xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
4#pragma once
5#include <cstdint>
6#include <string>
7#include <typeinfo>
8#include "core_export.h"
9
11#if !defined(__cpp_lib_char8_t)
12class char8_t {
13public:
14 char8_t() {}
15 char8_t(char value) : value_(value) {}
16 char8_t(const char8_t&) = default;
17 char8_t(char8_t&&) = default;
18
19 operator char() const {return value_;}
20 bool operator==(char8_t c) const {return value_ == c.value_;}
21 bool operator!=(char8_t c) const {return value_ != c.value_;}
22 bool operator<(char8_t c) const {return value_ < c.value_;}
23 bool operator>(char8_t c) const {return value_ > c.value_;}
24 bool operator<=(char8_t c) const {return value_ <= c.value_;}
25 bool operator>=(char8_t c) const {return value_ >= c.value_;}
26
27 char8_t operator+(char8_t c) const {return char8_t(value_ + c.value_);}
28 char8_t operator-(char8_t c) const {return char8_t(value_ - c.value_);}
29 char8_t& operator=(char8_t c) {value_ = c.value_; return *this;}
30 char8_t& operator++() {value_ += 1; return *this;}
31 char8_t operator++(int) {char8_t result(*this); ++(*this); return result;}
32 char8_t& operator--() {value_ -= 1; return *this;}
33 char8_t operator--(int) {char8_t result(*this); --(*this); return result;}
34
35 bool operator==(char c) const {return value_ == c;}
36 bool operator!=(char c) const {return value_ != c;}
37 bool operator<(char c) const {return value_ < c;}
38 bool operator>(char c) const {return value_ > c;}
39 bool operator<=(char c) const {return value_ <= c;}
40 bool operator>=(char c) const {return value_ >= c;}
41
42 friend std::ostream& operator <<(std::ostream& os, const char8_t& c) noexcept {return os << std::to_string(static_cast<int32_t>(c.value_));}
43
44private:
45 char value_ = 0;
46};
47
48namespace std {
49 using u8string=basic_string<char8_t>;
50}
51#endif
53
55namespace xtd {
57 using byte_t = uint8_t;
58 using char_t = char;
59 using decimal_t = long double;
60 using sbyte_t = int8_t;
61 using single_t = float;
62 using uchar_t = unsigned char;
63 using ushort_t = unsigned short;
64 using ulong_t = unsigned long;
65
66#if defined(__linux__) && defined(_LP64)
67 using llong_t = long long int;
68 using ullong_t = unsigned long long int;
69#else
70 using llong_t = long;
71 using ullong_t = unsigned long;
72#endif
74
81 using byte = uint8_t;
82
89 using char8 = char8_t;
90
97 using char16 = char16_t;
98
105 using char32 = char32_t;
106
113 using decimal = decimal_t;
114
121 using int16 = int16_t;
122
129 using int32 = int32_t;
130
137 using int64 = int64_t;
138
141 using intptr = intptr_t;
142
155 extern core_export_ std::nullptr_t null;
156
163 using sbyte = int8_t;
164
171 using size = size_t;
172
179 using type = std::type_info;
180
187 using uchar = unsigned char;
188
195 using uint = unsigned int;
196
203 using uint16 = uint16_t;
204
211 using uint32 = uint32_t;
212
219 using uint64 = uint64_t;
220
227 using uintptr = uintptr_t;
228
235 using ushort = ushort_t;
236
243 using ulong = ulong_t;
244
251 using wchar = wchar_t;
252}
253
254/*
256namespace __ {
259 namespace system = xtd;
260}
261using namespace __;
262*/
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.h:13
int16_t int16
Represents a 16-bit signed integer.
Definition types.h:121
char8_t char8
Represents a 16-bit unicode character.
Definition types.h:89
wchar_t wchar
Represents a wide character.
Definition types.h:251
decimal_t decimal
Represents a decimal-precision floating-point number.
Definition types.h:113
int32_t int32
Represents a 32-bit signed integer.
Definition types.h:129
unsigned char uchar
Represents a 8-bit unsigned integer.
Definition types.h:187
int64_t int64
Represents a 64-bit signed integer.
Definition types.h:137
int8_t sbyte
Represents a 8-bit signed integer.
Definition types.h:163
char16_t char16
Represents a 8-bit unicode character.
Definition types.h:97
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition types.h:211
uintptr_t uintptr
Represent a pointer or a handle.
Definition types.h:227
std::nullptr_t null
Represents a null pointer value.
unsigned int uint
Represents a 32-bit unsigned integer.
Definition types.h:195
size_t size
Represents a size of any object in bytes.
Definition types.h:171
char32_t char32
Represents a 32-bit unicode character.
Definition types.h:105
intptr_t intptr
Represent a pointer or a handle.
Definition types.h:141
ushort_t ushort
Represents a 16-bit unsigned integer.
Definition types.h:235
ulong_t ulong
Represents a 32-bit or 64-bit unsigned integer.
Definition types.h:243
uint64_t uint64
Represents a 64-bit unsigned integer.
Definition types.h:219
uint8_t byte
Represents a 8-bit unsigned integer.
Definition types.h:81
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition types.h:203
std::type_info type
Stores information about a type.
Definition types.h:179
@ c
The C key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17