8#if defined(_MSC_VER) && defined(max)
9# if __cplusplus < 202302L
10# pragma message("The macro `max` is defined. If you include the `Windows.h` file, please define the 'NOMINMAX' constant before including `Windows.h`. xtd will undef the `max` macro.")
12# warning "The macro `max` is defined. If you include the `Windows.h` file, please define the 'NOMINMAX' constant before including `Windows.h`. xtd will undef the `max` macro."
17#define __XTD_CORE_INTERNAL__
19#undef __XTD_CORE_INTERNAL__
33 template<
class value_t>
34 inline value_t
parse(
const std::string& str) {
35 if (std::is_enum<value_t>::value)
return __parse_enum<value_t>(str);
34 inline value_t
parse(
const std::string& str) {
…}
45 template<
class value_t>
54 template<
class value_t>
72 template<
class value_t>
81 template<
class value_t>
190 inline float parse<float>(
const std::string& str,
number_styles styles) {
return __parse_floating_point_number<float>(str, styles, std::locale());}
199 inline float parse<float>(
const std::string& str,
number_styles styles,
const std::locale& locale) {
return __parse_floating_point_number<float>(str, styles, locale);}
208 inline double parse<double>(
const std::string& str,
number_styles styles) {
return __parse_floating_point_number<double>(str, styles, std::locale());}
217 inline double parse<double>(
const std::string& str,
number_styles styles,
const std::locale& locale) {
return __parse_floating_point_number<double>(str, styles, locale);}
235 inline long double parse<long double>(
const std::string& str,
number_styles styles,
const std::locale& locale) {
return __parse_floating_point_number<long double>(str, styles, locale);}
371 std::string lower_str = str;
372 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))
373 lower_str.erase(0, 1);
374 while (lower_str.size() > 0 && (lower_str[lower_str.size() - 1] == 9 || lower_str[lower_str.size() - 1] == 10 || lower_str[lower_str.size() - 1] == 11 || lower_str[lower_str.size() - 1] == 12 || lower_str[lower_str.size() - 1] == 13 || lower_str[lower_str.size() - 1] == 32))
375 lower_str.erase(lower_str.size() - 1, 1);
376 for (
auto&
c : lower_str)
377 c =
static_cast<char>(std::tolower(
c));
379 return lower_str ==
"true" || lower_str ==
"1";
388 template<
class value_t>
397 template<
class value_t>
406 template<
class value_t>
415 template<
class value_t>
416 inline bool try_parse(
const std::basic_string<char>& str, value_t& value)
noexcept {
416 inline bool try_parse(
const std::basic_string<char>& str, value_t& value)
noexcept {
…}
430 template<
class value_t>
431 inline bool try_parse(
const std::basic_string<xtd::char16>& str, value_t& value)
noexcept {
431 inline bool try_parse(
const std::basic_string<xtd::char16>& str, value_t& value)
noexcept {
…}
445 template<
class value_t>
446 inline bool try_parse(
const std::basic_string<xtd::char32>& str, value_t& value)
noexcept {
446 inline bool try_parse(
const std::basic_string<xtd::char32>& str, value_t& value)
noexcept {
…}
460 template<
class value_t>
461 inline bool try_parse(
const std::basic_string<xtd::char8>& str, value_t& value)
noexcept {
461 inline bool try_parse(
const std::basic_string<xtd::char8>& str, value_t& value)
noexcept {
…}
475 template<
class value_t>
476 inline bool try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value)
noexcept {
476 inline bool try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value)
noexcept {
…}
491 template<
class value_t>
492 inline bool try_parse(
const std::basic_string<char>& str, value_t& value,
const std::locale& locale)
noexcept {
492 inline bool try_parse(
const std::basic_string<char>& str, value_t& value,
const std::locale& locale)
noexcept {
…}
506 template<
class value_t>
507 inline bool try_parse(
const std::basic_string<xtd::char16>& str, value_t& value,
const std::locale& locale)
noexcept {
507 inline bool try_parse(
const std::basic_string<xtd::char16>& str, value_t& value,
const std::locale& locale)
noexcept {
…}
521 template<
class value_t>
522 inline bool try_parse(
const std::basic_string<xtd::char32>& str, value_t& value,
const std::locale& locale)
noexcept {
522 inline bool try_parse(
const std::basic_string<xtd::char32>& str, value_t& value,
const std::locale& locale)
noexcept {
…}
536 template<
class value_t>
537 inline bool try_parse(
const std::basic_string<xtd::char8>& str, value_t& value,
const std::locale& locale)
noexcept {
537 inline bool try_parse(
const std::basic_string<xtd::char8>& str, value_t& value,
const std::locale& locale)
noexcept {
…}
551 template<
class value_t>
552 inline bool try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value,
const std::locale& locale)
noexcept {
552 inline bool try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value,
const std::locale& locale)
noexcept {
…}
567 template<
class value_t,
class char_t>
568 inline bool try_parse(
const char_t* str, value_t& value)
noexcept {
569 return try_parse(std::basic_string<char_t>(str), value);
568 inline bool try_parse(
const char_t* str, value_t& value)
noexcept {
…}
578 template<
class value_t,
class char_t>
579 inline bool try_parse(
const char_t* str, value_t& value,
const std::locale& locale)
noexcept {
580 return try_parse(std::basic_string<char_t>(str), value, locale);
579 inline bool try_parse(
const char_t* str, value_t& value,
const std::locale& locale)
noexcept {
…}
589 template<
class value_t>
604 template<
class value_t>
619 template<
class value_t>
634 template<
class value_t>
649 template<
class value_t>
665 template<
class value_t>
666 inline bool try_parse(
const std::basic_string<char>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
666 inline bool try_parse(
const std::basic_string<char>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
…}
680 template<
class value_t>
681 inline bool try_parse(
const std::basic_string<xtd::char16>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
681 inline bool try_parse(
const std::basic_string<xtd::char16>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
…}
695 template<
class value_t>
696 inline bool try_parse(
const std::basic_string<xtd::char32>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
696 inline bool try_parse(
const std::basic_string<xtd::char32>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
…}
710 template<
class value_t>
711 inline bool try_parse(
const std::basic_string<xtd::char8>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
711 inline bool try_parse(
const std::basic_string<xtd::char8>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
…}
725 template<
class value_t>
726 inline bool try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
726 inline bool try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept {
…}
741 template<
class value_t,
class char_t>
743 return try_parse(std::basic_string<char_t>(str), value, style);
752 template<
class value_t,
class char_t>
754 return try_parse(std::basic_string<char_t>(str), value, style, locale);
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
@ format
The format is not valid.
Definition exception_case.hpp:49
int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
double parse< double >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:208
number_styles
Determines the styles permitted in numeric string arguments that are passed to the xtd::parse and xtd...
Definition number_styles.hpp:16
char parse< char >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:100
bool parse< bool >(const std::string &str)
Convert a string into a type.
Definition parse.hpp:370
xtd::sbyte parse< xtd::sbyte >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:91
unsigned long parse< unsigned long >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:163
long long parse< long long >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:172
long double parse< long double >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:226
int parse< int >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:136
long parse< long >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:154
unsigned char parse< unsigned char >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:109
std::string parse< std::string >(const std::string &str)
Convert a string into a type.
Definition parse.hpp:64
float parse< float >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:190
short parse< short >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:118
unsigned int parse< unsigned int >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:145
unsigned short parse< unsigned short >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:127
unsigned long long parse< unsigned long long >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:181
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.hpp:34
bool try_parse(const std::basic_string< char > &str, value_t &value) noexcept
Convert a string into a type.
Definition parse.hpp:416
@ integer
Indicates that the allow_leading_white, allow_trailing_white, and allow_leading_sign styles are used....
Definition number_styles.hpp:44
@ fixed_point
Indicates that the allow_leading_white, allow_trailing_white, allow_leading_sign, allow_decimal_point...
Definition number_styles.hpp:48
@ c
The C key.
Definition console_key.hpp:92
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::number_styles enum class.
Contains xtd fundamental types.