ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
tokenizer.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2024 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
8
9#if !DOXYGEN
11#endif // !DOXYGEN
12
13namespace alib { namespace strings { namespace util {
14
15template<typename TChar>
17{
18 if ( Rest.IsNull() )
19 {
20 Actual= nullptr;
21 return Actual;
22 }
23
24 // change of delim?
25 if ( newDelim != '\0' )
26 delim= newDelim;
27
28 do
29 {
30 integer nextDelimiter= Rest.IndexOf( delim );
31
32 if ( nextDelimiter >= 0 )
33 {
34 Actual= Rest.template Substring<NC>( 0 , nextDelimiter );
35 Rest = Rest.template Substring<NC>( nextDelimiter + 1, Rest.Length() - (nextDelimiter + 1) );
36 }
37 else
38 {
39 Actual= Rest;
40 Rest = nullptr;
41 }
42
43 // trim
44 if ( trimming == lang::Whitespaces::Trim )
45 Actual.Trim( TrimChars );
46 }
47 while( skipEmpty && Actual.IsEmpty() && Rest.IsNotNull() );
48
49 return Actual;
50}
51
54
55}}} // namespace [alib::strings::util]
56
ALIB_API TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
Definition tokenizer.cpp:16
Whitespaces
Denotes whether a string is trimmed or not.
@ Trim
Trim whitespaces away.
Definition alib.cpp:69
characters::wchar wchar
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:273