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