chsvlib
chsv helper source code

◆ from_string() [6/9]

T Chusov::String::from_string ( const ucp_t pszValue,
int  base = 10 
)

A set of templates providing an interface to convert an argument specifying a C or C++ string to a value of a specified type. This template is available (i.e. participates in overload resolution) when the type is integral.

Template Parameters
Tis a type for the string value to convert to. The type T must be either constructible from pszValue directly or be one of the fundamental arithmetic types. Particularly this overload is chosen when T is integral.
Parameters
pszValueA C-string containing the value to convert.
baseA base in which the integral numeric value is expected in pszValue.
Returns
The resulting value.

The function performs a transformation of a Unicode string to an integral value of the type T provided that the whole zero-terminated string pszValue represents the value to return with respect to base. If not all characters of pszValue an be converted to the numeric value, the function fails and generates InvalidParameterException.

If the function is called with one argument and non-integral T, Chusov::String::from_string(In_z const ucp_t* pszValue) "another overload" will be used from the conversion.

Note
Unlike C and C++ library conversion functions, this function fails, if pszValue is an empty string, or if not the entire pszValue can be converted into the type T, because of parsing errors or when the produced value goes out of valid range of supported values for T.
Exceptions
Chusov::Exceptions::InvalidParameterExceptionParsing or range error occurred during the conversion to T.
See also
to_ucp_string(int value)
to_ucp_string(long value)
to_ucp_string(long long value)
to_ucp_string(unsigned value)
to_ucp_string(unsigned long value)
to_ucp_string(unsigned long long value)
to_ucp_string(float value)
to_ucp_string(double value)
to_ucp_string(long double value)
from_string(const ucp_t* pszValue)