8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
61 int8_t minLength1, int8_t minLength2, int8_t minLength3, int8_t minLength4, int8_t minLength5,
62 int8_t minLength6, int8_t minLength7 )
64,
minLengths { minLength1, minLength2, minLength3, minLength4, minLength5, minLength6, minLength7 }
85 for(
int i= 0 ; i < 7 ; ++i )
114 size_t qtyMinLengths= 0;
127 if( qtyMinLengths >= 7 )
157 if( qtyMinLengths == 0 )
160 if( qtyMinLengths > 0 && qtyMinLengths < 7 )
187 while( qtyMinLength < 7 &&
minLengths[qtyMinLength] >= 0 )
192 if( qtyMinLength > 1 )
196 int qtyUpperCases= 0;
197 int qtyUnderscores= 0;
202 if( c ==
'_' ) ++qtyUnderscores;
203 else if( c ==
'-' ) ++qtyHyphens;
204 else if( isalpha(c) )
216 if( qtyUnderscores > 0 )
220 if( (qtyUnderscores >= 7 && qtyMinLength != 7 )
221 || (qtyUnderscores < 7 && qtyMinLength != qtyUnderscores + 1 ) )
227 else if( qtyHyphens > 0 )
231 if( (qtyHyphens >= 7 && qtyMinLength != 7 )
232 || (qtyHyphens < 7 && qtyMinLength != qtyHyphens + 1 ) )
238 else if( hasLowerCases && ( qtyUpperCases > 0 ) )
242 if( (qtyUpperCases >= 7 && qtyMinLength != 7 )
243 || (qtyUpperCases < 7 && qtyMinLength != qtyUpperCases + 1 ) )
276 int segmentLength= 0;
282 bool segmentEnd= c ==
'\0'
289 if( segmentNo < 7 &&
minLengths[segmentNo] > segmentLength )
300 for(
int minLenIdx= 0 ; minLenIdx < 7 && minLengths[minLenIdx] >= 0 ; ++minLenIdx )
304 || !( minLenIdx == 6 ||
minLengths[minLenIdx + 1] == -1 ) ) )
319 "Empty search string in when matching function name." )
334 bool isSegOK =
false;
353 if( n ==
'\0' && segMinLen == 0)
359 if( segLen == 1 && rollbackLen > 0)
374 else if( same && isSegOK )
380 || (isSnake && h ==
'_' )
381 || (isKebab && h ==
'-' )
388 isSegOK= ( ( segMinLen >= 0 && segLen >= segMinLen )
389 || ( segMinLen < 0 && isSegEnd ) );
393 else if( segLen == 1 && segMinLen != 0 )
398 if( isSegEnd && n !=
'\0')
412 && ( ( isCamel && (!isalpha(h) || !isupper(h) ) )
413 || ( isSnake && h !=
'_' )
414 || ( isKebab && h !=
'-' ) ) )
422 if( !same || isSegEnd )
426 segMinLen = segNo < 7 ?
minLengths[segNo] : -2;
429 if( n ==
'\0' && (!isCamel || h ==
'\0' || rollbackLen == 0) )
430 return h ==
'\0' || isNormal || segMinLen == 0;
434 return same && isSegOK && (nIdx == needle.
Length());
constexpr integer Length() const
TChar CharAtStart() const
TChar CharAt(integer idx) const
constexpr bool IsNotEmpty() const
bool ConsumeDecDigits(std::integral auto &result)
TSubstring & Trim(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
@ ErrorReadingSensitivity
Sensitivity value not found.
@ TooManyMinLengthsGiven
A maximum of 7 minimum length values was exceeded.
@ EmptyName
No token name found.
@ ZeroMinLengthAndNotLastCamelHump
@ ErrorReadingMinLengths
Error parsing the list of minimum lengths.
@ DefinitionStringNotConsumed
The definition string was not completely consumed.
@ MinLenExceedsSegmentLength
ALIB_DLL void detectFormat()
Detects snake_case, kebab-case or CamelCase.
int8_t GetMinLength(int idx) const
String definitionName
The tokens' definition string part.
const String & GetDefinitionName() const
lang::Case Sensitivity() const
Formats
Format types detected with detectFormat.
@ CamelCase
UpperCamelCase or lowerCamelCase.
@ SnakeCase
snake_case using underscores.
@ Normal
Normal, optionally abbreviated words.
@ KebabCase
kebab-case using hyphens.
Token()
Parameterless constructor. Creates an "undefined" token.
Formats format
Defines the "case type" as well as the letter case sensitivity of this token.
String exportName
The tokens' optional explicit export name.
static constexpr Formats ignoreCase
Letter case sensitivity. This is combined with the format bits.
Formats GetFormat() const
ALIB_DLL void Define(const String &definition, character separator=';')
ALIB_DLL bool Match(const String &needle)
ALIB_DLL void GetExportName(AString &target) const
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_REL_DBG(releaseCode,...)
bool Parse(strings::TSubstring< TChar > &input, TEnum &result)
Case
Denotes upper and lower case character treatment.
@ Exclude
Chooses exclusion.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.