ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
substring.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
12#endif // !DOXYGEN
13
14// Windows.h might bring in max/min macros
15#if defined( max )
16 #undef max
17 #undef min
18#endif
19
20namespace alib { namespace strings {
21
22template<typename TChar>
24{
25 integer idx= 0;
26 result= detail::ParseDecDigits( *this, idx );
27 if( idx > 0 )
28 {
29 ConsumeChars<NC>( idx );
30 return true;
31 }
32 return false;
33}
34
35template<typename TChar>
36bool TSubstring<TChar>::consumeIntImpl( int64_t& result, TNumberFormat<TChar>* numberFormat )
37{
38 if ( numberFormat == nullptr )
40
41 integer idx= 0;
42 result= detail::ParseInt( *this, idx, *numberFormat );
43 if( idx > 0 )
44 {
45 ConsumeChars<NC>( idx );
46 return true;
47 }
48 return false;
49}
50
51template<typename TChar>
52bool TSubstring<TChar>::consumeDecImpl( uint64_t& result, TNumberFormat<TChar>* numberFormat )
53{
54 if ( numberFormat == nullptr )
56
57 integer idx= 0;
58 result= detail::ParseDec( *this, idx, *numberFormat );
59 if( idx > 0 )
60 {
61 ConsumeChars<NC>( idx );
62 return true;
63 }
64 return false;
65}
66
67template<typename TChar>
68bool TSubstring<TChar>::consumeBinImpl( uint64_t& result, TNumberFormat<TChar>* numberFormat )
69{
70 if ( numberFormat == nullptr )
72
73 integer idx= 0;
74 result= detail::ParseBin( *this, idx, *numberFormat );
75 if( idx > 0 )
76 {
77 ConsumeChars<NC>( idx );
78 return true;
79 }
80 return false;
81}
82
83template<typename TChar>
84bool TSubstring<TChar>::consumeHexImpl( uint64_t& result, TNumberFormat<TChar>* numberFormat )
85{
86 if ( numberFormat == nullptr )
88
89 integer idx= 0;
90 result= detail::ParseHex( *this, idx, *numberFormat );
91 if( idx > 0 )
92 {
93 ConsumeChars<NC>( idx );
94 return true;
95 }
96 return false;
97}
98
99template<typename TChar>
100bool TSubstring<TChar>::consumeOctImpl( uint64_t& result, TNumberFormat<TChar>* numberFormat )
101{
102 if ( numberFormat == nullptr )
104
105 integer idx= 0;
106 result= detail::ParseOct( *this, idx, *numberFormat );
107 if( idx > 0 )
108 {
109 ConsumeChars<NC>( idx );
110 return true;
111 }
112 return false;
113}
114
115template<typename TChar>
117 TNumberFormat<TChar>* numberFormat )
118{
119 if ( numberFormat == nullptr )
121
122 integer idx= 0;
123 result= detail::ParseFloat( *this, idx, *numberFormat );
124 if( idx > 0 )
125 {
126 ConsumeChars<NC>( idx );
127 return true;
128 }
129 return false;
130}
131
132
133template bool TSubstring<nchar>::ConsumeFloat ( double& , TNumberFormat<nchar>* );
134template bool TSubstring<nchar>::consumeDecDigitsImpl( uint64_t& );
135template bool TSubstring<nchar>::consumeIntImpl ( int64_t& , TNumberFormat<nchar>* );
136template bool TSubstring<nchar>::consumeDecImpl ( uint64_t& , TNumberFormat<nchar>* );
137template bool TSubstring<nchar>::consumeBinImpl ( uint64_t& , TNumberFormat<nchar>* );
138template bool TSubstring<nchar>::consumeHexImpl ( uint64_t& , TNumberFormat<nchar>* );
139template bool TSubstring<nchar>::consumeOctImpl ( uint64_t& , TNumberFormat<nchar>* );
140
141template bool TSubstring<wchar>::ConsumeFloat ( double& , TNumberFormat<wchar>* );
142template bool TSubstring<wchar>::consumeDecDigitsImpl( uint64_t& );
143template bool TSubstring<wchar>::consumeIntImpl ( int64_t& , TNumberFormat<wchar>* );
144template bool TSubstring<wchar>::consumeDecImpl ( uint64_t& , TNumberFormat<wchar>* );
145template bool TSubstring<wchar>::consumeBinImpl ( uint64_t& , TNumberFormat<wchar>* );
146template bool TSubstring<wchar>::consumeHexImpl ( uint64_t& , TNumberFormat<wchar>* );
147template bool TSubstring<wchar>::consumeOctImpl ( uint64_t& , TNumberFormat<wchar>* );
148
149template bool TSubstring<xchar>::ConsumeFloat ( double& , TNumberFormat<xchar>* );
150template bool TSubstring<xchar>::consumeDecDigitsImpl( uint64_t& );
151template bool TSubstring<xchar>::consumeIntImpl ( int64_t& , TNumberFormat<xchar>* );
152template bool TSubstring<xchar>::consumeDecImpl ( uint64_t& , TNumberFormat<xchar>* );
153template bool TSubstring<xchar>::consumeBinImpl ( uint64_t& , TNumberFormat<xchar>* );
154template bool TSubstring<xchar>::consumeHexImpl ( uint64_t& , TNumberFormat<xchar>* );
155template bool TSubstring<xchar>::consumeOctImpl ( uint64_t& , TNumberFormat<xchar>* );
156
157}} // namespace [alib::strings]
158
ALIB_API bool consumeDecDigitsImpl(uint64_t &result)
Definition substring.cpp:23
ALIB_API bool consumeBinImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
Definition substring.cpp:68
ALIB_API bool ConsumeFloat(double &result, TNumberFormat< TChar > *numberFormat=nullptr)
ALIB_API bool consumeHexImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
Definition substring.cpp:84
ALIB_API bool consumeIntImpl(int64_t &result, TNumberFormat< TChar > *numberFormat)
Definition substring.cpp:36
ALIB_API bool consumeDecImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
Definition substring.cpp:52
ALIB_API bool consumeOctImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
ALIB_API uint64_t ParseOct(const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf)
ALIB_API int64_t ParseInt(const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf)
ALIB_API uint64_t ParseHex(const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf)
ALIB_API uint64_t ParseBin(const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf)
uint64_t ParseDecDigits(const TString< TChar > &src, integer &idx)
ALIB_API double ParseFloat(const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf)
ALIB_API uint64_t ParseDec(const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf)
Definition alib.cpp:69
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:273