ALib C++ Library
Library Version: 2510 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
19#else
21#endif
22// ====================================== Implementation =======================================
23namespace alib { namespace strings { namespace util {
24
25template<typename TChar>
27{
28 if ( Rest.IsNull() )
29 {
30 Actual= nullptr;
31 return Actual;
32 }
33
34 // change of delim?
35 if ( newDelim != '\0' )
36 delim= newDelim;
37
38 do
39 {
40 integer nextDelimiter= Rest.IndexOf( delim );
41
42 if ( nextDelimiter >= 0 )
43 {
44 Actual= Rest.template Substring<NC>( 0 , nextDelimiter );
45 Rest = Rest.template Substring<NC>( nextDelimiter + 1, Rest.Length() - (nextDelimiter + 1) );
46 }
47 else
48 {
49 Actual= Rest;
50 Rest = nullptr;
51 }
52
53 // trim
54 if ( trimming == lang::Whitespaces::Trim )
55 Actual.Trim( TrimChars );
56 }
57 while( skipEmpty && Actual.IsEmpty() && Rest.IsNotNull() );
58
59 return Actual;
60}
61
64
65}}} // namespace [alib::strings::util]
66
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:78
TSubstring< TChar > Actual
Definition tokenizer.inl:66
bool skipEmpty
If true, empty tokens are omitted.
Definition tokenizer.inl:81
TLocalString< TChar, 8 > TrimChars
Definition tokenizer.inl:70
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.