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<
typename value_t>
34 [[nodiscard]]
inline auto parse(
const std::string& str) -> value_t {
35 if (std::is_enum<value_t>::value)
return __parse_enum<value_t>(str);
45 template<
typename value_t>
54 template<
typename value_t>
64 [[nodiscard]]
inline auto parse<std::string>(
const std::string& str) -> std::string {
return str;}
72 template<
typename value_t>
81 template<
typename value_t>
100 [[nodiscard]]
inline auto parse<char>(
const std::string& str,
number_styles styles) ->
char {
return __parse_number<char>(str, styles);}
208 [[nodiscard]]
inline auto parse<double>(
const std::string& str,
number_styles styles) ->
double {
return __parse_floating_point_number<double>(str, styles, std::locale());}
217 [[nodiscard]]
inline auto parse<double>(
const std::string& str,
number_styles styles,
const std::locale& locale) ->
double {
return __parse_floating_point_number<double>(str, styles, locale);}
370 [[nodiscard]]
inline auto parse<bool>(
const std::string& str) ->
bool {
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<
typename value_t>
397 template<
typename value_t>
406 template<
typename value_t>
415 template<
typename value_t>
416 [[nodiscard]]
inline auto try_parse(
const std::basic_string<char>& str, value_t& value)
noexcept ->
bool {
430 template<
typename value_t>
431 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char16>& str, value_t& value)
noexcept ->
bool {
445 template<
typename value_t>
446 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char32>& str, value_t& value)
noexcept ->
bool {
460 template<
typename value_t>
461 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char8>& str, value_t& value)
noexcept ->
bool {
475 template<
typename value_t>
476 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value)
noexcept ->
bool {
491 template<
typename value_t>
492 [[nodiscard]]
inline auto try_parse(
const std::basic_string<char>& str, value_t& value,
const std::locale& locale)
noexcept ->
bool {
506 template<
typename value_t>
507 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char16>& str, value_t& value,
const std::locale& locale)
noexcept ->
bool {
521 template<
typename value_t>
522 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char32>& str, value_t& value,
const std::locale& locale)
noexcept ->
bool {
536 template<
typename value_t>
537 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char8>& str, value_t& value,
const std::locale& locale)
noexcept ->
bool {
551 template<
typename value_t>
552 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value,
const std::locale& locale)
noexcept ->
bool {
567 template<
typename value_t,
typename char_t>
568 [[nodiscard]]
inline auto try_parse(
const char_t* str, value_t& value)
noexcept ->
bool {
569 return try_parse(std::basic_string<char_t>(str), value);
578 template<
typename value_t,
typename char_t>
579 [[nodiscard]]
inline auto try_parse(
const char_t* str, value_t& value,
const std::locale& locale)
noexcept ->
bool {
580 return try_parse(std::basic_string<char_t>(str), value, locale);
589 template<
typename value_t>
590 [[nodiscard]]
inline auto try_parse(
const std::basic_string<char>& str, value_t& value,
number_styles style)
noexcept ->
bool {
604 template<
typename value_t>
605 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char16>& str, value_t& value,
number_styles style)
noexcept ->
bool {
619 template<
typename value_t>
620 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char32>& str, value_t& value,
number_styles style)
noexcept ->
bool {
634 template<
typename value_t>
635 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char8>& str, value_t& value,
number_styles style)
noexcept ->
bool {
649 template<
typename value_t>
650 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value,
number_styles style)
noexcept ->
bool {
665 template<
typename value_t>
666 [[nodiscard]]
inline auto try_parse(
const std::basic_string<char>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept ->
bool {
680 template<
typename value_t>
681 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char16>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept ->
bool {
695 template<
typename value_t>
696 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char32>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept ->
bool {
710 template<
typename value_t>
711 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::char8>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept ->
bool {
725 template<
typename value_t>
726 [[nodiscard]]
inline auto try_parse(
const std::basic_string<xtd::wchar>& str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept ->
bool {
741 template<
typename value_t,
typename char_t>
743 return try_parse(std::basic_string<char_t>(str), value, style);
752 template<
typename value_t,
typename char_t>
753 [[nodiscard]]
inline auto try_parse(
const char_t* str, value_t& value,
number_styles style,
const std::locale& locale)
noexcept ->
bool {
754 return try_parse(std::basic_string<char_t>(str), value, style, locale);
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
@ format
The format is not valid.
Definition exception_case.hpp:51
std::int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
__slong__ slong
Represents a 32-bit or 64-bit signed integer.
Definition slong.hpp:27
std::int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
__ulong__ ulong
Represents a 32-bit or 64-bit unsigned integer.
Definition ulong.hpp:27
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.hpp:23
std::uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
std::uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
std::uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
float single
Represents a single-precision floating-point number.
Definition single.hpp:23
auto parse< xtd::slong >(const std::string &str, number_styles styles) -> xtd::slong
Convert a string into a type.
Definition parse.hpp:172
number_styles
Determines the styles permitted in numeric string arguments that are passed to the xtd::parse and xtd...
Definition number_styles.hpp:16
auto parse< xtd::uint32 >(const std::string &str, number_styles styles) -> xtd::uint32
Convert a string into a type.
Definition parse.hpp:145
auto parse< xtd::sbyte >(const std::string &str, number_styles styles) -> xtd::sbyte
Convert a string into a type.
Definition parse.hpp:91
auto try_parse(const std::basic_string< char > &str, value_t &value) noexcept -> bool
Convert a string into a type.
Definition parse.hpp:416
auto parse< char >(const std::string &str, number_styles styles) -> char
Convert a string into a type.
Definition parse.hpp:100
auto parse< xtd::uint64 >(const std::string &str, number_styles styles) -> xtd::uint64
Convert a string into a type.
Definition parse.hpp:163
auto parse< xtd::decimal >(const std::string &str, number_styles styles) -> xtd::decimal
Convert a string into a type.
Definition parse.hpp:226
auto parse(const std::string &str) -> value_t
Convert a string into a type.
Definition parse.hpp:34
auto parse< double >(const std::string &str, number_styles styles) -> double
Convert a string into a type.
Definition parse.hpp:208
auto parse< xtd::int32 >(const std::string &str, number_styles styles) -> xtd::int32
Convert a string into a type.
Definition parse.hpp:136
auto parse< bool >(const std::string &str) -> bool
Convert a string into a type.
Definition parse.hpp:370
auto parse< std::string >(const std::string &str) -> std::string
Convert a string into a type.
Definition parse.hpp:64
auto parse< xtd::single >(const std::string &str, number_styles styles) -> xtd::single
Convert a string into a type.
Definition parse.hpp:190
auto parse< xtd::int64 >(const std::string &str, number_styles styles) -> xtd::int64
Convert a string into a type.
Definition parse.hpp:154
auto parse< xtd::byte >(const std::string &str, number_styles styles) -> xtd::byte
Convert a string into a type.
Definition parse.hpp:109
auto parse< xtd::int16 >(const std::string &str, number_styles styles) -> xtd::int16
Convert a string into a type.
Definition parse.hpp:118
auto parse< xtd::uint16 >(const std::string &str, number_styles styles) -> xtd::uint16
Convert a string into a type.
Definition parse.hpp:127
auto parse< xtd::ulong >(const std::string &str, number_styles styles) -> xtd::ulong
Convert a string into a type.
Definition parse.hpp:181
@ 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.