ALib C++ Library
Library Version: 2402 R1
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 !defined(ALIB_DOX)
10#if !defined (HPP_ALIB_STRINGS_UTIL_TOKENIZER)
12#endif
13#endif // !defined(ALIB_DOX)
14
15namespace alib { namespace strings { namespace util {
16
17template<typename TChar>
19{
20 if ( Rest.IsNull() )
21 {
22 Actual= nullptr;
23 return Actual;
24 }
25
26 // change of delim?
27 if ( newDelim != '\0' )
28 delim= newDelim;
29
30 do
31 {
32 integer nextDelimiter= Rest.IndexOf( delim );
33
34 if ( nextDelimiter >= 0 )
35 {
36 Actual= Rest.template Substring<false>( 0 , nextDelimiter );
37 Rest = Rest.template Substring<false>( nextDelimiter + 1, Rest.Length() - (nextDelimiter + 1) );
38 }
39 else
40 {
41 Actual= Rest;
42 Rest = nullptr;
43 }
44
45 // trim
46 if ( trimming == lang::Whitespaces::Trim )
47 Actual.Trim( TrimChars );
48 }
49 while( skipEmpty && Actual.IsEmpty() && Rest.IsNotNull() );
50
51 return Actual;
52}
53
56
57}}} // namespace [alib::strings::util]
integer IndexOf(TChar needle, integer startIdx=0) const
Definition string.hpp:889
ALIB_API TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
Definition tokenizer.cpp:18
@ Trim
Trim whitespaces away.
Definition alib.cpp:57
characters::wchar wchar
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:286