HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Friends
v1::language_tag Class Reference

#include <hikogui/i18n/language_tag.hpp>

Public Member Functions

constexpr language_tag (language_tag const &) noexcept=default
 
constexpr language_tag (language_tag &&) noexcept=default
 
constexpr language_tagoperator= (language_tag const &) noexcept=default
 
constexpr language_tagoperator= (language_tag &&) noexcept=default
 
constexpr language_tag (iso_639 const &language, iso_15924 const &script={}, iso_3166 const &region={}) noexcept
 
constexpr language_tag (iso_639 const &language, iso_3166 const &region) noexcept
 
 language_tag (std::string_view str)
 Parse a language tag.
 
bool empty () const noexcept
 Check if the language tag is empty.
 
 operator bool () const noexcept
 Check if the language tag is used.
 
generator< language_tagvariants () const noexcept
 Get variants of the language_tag.
 
generator< language_tagcanonical_variants () const noexcept
 Get variants of the language_tag.
 
std::vector< language_tagall_variants () const noexcept
 Creates variants of a language tag, including those by expanding the normal variants.
 
language_tag expand () const noexcept
 Expand the language tag to include script and language.
 
language_tag shrink () const noexcept
 Get a tag with only the language.
 
unicode_bidi_class writing_direction () const noexcept
 The language direction for this language-tag.
 
std::string to_string () const noexcept
 

Static Public Member Functions

static language_tag parse (std::string_view str)
 Parse the language, script and region raw from the string.
 

Data Fields

iso_639 language
 
iso_15924 script
 
iso_3166 region
 
uint16_t _reserved = 0
 

Friends

constexpr friend bool match (language_tag const &lhs, language_tag const &rhs) noexcept
 Check if two language_tags match for their non-empty fields.
 
constexpr friend bool operator== (language_tag const &, language_tag const &) noexcept=default
 

Detailed Description

The IETF BCP 47 language tag.

This class stores the language tag in 64 bits; in its individual components of the: ISO-639 language (16 bit), ISO-15924 script (16 bit) and ISO-3166 region (16 bit). In the future another 16 bits can be used to store the variants and extensions.

Constructor & Destructor Documentation

◆ language_tag()

v1::language_tag::language_tag ( std::string_view str)

Parse a language tag.

This will construct a language tag with the language, script and region set as complete as possible. It does this by expanding the language tags using default script, region and grandfathering tables.

This function will ignore upper/lower case of the sub-tags, and allow for both underscores '_' and dashes '-' to separate the sub-tags.

Parameters
strThe language tag to parse
Exceptions
parse_error

Member Function Documentation

◆ all_variants()

std::vector< language_tag > v1::language_tag::all_variants ( ) const
inlinenoexcept

Creates variants of a language tag, including those by expanding the normal variants.

◆ canonical_variants()

generator< language_tag > v1::language_tag::canonical_variants ( ) const
inlinenoexcept

Get variants of the language_tag.

This function will create language_tags that may include this tag and tags with strictly less information (no script, no region), which still canonically expands into this tag.

Returns
A list of language-tags sorted: lang-script-region, lang-region, lang-script, lang

◆ empty()

bool v1::language_tag::empty ( ) const
inlinenoexcept

Check if the language tag is empty.

◆ expand()

language_tag v1::language_tag::expand ( ) const
noexcept

Expand the language tag to include script and language.

Expansion is done by querying default script, default language and grandfathering tables.

◆ operator bool()

v1::language_tag::operator bool ( ) const
inlineexplicitnoexcept

Check if the language tag is used.

◆ parse()

static language_tag v1::language_tag::parse ( std::string_view str)
static

Parse the language, script and region raw from the string.

No automatic expansion of the script or region will be done.

◆ shrink()

language_tag v1::language_tag::shrink ( ) const
inlinenoexcept

Get a tag with only the language.

◆ variants()

generator< language_tag > v1::language_tag::variants ( ) const
inlinenoexcept

Get variants of the language_tag.

This function will create language_tags that includes this tag and tags with strictly less information (no script, no region).

Returns
A list of language-tags sorted: lang-script-region, lang-region, lang-script, lang

◆ writing_direction()

unicode_bidi_class v1::language_tag::writing_direction ( ) const
inlinenoexcept

The language direction for this language-tag.

Returns
Either unicode_bidi_class::L for left-to-right; or unicode_bidi_class::R for right-to-left

Friends And Related Symbol Documentation

◆ match

constexpr friend bool match ( language_tag const & lhs,
language_tag const & rhs )
friend

Check if two language_tags match for their non-empty fields.


The documentation for this class was generated from the following file: