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

#include <hikogui/i18n/language_tag_intf.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.
 
iso_15924 default_script () const noexcept
 Get the default-script for this language.
 
bool left_to_right () const noexcept
 The language direction for this language-tag.
 

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 std::string to_string (language_tag const &rhs) noexcept
 
constexpr friend bool matches (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()

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

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 > hi::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 > hi::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

◆ default_script()

iso_15924 hi::v1::language_tag::default_script ( ) const
inlinenoexcept

Get the default-script for this language.

This will expand the language-tag if necessary to get the script.

◆ empty()

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

Check if the language tag is empty.

◆ expand()

language_tag hi::v1::language_tag::expand ( ) const
inlinenoexcept

Expand the language tag to include script and language.

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

◆ left_to_right()

bool hi::v1::language_tag::left_to_right ( ) const
inlinenoexcept

The language direction for this language-tag.

Returns
true if left-to-right language

◆ operator bool()

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

Check if the language tag is used.

◆ parse()

language_tag hi::v1::language_tag::parse ( std::string_view str)
inlinestatic

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

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

◆ shrink()

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

Get a tag with only the language.

◆ variants()

generator< language_tag > hi::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

Friends And Related Symbol Documentation

◆ matches

constexpr friend bool matches ( 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 files: