ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
tokenizer.cpp
1//##################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2025 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6//##################################################################################################
7#include "alib_precompile.hpp"
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"
10#endif
11#if ALIB_C20_MODULES
12 module;
13#endif
14//========================================= Global Fragment ========================================
16//============================================== Module ============================================
17#if ALIB_C20_MODULES
18 module ALib.Strings.Tokenizer;
19#else
21#endif
22//========================================== Implementation ========================================
23namespace alib { namespace strings { namespace util {
24
25template<typename TChar>
27 if ( Rest.IsNull() ) {
28 Actual= nullptr;
29 return Actual;
30 }
31
32 // change of delim?
33 if ( newDelim != '\0' )
34 delim= newDelim;
35
36 do
37 {
38 integer nextDelimiter= Rest.IndexOf( delim );
39
40 if ( nextDelimiter >= 0 ) {
41 Actual= Rest.template Substring<NC>( 0 , nextDelimiter );
42 Rest = Rest.template Substring<NC>( nextDelimiter + 1, Rest.Length() - (nextDelimiter + 1) );
43 } else {
44 Actual= Rest;
45 Rest = nullptr;
46 }
47
48 // trim
49 if ( trimming == lang::Whitespaces::Trim )
50 Actual.Trim( TrimChars );
51 }
52 while( skipEmpty && Actual.IsEmpty() && Rest.IsNotNull() );
53
54 return Actual;
55}
56
59
60}}} // namespace [alib::strings::util]
ALIB_DLL TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
Definition tokenizer.cpp:26
TChar delim
The most recently set delimiter used by default for the next token extraction.
Definition tokenizer.inl:79
TSubstring< TChar > Actual
Definition tokenizer.inl:67
bool skipEmpty
If true, empty tokens are omitted.
Definition tokenizer.inl:82
TLocalString< TChar, 8 > TrimChars
Definition tokenizer.inl:71
Whitespaces
Denotes whether a string is trimmed or not.
@ Trim
Trim whitespaces away.
characters::wchar wchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
characters::nchar nchar
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.