ALib C++ Library
by
Library Version:
2402 R1
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
strings
util
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
// #################################################################################################
7
#include "
alib/alib_precompile.hpp
"
8
9
#if !defined(ALIB_DOX)
10
#if !defined (HPP_ALIB_STRINGS_UTIL_TOKENIZER)
11
# include "
alib/strings/util/tokenizer.hpp
"
12
#endif
13
#endif
// !defined(ALIB_DOX)
14
15
namespace
alib
{
namespace
strings {
namespace
util {
16
17
template
<
typename
TChar>
18
TSubstring<TChar>
&
TTokenizer<TChar>::Next
(
lang::Whitespaces
trimming, TChar newDelim )
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
54
template
TSubstring<nchar>
&
TTokenizer<nchar>::Next
(
lang::Whitespaces
trimming,
nchar
newDelim );
55
template
TSubstring<wchar>
&
TTokenizer<wchar>::Next
(
lang::Whitespaces
trimming,
wchar
newDelim );
56
57
}}}
// namespace [alib::strings::util]
alib_precompile.hpp
alib::strings::TString::IndexOf
integer IndexOf(TChar needle, integer startIdx=0) const
Definition
string.hpp:889
alib::strings::TSubstring
Definition
substring.hpp:49
alib::strings::util::TTokenizer::Next
ALIB_API TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
Definition
tokenizer.cpp:18
alib::lang::Whitespaces
Whitespaces
Definition
commonenumdefs.hpp:261
alib::lang::Whitespaces::Trim
@ Trim
Trim whitespaces away.
alib
Definition
alib.cpp:57
alib::wchar
characters::wchar wchar
Type alias in namespace alib.
Definition
characters.hpp:659
alib::nchar
characters::nchar nchar
Type alias in namespace alib.
Definition
characters.hpp:656
alib::integer
lang::integer integer
Type alias in namespace alib.
Definition
integers.hpp:286
tokenizer.hpp