Tag Parser 12.1.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TagParser::Locale Struct Reference

The Locale struct specifies a language and/or a country using one or more LocaleDetail objects. More...

#include <localehelper.h>

Inheritance diagram for TagParser::Locale:
[legend]
Collaboration diagram for TagParser::Locale:
[legend]

Public Member Functions

 Locale ()=default
 
 Locale (std::initializer_list< LocaleDetail > details)
 Constructs a new locale with the specified details.
 
 Locale (std::string &&value, LocaleFormat format)
 Constructs a new locale with the specified value and format.
 
 Locale (std::string_view value, LocaleFormat format)
 Constructs a new locale with the specified value and format.
 
const LocaleDetailabbreviatedName (LocaleFormat format) const
 Returns the abbreviated name of the specified format.
 
template<typename LocaleFormat , typename... LocaleFormats>
const LocaleDetailabbreviatedName (LocaleFormat format, LocaleFormats... moreFormats) const
 Returns the abbreviated name of the specified format; if not present, checks moreFormats.
 
const LocaleDetailsomeAbbreviatedName (LocaleFormat preferredFormat=LocaleFormat::BCP_47) const
 Returns some abbreviated name, preferably of the specified preferredFormat.
 
const std::string & fullName () const
 Returns the full name of the locale, e.g.
 
const std::string & fullOrSomeAbbreviatedName () const
 Returns the full name if possible and otherwise falls back to the abbreviated name.
 
std::string toString () const
 Returns all details as comma-separated string.
 

Detailed Description

The Locale struct specifies a language and/or a country using one or more LocaleDetail objects.

Definition at line 61 of file localehelper.h.

Constructor & Destructor Documentation

◆ Locale() [1/4]

TagParser::Locale::Locale ( )
explicitdefault

◆ Locale() [2/4]

TagParser::Locale::Locale ( std::initializer_list< LocaleDetail details)
inlineexplicit

Constructs a new locale with the specified details.

Definition at line 91 of file localehelper.h.

◆ Locale() [3/4]

TagParser::Locale::Locale ( std::string &&  value,
LocaleFormat  format 
)
inlineexplicit

Constructs a new locale with the specified value and format.

Definition at line 99 of file localehelper.h.

◆ Locale() [4/4]

TagParser::Locale::Locale ( std::string_view  value,
LocaleFormat  format 
)
inlineexplicit

Constructs a new locale with the specified value and format.

Definition at line 108 of file localehelper.h.

Member Function Documentation

◆ abbreviatedName() [1/2]

const LocaleDetail & TagParser::Locale::abbreviatedName ( LocaleFormat  format) const

Returns the abbreviated name of the specified format.

This function returns the format if present. Otherwise it returns an empty string. This might be improved in the future, e.g. to convert to the specified format. It would also be possible to combine multiple details. For instance, if BCP-47 is required but only an ISO language and a domain name country are present, both could be combined and returned as BCP-47 abbreviation.

Definition at line 62 of file localehelper.cpp.

◆ abbreviatedName() [2/2]

template<typename LocaleFormat , typename... LocaleFormats>
const LocaleDetail & TagParser::Locale::abbreviatedName ( LocaleFormat  format,
LocaleFormats...  moreFormats 
) const
inline

Returns the abbreviated name of the specified format; if not present, checks moreFormats.

Definition at line 79 of file localehelper.h.

◆ fullName()

const std::string & TagParser::Locale::fullName ( ) const

Returns the full name of the locale, e.g.

Germany for the ISO code "ger" or an empty string if the full name is not known.

Remarks
So far the full name is only known for ISO-639-2/B codes.

Definition at line 110 of file localehelper.cpp.

◆ fullOrSomeAbbreviatedName()

const std::string & TagParser::Locale::fullOrSomeAbbreviatedName ( ) const

Returns the full name if possible and otherwise falls back to the abbreviated name.

Remarks
This function is intended to be used for display purposes.

Definition at line 124 of file localehelper.cpp.

◆ someAbbreviatedName()

const LocaleDetail & TagParser::Locale::someAbbreviatedName ( LocaleFormat  preferredFormat = LocaleFormat::BCP_47) const

Returns some abbreviated name, preferably of the specified preferredFormat.

This function returns the preferredFormat if present. Otherwise it returns the most relevant detail. This might be improved in the future, e.g. to convert to the preferredFormat. It would also be possible to combine multiple details. For instance, if BCP-47 is preferred but only an ISO language and a domain name country are present, both could be combined and returned as BCP-47 abbreviation.

Returns an empty string if no details are present.

Remarks
This function is intended to be used for display purposes when the exact format doesn't matter and you just want to show the "best" abbreviation specified within the file.

Definition at line 85 of file localehelper.cpp.

◆ toString()

std::string TagParser::Locale::toString ( ) const

Returns all details as comma-separated string.

Definition at line 135 of file localehelper.cpp.


The documentation for this struct was generated from the following files: