• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef icu4x_GeneralCategory_D_HPP
2 #define icu4x_GeneralCategory_D_HPP
3 
4 #include <stdio.h>
5 #include <stdint.h>
6 #include <stddef.h>
7 #include <stdbool.h>
8 #include <memory>
9 #include <functional>
10 #include <optional>
11 #include "../diplomat_runtime.hpp"
12 
13 namespace icu4x {
14 struct GeneralCategoryGroup;
15 class GeneralCategory;
16 }
17 
18 
19 namespace icu4x {
20 namespace capi {
21     enum GeneralCategory {
22       GeneralCategory_Unassigned = 0,
23       GeneralCategory_UppercaseLetter = 1,
24       GeneralCategory_LowercaseLetter = 2,
25       GeneralCategory_TitlecaseLetter = 3,
26       GeneralCategory_ModifierLetter = 4,
27       GeneralCategory_OtherLetter = 5,
28       GeneralCategory_NonspacingMark = 6,
29       GeneralCategory_SpacingMark = 8,
30       GeneralCategory_EnclosingMark = 7,
31       GeneralCategory_DecimalNumber = 9,
32       GeneralCategory_LetterNumber = 10,
33       GeneralCategory_OtherNumber = 11,
34       GeneralCategory_SpaceSeparator = 12,
35       GeneralCategory_LineSeparator = 13,
36       GeneralCategory_ParagraphSeparator = 14,
37       GeneralCategory_Control = 15,
38       GeneralCategory_Format = 16,
39       GeneralCategory_PrivateUse = 17,
40       GeneralCategory_Surrogate = 18,
41       GeneralCategory_DashPunctuation = 19,
42       GeneralCategory_OpenPunctuation = 20,
43       GeneralCategory_ClosePunctuation = 21,
44       GeneralCategory_ConnectorPunctuation = 22,
45       GeneralCategory_InitialPunctuation = 28,
46       GeneralCategory_FinalPunctuation = 29,
47       GeneralCategory_OtherPunctuation = 23,
48       GeneralCategory_MathSymbol = 24,
49       GeneralCategory_CurrencySymbol = 25,
50       GeneralCategory_ModifierSymbol = 26,
51       GeneralCategory_OtherSymbol = 27,
52     };
53 
54     typedef struct GeneralCategory_option {union { GeneralCategory ok; }; bool is_ok; } GeneralCategory_option;
55 } // namespace capi
56 } // namespace
57 
58 namespace icu4x {
59 class GeneralCategory {
60 public:
61   enum Value {
62     Unassigned = 0,
63     UppercaseLetter = 1,
64     LowercaseLetter = 2,
65     TitlecaseLetter = 3,
66     ModifierLetter = 4,
67     OtherLetter = 5,
68     NonspacingMark = 6,
69     SpacingMark = 8,
70     EnclosingMark = 7,
71     DecimalNumber = 9,
72     LetterNumber = 10,
73     OtherNumber = 11,
74     SpaceSeparator = 12,
75     LineSeparator = 13,
76     ParagraphSeparator = 14,
77     Control = 15,
78     Format = 16,
79     PrivateUse = 17,
80     Surrogate = 18,
81     DashPunctuation = 19,
82     OpenPunctuation = 20,
83     ClosePunctuation = 21,
84     ConnectorPunctuation = 22,
85     InitialPunctuation = 28,
86     FinalPunctuation = 29,
87     OtherPunctuation = 23,
88     MathSymbol = 24,
89     CurrencySymbol = 25,
90     ModifierSymbol = 26,
91     OtherSymbol = 27,
92   };
93 
94   GeneralCategory() = default;
95   // Implicit conversions between enum and ::Value
GeneralCategory(Value v)96   constexpr GeneralCategory(Value v) : value(v) {}
operator Value() const97   constexpr operator Value() const { return value; }
98   // Prevent usage as boolean value
99   explicit operator bool() const = delete;
100 
101   inline static icu4x::GeneralCategory for_char(char32_t ch);
102 
103   inline std::optional<std::string_view> long_name();
104 
105   inline std::optional<std::string_view> short_name();
106 
107   inline uint8_t to_integer_value();
108 
109   inline icu4x::GeneralCategoryGroup to_group();
110 
111   inline static std::optional<icu4x::GeneralCategory> from_integer_value(uint8_t other);
112 
113   inline icu4x::capi::GeneralCategory AsFFI() const;
114   inline static icu4x::GeneralCategory FromFFI(icu4x::capi::GeneralCategory c_enum);
115 private:
116     Value value;
117 };
118 
119 } // namespace
120 #endif // icu4x_GeneralCategory_D_HPP
121