7#include "iso_15924.hpp"
11#include "../generator.hpp"
12#include "../ranges.hpp"
16namespace hi::inline
v1 {
30 uint16_t _reserved = 0;
67 [[nodiscard]]
bool empty() const noexcept
69 return language.empty() and script.empty() and region.empty();
74 explicit operator bool() const noexcept
89 if (script and region) {
93 if (script or region) {
108 hilet check = expand();
110 if (tag.expand() == check) {
124 for (
hilet expanded_variant : variant.expand().variants()) {
125 if (
std::find(r.begin(), r.end(), expanded_variant) == r.end()) {
126 r.push_back(expanded_variant);
143 auto last_variant = *
this;
144 for (
hilet& variant : canonical_variants()) {
145 last_variant = variant;
156 return expand().script.writing_direction();
159 [[nodiscard]]
std::string to_string() const noexcept
162 r += language.
code();
178 if (lhs.language != rhs.language) {
181 if (lhs.script and rhs.script and lhs.script != rhs.script) {
184 if (lhs.region and rhs.region and lhs.region != rhs.region) {
207 [[nodiscard]]
size_t operator()(hi::language_tag
const& rhs)
const noexcept
216template<
typename CharT>
217struct std::formatter<
hi::language_tag, CharT> : std::formatter<std::string_view, CharT> {
218 auto format(hi::language_tag
const& t,
auto& fc)
220 return std::formatter<std::string_view, CharT>::format(t.to_string(), fc);
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
constexpr std::vector< Value > make_vector(Range &&range)
Make a vector from a view.
Definition ranges.hpp:43
std::vector< language_tag > variants(std::vector< language_tag > languages)
Add variants to the list of languages.
unicode_bidi_class
Bidirectional class Unicode Standard Annex #9: https://unicode.org/reports/tr9/.
Definition unicode_bidi_class.hpp:17
The HikoGUI namespace.
Definition ascii.hpp:19
A return value for a generator-function.
Definition generator.hpp:28
ISO-15924 script code.
Definition iso_15924.hpp:19
std::string_view code4() const noexcept
Get the iso-15924 4-letter code.
ISO-3166 country code.
Definition iso_3166.hpp:16
ISO-639 language code.
Definition iso_639.hpp:25
constexpr std::string code() const noexcept
Get the 2 or 3 letter ISO-639 code.
Definition iso_639.hpp:140
Definition language.hpp:17
The IETF BCP 47 language tag.
Definition language_tag.hpp:25
unicode_bidi_class writing_direction() const noexcept
The language direction for this language-tag.
Definition language_tag.hpp:154
bool empty() const noexcept
Check if the language tag is empty.
Definition language_tag.hpp:67
language_tag(std::string_view str)
Parse a language tag.
language_tag expand() const noexcept
Expand the language tag to include script and language.
generator< language_tag > canonical_variants() const noexcept
Get variants of the language_tag.
Definition language_tag.hpp:106
generator< language_tag > variants() const noexcept
Get variants of the language_tag.
Definition language_tag.hpp:86
std::vector< language_tag > all_variants() const noexcept
Creates variants of a language tag, including those by expanding the normal variants.
Definition language_tag.hpp:118
static language_tag parse(std::string_view str)
Parse the language, script and region raw from the string.
constexpr friend bool match(language_tag const &lhs, language_tag const &rhs) noexcept
Check if two language_tags match for their non-empty fields.
Definition language_tag.hpp:176