7#include "../enum_metadata.hpp"
10namespace hi::inline v1 {
12enum class text_phrasing {
29constexpr auto text_phrasing_metadata = enum_metadata{
30 text_phrasing::regular,
"regular",
31 text_phrasing::emphesis,
"emphesis",
32 text_phrasing::strong,
"strong",
33 text_phrasing::code,
"code",
34 text_phrasing::abbreviation,
"abbreviation",
35 text_phrasing::bold,
"bold",
36 text_phrasing::italic,
"italic",
37 text_phrasing::citation,
"citation",
38 text_phrasing::keyboard,
"keyboard",
39 text_phrasing::mark,
"mark",
40 text_phrasing::math,
"math",
41 text_phrasing::example,
"example",
42 text_phrasing::unarticulated,
"unarticulated",
46enum class text_phrasing_mask : uint16_t {
48 regular = 1 << to_underlying(text_phrasing::regular),
49 emphesis = 1 << to_underlying(text_phrasing::emphesis),
50 strong = 1 << to_underlying(text_phrasing::strong),
51 code = 1 << to_underlying(text_phrasing::code),
52 abbreviation = 1 << to_underlying(text_phrasing::abbreviation),
53 bold = 1 << to_underlying(text_phrasing::bold),
54 italic = 1 << to_underlying(text_phrasing::italic),
55 citation = 1 << to_underlying(text_phrasing::citation),
56 keyboard = 1 << to_underlying(text_phrasing::keyboard),
57 mark = 1 << to_underlying(text_phrasing::highlight),
58 math = 1 << to_underlying(text_phrasing::math),
59 example = 1 << to_underlying(text_phrasing::example),
60 unarticulated = 1 << to_underlying(text_phrasing::unarticulated),
62 all = regular | emphesis | strong | code | abbreviation | bold | italic | citation | keyboard | highlight | math | example |
66[[nodiscard]]
constexpr text_phrasing_mask operator&(text_phrasing_mask
const& lhs, text_phrasing_mask
const& rhs)
noexcept
68 return static_cast<text_phrasing_mask
>(to_underlying(lhs) & to_underlying(rhs));
71[[nodiscard]]
constexpr text_phrasing_mask
operator|(text_phrasing_mask
const& lhs, text_phrasing_mask
const& rhs)
noexcept
73 return static_cast<text_phrasing_mask
>(to_underlying(lhs) | to_underlying(rhs));
76constexpr text_phrasing_mask &operator|=(text_phrasing_mask &lhs, text_phrasing_mask
const& rhs)
noexcept
78 return lhs = lhs | rhs;
81constexpr text_phrasing_mask &operator&=(text_phrasing_mask &lhs, text_phrasing_mask
const& rhs)
noexcept
83 return lhs = lhs & rhs;
86[[nodiscard]]
constexpr text_phrasing_mask to_text_phrasing_mask(text_phrasing
const& rhs)
noexcept
88 hi_axiom(to_underlying(rhs) <
sizeof(text_phrasing_mask) * CHAR_BIT);
89 return static_cast<text_phrasing_mask
>(1 << to_underlying(rhs));
92[[nodiscard]]
constexpr text_phrasing_mask to_text_phrasing_mask(
char const &rhs)
noexcept
96 case 'r':
return text_phrasing_mask::regular;
97 case 'e':
return text_phrasing_mask::emphesis;
98 case 's':
return text_phrasing_mask::strong;
99 case 'c':
return text_phrasing_mask::code;
100 case 'a':
return text_phrasing_mask::abbreviation;
101 case 'b':
return text_phrasing_mask::bold;
102 case 'i':
return text_phrasing_mask::italic;
103 case 'c':
return text_phrasing_mask::citation;
104 case 'k':
return text_phrasing_mask::keyboard;
105 case 'h':
return text_phrasing_mask::highlight;
106 case 'm':
return text_phrasing_mask::mark;
107 case 'x':
return text_phrasing_mask::example;
108 case 'u':
return text_phrasing_mask::unarticulated;
109 default: hi_no_default();
114[[nodiscard]]
constexpr text_phrasing_mask to_text_phrasing_mask(std::string_view rhs)
noexcept
116 auto r = text_phrasing_mask::none;
118 r |= to_text_phrasing_mask(c);
129 if (to_bool(rhs & text_phrasing_mask::regular)) { r +=
'r'; }
130 if (to_bool(rhs & text_phrasing_mask::emphesis)) { r +=
'e'; }
131 if (to_bool(rhs & text_phrasing_mask::strong)) { r +=
's'; }
132 if (to_bool(rhs & text_phrasing_mask::code)) { r +=
'c'; }
133 if (to_bool(rhs & text_phrasing_mask::abbreviation)) { r +=
'a'; }
134 if (to_bool(rhs & text_phrasing_mask::bold)) { r +=
'b'; }
135 if (to_bool(rhs & text_phrasing_mask::italic)) { r +=
'i'; }
136 if (to_bool(rhs & text_phrasing_mask::citation)) { r +=
'q'; }
137 if (to_bool(rhs & text_phrasing_mask::keyboard)) { r +=
'k'; }
138 if (to_bool(rhs & text_phrasing_mask::highlight)) { r +=
'h'; }
139 if (to_bool(rhs & text_phrasing_mask::math)) { r +=
'm'; }
140 if (to_bool(rhs & text_phrasing_mask::example)) { r +=
'x'; }
141 if (to_bool(rhs & text_phrasing_mask::unarticulated)) { r +=
'u'; }
147[[nodiscard]]
constexpr bool all(text_phrasing_mask
const& rhs)
noexcept
149 return (rhs & text_phrasing_mask::all) == text_phrasing_mask::all;
152[[nodiscard]]
constexpr bool to_bool(text_phrasing_mask
const& rhs)
noexcept
154 return to_bool(to_underlying(rhs));
This file includes required definitions.
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23
constexpr alignment operator|(horizontal_alignment lhs, vertical_alignment rhs) noexcept
Combine vertical and horizontal alignment.
Definition alignment.hpp:200