A functor for reading numerical values from a string or character array.
More...
#include <utility.hpp>
|
template<typename T > |
bool | operator() (T &dst) |
| Retrieve an integral or floating point value from the array. More...
|
|
| operator bool () const |
| Check if unread characters remain. More...
|
|
| FromChars (char const *const start, char const *const end) |
| Range based constructor. More...
|
|
template<size_t CountV> |
| FromChars (char const (&str)[CountV], bool const terminator=true) |
| Construct from a character array. More...
|
|
| FromChars (std::string const &str) |
| Construct functor from a string. More...
|
|
|
const char * | it |
| The next character to read.
|
|
const char *const | end |
| The first character of the same array that may not be read, this should usually point to a terminating zero or behind a buffer.
|
|
A functor for reading numerical values from a string or character array.
◆ FromChars() [1/3]
utility::FromChars::FromChars |
( |
char const *const |
start, |
|
|
char const *const |
end |
|
) |
| |
|
inline |
Range based constructor.
- Parameters
-
start,end | The character array range |
◆ FromChars() [2/3]
template<size_t CountV>
utility::FromChars::FromChars |
( |
char const (&) |
str[CountV], |
|
|
bool const |
terminator = true |
|
) |
| |
|
inline |
Construct from a character array.
- Template Parameters
-
CountV | The number of characters |
- Parameters
-
str | The character array to parse from |
terminator | Indicates whether the character array has a terminating null character. |
◆ FromChars() [3/3]
utility::FromChars::FromChars |
( |
std::string const & |
str | ) |
|
|
inline |
Construct functor from a string.
Note that changing the string during the lifetime of the functor may silently invalidate the functor's state and thus invoke undefined behaviour.
- Parameters
-
str | The string to parse from |
◆ operator bool()
utility::FromChars::operator bool |
( |
| ) |
const |
|
inline |
Check if unread characters remain.
- Return values
-
false | All characters have been read |
true | Characters remain to be read |
◆ operator()()
template<typename T >
bool utility::FromChars::operator() |
( |
T & |
dst | ) |
|
|
inline |
Retrieve an integral or floating point value from the array.
The operation may fail for multiple reasons:
- No more characters left to read, in that case the functor will equal false
- The given characters do not represent a valid value, in that case the functor will equal true
- Template Parameters
-
T | The value type to retrieve |
- Parameters
-
dst | The lvalue to assign to |
- Return values
-
true | The numerical value was successfully read from the array |
false | The numerical value could not be read from the array |
The documentation for this struct was generated from the following file: