7 #define __XTD_CORE_INTERNAL__
8 #include "internal/__parse.h"
9 #undef __XTD_CORE_INTERNAL__
21 template<
typename value_t>
22 inline value_t
parse(
const std::string& str) {__throw_parse_format_exception(
"Parse specialisation not found");
return {};}
30 template<
typename value_t>
31 inline value_t
parse(
const std::string& str,
const std::string& fmt) {__throw_parse_format_exception(
"Parse specialisation not found");
return {};}
40 inline std::string parse<std::string>(
const std::string& str) {
return str;}
48 template<
typename value_t>
49 inline value_t
parse(
const std::string& str,
number_styles) {__throw_parse_format_exception(
"Parse specialisation not found");
return {};}
311 std::string lower_str = str;
312 while(lower_str.size() > 0 && (lower_str[0] == 9 || lower_str[0] == 10 || lower_str[0] == 11 || lower_str[0] == 12 || lower_str[0] == 13 || lower_str[0] == 32))
313 lower_str.erase(0, 1);
314 for (
auto&
c : lower_str)
315 c =
static_cast<char>(std::tolower(
c));
316 if (lower_str !=
"true" && lower_str !=
"1" && lower_str !=
"false" && lower_str !=
"0") __throw_parse_format_exception(
"Invalid string format");
317 return lower_str ==
"true" || lower_str ==
"1";
326 template<
typename value_t>
327 inline value_t
parse(
const std::wstring& str) {__throw_parse_format_exception(
"Parse specialisation not found");
return {};}
335 template<
typename value_t>
336 inline value_t
parse(
const std::u16string& str) {__throw_parse_format_exception(
"Parse specialisation not found");
return {};}
344 template<
typename value_t>
345 inline value_t
parse(
const std::u32string& str) {__throw_parse_format_exception(
"Parse specialisation not found");
return {};}
353 template<
typename value_t,
typename char_t>
354 inline bool try_parse(
const std::basic_string<char_t>& str, value_t& value) {
356 value = parse<value_t>(str);
369 template<
typename value_t,
typename char_t>
370 inline bool try_parse(
const char_t* str, value_t& value) {
371 return try_parse(std::basic_string<char_t>(str), value);
double parse< double >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:166
number_styles
Determines the styles permitted in numeric string arguments that are passed to the xtd::parse and xtd...
Definition: number_styles.h:15
int8_t parse< int8_t >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:58
char parse< char >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:67
bool parse< bool >(const std::string &str)
Convert a type into a string.
Definition: parse.h:310
unsigned long parse< unsigned long >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:130
long long parse< long long >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:139
long double parse< long double >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:175
bool try_parse(const std::basic_string< char_t > &str, value_t &value)
Convert a type into a string.
Definition: parse.h:354
int parse< int >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:103
long parse< long >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:121
unsigned char parse< unsigned char >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:76
float parse< float >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:157
short parse< short >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:85
unsigned int parse< unsigned int >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:112
unsigned short parse< unsigned short >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:94
unsigned long long parse< unsigned long long >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition: parse.h:148
value_t parse(const std::string &str)
Convert a type into a string.
Definition: parse.h:22
@ integer
Indicates that the allow_leading_white, allow_trailing_white, and allow_leading_sign styles are used....
@ fixed_point
Indicates that the allow_leading_white, allow_trailing_white, allow_leading_sign, allow_decimal_point...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::number_styles enum class.