26 int8_t minLength1, int8_t minLength2, int8_t minLength3, int8_t minLength4,
27 int8_t minLength5, int8_t minLength6, int8_t minLength7 )
29,
minLengths {minLength1, minLength2, minLength3, minLength4, minLength5, minLength6, minLength7} {
46 for(
int i= 0 ; i < 7 ; ++i ) {
70 size_t qtyMinLengths= 0;
80 if( qtyMinLengths >= 7 ) {
105 if( qtyMinLengths == 0 )
108 if( qtyMinLengths > 0 && qtyMinLengths < 7 )
133 while( qtyMinLength < 7 &&
minLengths[qtyMinLength] >= 0 )
138 if( qtyMinLength > 1 ) {
141 int qtyUpperCases= 0;
142 int qtyUnderscores= 0;
146 if( c ==
'_' ) ++qtyUnderscores;
147 else if( c ==
'-' ) ++qtyHyphens;
148 else if( isalpha(c) ) {
159 if( qtyUnderscores > 0 ) {
162 if( (qtyUnderscores >= 7 && qtyMinLength != 7 )
163 || (qtyUnderscores < 7 && qtyMinLength != qtyUnderscores + 1 ) )
169 else if( qtyHyphens > 0 ) {
172 if( (qtyHyphens >= 7 && qtyMinLength != 7 )
173 || (qtyHyphens < 7 && qtyMinLength != qtyHyphens + 1 ) )
179 else if( hasLowerCases && ( qtyUpperCases > 0 ) ) {
182 if( (qtyUpperCases >= 7 && qtyMinLength != 7 )
183 || (qtyUpperCases < 7 && qtyMinLength != qtyUpperCases + 1 ) )
211 int segmentLength= 0;
216 bool segmentEnd= c ==
'\0'
222 if( segmentNo < 7 &&
minLengths[segmentNo] > segmentLength ) {
231 for(
int minLenIdx= 0 ; minLenIdx < 7 && minLengths[minLenIdx] >= 0 ; ++minLenIdx ) {
234 || !( minLenIdx == 6 ||
minLengths[minLenIdx + 1] == -1 ) ) )
246 "Empty search string in when matching function name." )
261 bool isSegOK =
false;
278 if( n ==
'\0' && segMinLen == 0)
283 if( segLen == 1 && rollbackLen > 0) {
297 else if( same && isSegOK )
303 || (isSnake && h ==
'_' )
304 || (isKebab && h ==
'-' )
310 isSegOK= ( ( segMinLen >= 0 && segLen >= segMinLen )
311 || ( segMinLen < 0 && isSegEnd ) );
315 else if( segLen == 1 && segMinLen != 0 )
320 if( isSegEnd && n !=
'\0') {
332 && ( ( isCamel && (!isalpha(h) || !isupper(h) ) )
333 || ( isSnake && h !=
'_' )
334 || ( isKebab && h !=
'-' ) ) )
342 if( !same || isSegEnd ) {
345 segMinLen = segNo < 7 ?
minLengths[segNo] : -2;
348 if( n ==
'\0' && (!isCamel || h ==
'\0' || rollbackLen == 0) )
349 return h ==
'\0' || isNormal || segMinLen == 0;
352 return same && isSegOK && (nIdx == needle.
Length());
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_REL_DBG(releaseCode,...)
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
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
void Define(const String &definition, character separator=';')
bool Match(const String &needle)
void GetExportName(AString &target) const
bool Parse(strings::TSubstring< TChar > &input, TEnum &result)
Case
Denotes upper and lower case character treatment.
@ Exclude
Chooses exclusion.
lang::integer integer
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
characters::character character
Type alias in namespace #"%alib".