xtd 0.2.0
Loading...
Searching...
No Matches
box_integer.h
Go to the documentation of this file.
1
4#pragma once
5
7// Workaround : Like Windows.h (with NOMINMAX defined), some includes define max as a macro and this causes compilation errors.
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.")
11# else
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."
13# endif
14# undef max
15#endif
17
18#include "box.h"
19#include "number_styles.h"
20
22namespace xtd {
49 template<typename type_t>
50 class box_integer : public xtd::box<type_t> {
51 public:
53 box_integer() = default;
54 box_integer(const type_t& value) : xtd::box<type_t>(value) {}
55 box_integer(const box_integer&) = default;
56 box_integer(box_integer&&) = default;
57 box_integer& operator =(const box_integer&) = default;
59
61
65 static constexpr type_t max_value = std::numeric_limits<type_t>::max();
68 static constexpr type_t min_value = std::numeric_limits<type_t>::lowest();
70
72
74 using box<type_t>::parse;
78 static type_t parse(const xtd::ustring& value, xtd::number_styles styles) {return xtd::parse<type_t>(value, styles);}
79 using box<type_t>::try_parse;
83 static bool parse(const xtd::ustring& value, type_t& result, xtd::number_styles styles) {return xtd::try_parse<type_t>(value, result, styles);}
85 };
86}
Contains xtd::box class.
Represents a boxed integer object.
Definition box_integer.h:50
static constexpr type_t max_value
Represents the largest possible value of type_t. This field is constant.
Definition box_integer.h:65
static constexpr type_t min_value
Represents the smallest possible value of type_t. This field is constant.
Definition box_integer.h:68
static bool parse(const xtd::ustring &value, type_t &result, xtd::number_styles styles)
Converts the string to its type_t equivalent.
Definition box_integer.h:83
static type_t parse(const xtd::ustring &value, xtd::number_styles styles)
Converts the string to its type_t equivalent.
Definition box_integer.h:78
Represents a boxed object.
Definition box.h:47
const type_t & value() const noexcept
Gets the underlying value.
Definition box.h:79
static bool try_parse(const xtd::ustring &value, type_t &result) noexcept
Converts the string to its type_t equivalent. A return value indicates whether the conversion succeed...
Definition box.h:129
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
number_styles
Determines the styles permitted in numeric string arguments that are passed to the xtd::parse and xtd...
Definition number_styles.h:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::number_styles enum class.