xtd 0.2.0
Loading...
Searching...
No Matches
box_char.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "box.hpp"
6#include "char32.hpp"
7#include "character.hpp"
8
10namespace xtd {
39 template<typename type_t>
40 requires xtd::character<type_t>
41 class box_char : public xtd::box<type_t> {
42 public:
44 box_char() = default;
45 box_char(const type_t& value) : box<type_t>(value) {}
46 box_char(const box_char&) = default;
47 box_char(box_char&&) = default;
48 box_char& operator =(const box_char&) = default;
50
52
56 static constexpr type_t max_value = std::numeric_limits<type_t>::max();
59 static constexpr type_t min_value = std::numeric_limits<type_t>::lowest();
61
63
68 [[nodiscard]] static auto is_ascii(type_t c) noexcept -> bool {return c > 0 && c <= 0x7F;}
74 [[nodiscard]] static auto is_ascii(const string& s, size_t index) -> bool {return is_ascii(s[index]);}
75
79 [[nodiscard]] static auto is_control(type_t c) noexcept -> bool {return std::iscntrl(static_cast<int>(c)) != 0;}
85 [[nodiscard]] static auto is_control(const string& s, size_t index) -> bool {return is_control(s[index]);}
86
91 [[nodiscard]] static auto is_digit(type_t c) noexcept -> bool {return std::isdigit(static_cast<int>(c)) != 0;}
97 [[nodiscard]] static auto is_digit(const string& s, size_t index) -> bool {return is_digit(s[index]);}
98
102 [[nodiscard]] static auto is_letter(type_t c) noexcept -> bool {return std::isalpha(static_cast<int>(c)) != 0;}
108 [[nodiscard]] static auto is_letter(const string& s, size_t index) -> bool {return is_letter(s[index]);}
109
113 [[nodiscard]] static auto is_letter_or_digit(type_t c) noexcept -> bool {return std::isalnum(static_cast<int>(c)) != 0;}
119 [[nodiscard]] static auto is_letter_or_digit(const string& s, size_t index) -> bool {return is_letter_or_digit(s[index]);}
120
124 [[nodiscard]] static auto is_lower(type_t c) noexcept -> bool {return std::islower(static_cast<int>(c)) != 0;}
130 [[nodiscard]] static auto is_lower(const string& s, size_t index) -> bool {return is_lower(s[index]);}
131
135 [[nodiscard]] static auto is_number(type_t c) noexcept -> bool {return std::isdigit(static_cast<int>(c)) != 0;}
141 [[nodiscard]] static auto is_number(const string& s, size_t index) -> bool {return is_number(s[index]);}
142
146 [[nodiscard]] static auto is_punctuation(type_t c) noexcept -> bool {return std::ispunct(static_cast<int>(c)) != 0;}
152 [[nodiscard]] static auto is_punctuation(const string& s, size_t index) -> bool {return is_punctuation(s[index]);}
153
157 [[nodiscard]] static auto is_separator(type_t c) noexcept -> bool {return std::isspace(static_cast<int>(c)) != 0 || c == '\n';}
163 [[nodiscard]] static auto is_separator(const string& s, size_t index) -> bool {return is_separator(s[index]);}
164
168 [[nodiscard]] static auto is_symbol(type_t c) noexcept -> bool {return std::isgraph(static_cast<int>(c)) != 0 || c == 0x9C;}
174 [[nodiscard]] static auto is_symbol(const string& s, size_t index) -> bool {return is_symbol(s[index]);}
175
179 [[nodiscard]] static auto is_upper(type_t c) noexcept -> bool {return std::isupper(static_cast<int>(c)) != 0;}
185 [[nodiscard]] static auto is_upper(const string& s, size_t index) -> bool {return is_upper(s[index]);}
186
191 [[nodiscard]] static auto is_valid(type_t value) noexcept -> bool {return value >= static_cast<xtd::char32>(min_value) && value <= static_cast<xtd::char32>(max_value);}
192
196 [[nodiscard]] static auto is_white_space(type_t c) noexcept -> bool {return std::isspace(static_cast<int>(c)) != 0;}
202 [[nodiscard]] static auto is_white_space(const string& s, size_t index) -> bool {return is_white_space(s[index]);}
203
204 using box<type_t>::parse;
208 static type_t parse(const xtd::string& value, xtd::number_styles styles) {return xtd::parse<type_t>(value, styles);}
209
213 [[nodiscard]] static auto to_lower(type_t c) noexcept -> type_t {return static_cast<type_t>(std::tolower(static_cast<int>(c)));}
214
218 [[nodiscard]] static auto to_upper(type_t c) noexcept -> type_t {return static_cast<type_t>(std::toupper(static_cast<int>(c)));}
219
220 using box<type_t>::try_parse;
224 static bool try_parse(const xtd::string& value, type_t& result, xtd::number_styles styles) {return xtd::try_parse<type_t>(value, result, styles);}
226 };
227}
Contains xtd::box struct.
Contains xtd::char32 type.
Contains xtd::character concept.
Represents a boxed char object.
Definition box_char.hpp:41
static auto is_letter(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as a Unicode letter.
Definition box_char.hpp:102
static auto is_ascii(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is an ASCII character...
Definition box_char.hpp:74
static auto to_upper(type_t c) noexcept -> type_t
Converts the value of a Unicode character to its uppercase equivalent.
Definition box_char.hpp:218
static auto is_punctuation(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as a punctuation mark.
Definition box_char.hpp:146
static auto is_number(type_t c) noexcept -> bool
Indicates whether a Unicode character is categorized as a number.
Definition box_char.hpp:135
static type_t parse(const xtd::string &value, xtd::number_styles styles)
Converts the string to its type_t equivalent.
Definition box_char.hpp:208
static auto is_control(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as a control character.
Definition box_char.hpp:79
static auto is_punctuation(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a p...
Definition box_char.hpp:152
static auto is_ascii(type_t c) noexcept -> bool
Returns true if c is an ASCII character ([ U+0000..U+007F ]).
Definition box_char.hpp:68
static auto is_number(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a n...
Definition box_char.hpp:141
static auto is_upper(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as an uppercase letter.
Definition box_char.hpp:179
static auto to_lower(type_t c) noexcept -> type_t
Converts the value of a Unicode character to its lowercase equivalent.
Definition box_char.hpp:213
static auto is_separator(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a s...
Definition box_char.hpp:163
static constexpr char16 min_value
Definition box_char.hpp:59
static auto is_valid(type_t value) noexcept -> bool
Determines whether the specified value can be safely converted to type_t without overflow.
Definition box_char.hpp:191
static auto is_separator(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as a separator character.
Definition box_char.hpp:157
static constexpr char16 max_value
Definition box_char.hpp:56
static auto is_lower(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a l...
Definition box_char.hpp:130
static auto is_letter_or_digit(type_t c) noexcept -> bool
Indicates whether a Unicode character is categorized as a letter or a decimal digit.
Definition box_char.hpp:113
static auto is_symbol(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a s...
Definition box_char.hpp:174
static auto is_digit(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as a decimal digit.
Definition box_char.hpp:91
static auto is_white_space(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as white space.
Definition box_char.hpp:196
static auto is_letter_or_digit(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a l...
Definition box_char.hpp:119
static auto is_upper(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as an ...
Definition box_char.hpp:185
static auto is_digit(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a d...
Definition box_char.hpp:97
static auto is_lower(type_t c) noexcept -> bool
ndicates whether the specified Unicode character is categorized as a lowercase letter.
Definition box_char.hpp:124
static auto is_symbol(type_t c) noexcept -> bool
Indicates whether the specified Unicode character is categorized as a symbol character.
Definition box_char.hpp:168
static auto is_white_space(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as whi...
Definition box_char.hpp:202
static auto is_control(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a c...
Definition box_char.hpp:85
static auto is_letter(const string &s, size_t index) -> bool
Indicates whether the character at the specified position in a specified string is categorized as a U...
Definition box_char.hpp:108
static bool try_parse(const xtd::string &value, type_t &result, xtd::number_styles styles)
Converts the string to its type_t equivalent.
Definition box_char.hpp:224
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:23
number_styles
Determines the styles permitted in numeric string arguments that are passed to the xtd::parse and xtd...
Definition number_styles.hpp:16
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
@ s
The S key.
Definition console_key.hpp:124
@ 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
Represents a boxed object.
Definition box.hpp:56
box()=default
Initialize a new xtd::box object.
value_type value
Gets or sets the underlying value.
Definition box.hpp:106