AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AChar.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14
19class AChar {
20private:
21 char32_t mValue;
22
23public:
24 AChar(char c): mValue(c) {}
25
26 [[nodiscard]]
27 bool digit() const {
28 return mValue >= '0' && mValue <= '9';
29 }
30
31 [[nodiscard]]
32 bool alpha() const {
33 return (mValue >= 'a' && mValue <= 'z') || (mValue >= 'A' && mValue <= 'Z');
34 }
35
36 [[nodiscard]]
37 bool alnum() const {
38 return alpha() || digit();
39 }
40
41 [[nodiscard]]
42 char asAscii() const {
43 return char(mValue);
44 }
45
46 operator char32_t() const {
47 return mValue;
48 }
49};
50
51static_assert(sizeof(AChar) == 4, "AChar should be exact 4 bytes");
52
53
Represents a single 32-bit char.
Definition: AChar.h:19