|
Soprano
2.7.2
|
A LanguageTag represents a language according to RFC 3066 and RFC 4646. More...
#include <Soprano/LanguageTag>
Public Types | |
| enum | MatchFilter { MatchFilterBasic = 0, MatchFilterExtended = 1 } |
| enum | LookupFlag { LookupFlagNone = 0, LookupFlagNoFallback = 1 } |
Public Member Functions | |
Constructors | |
| LanguageTag () | |
| LanguageTag (const LanguageTag &other) | |
| LanguageTag (const char *tag) | |
| LanguageTag (const QLatin1String &tag) | |
| LanguageTag (const QString &tag) | |
| LanguageTag (const QLocale &locale) | |
| LanguageTag (QLocale::Language lang, QLocale::Country country=QLocale::AnyCountry) | |
| ~LanguageTag () | |
Operators | |
| LanguageTag & | operator= (const LanguageTag &other) |
| bool | operator== (const LanguageTag &other) const |
| bool | operator!= (const LanguageTag &other) const |
| bool | operator< (const LanguageTag &other) const |
| bool | operator<= (const LanguageTag &other) const |
| bool | operator> (const LanguageTag &other) const |
| bool | operator>= (const LanguageTag &other) const |
| bool | matches (const LanguageTag &range, MatchFilter scheme=MatchFilterBasic) const |
Information | |
| bool | isEmpty () const |
| bool | isValid () const |
| QStringList | subTags () const |
Conversion | |
| QString | toString () const |
| QString | toPrettyString () const |
| QLocale | toLocale () const |
| operator QString () const | |
Static Public Member Functions | |
| static int | lookup (const QList< LanguageTag > &choices, const QList< LanguageTag > &priority, LookupFlags flags=LookupFlagNone, MatchFilter scheme=MatchFilterBasic) |
| static int | lookup (const QList< LanguageTag > &choices, const LanguageTag &priority, LookupFlags flags=LookupFlagNone, MatchFilter scheme=MatchFilterBasic) |
A LanguageTag represents a language according to RFC 3066 and RFC 4646.
Definition at line 47 of file languagetag.h.
Flags for performing LanguageTag lookups.
Definition at line 70 of file languagetag.h.
| Soprano::LanguageTag::LanguageTag | ( | ) |
Default constructor. Creates an empty language tag.
| Soprano::LanguageTag::LanguageTag | ( | const LanguageTag & | other | ) |
Copy constructor.
| other | The language tag from which to copy |
| Soprano::LanguageTag::LanguageTag | ( | const char * | tag | ) |
Creates a language tag.
| tag | The language tag string |
| Soprano::LanguageTag::LanguageTag | ( | const QLatin1String & | tag | ) |
Creates a language tag.
| tag | The language tag string |
| Soprano::LanguageTag::LanguageTag | ( | const QString & | tag | ) |
Creates a language tag.
| tag | The language tag string |
| Soprano::LanguageTag::LanguageTag | ( | const QLocale & | locale | ) | [explicit] |
Creates a language tag from a QLocale. If the language is QLocale::C, then an empty LanguageTag is produced.
| locale | the locale |
| Soprano::LanguageTag::LanguageTag | ( | QLocale::Language | lang, |
| QLocale::Country | country = QLocale::AnyCountry |
||
| ) |
Creates a language tag from a language and country. If lang is QLocale::C, then an empty LanguageTag is produced.
| lang | the language code |
| country | the country code |
| Soprano::LanguageTag::~LanguageTag | ( | ) |
Destructor.
| LanguageTag& Soprano::LanguageTag::operator= | ( | const LanguageTag & | other | ) |
Assigns other to this tag.
| bool Soprano::LanguageTag::operator== | ( | const LanguageTag & | other | ) | const |
Comparison operator. Language tag comparisons are case-insensitive.
true if this tag and other are equal. | bool Soprano::LanguageTag::operator!= | ( | const LanguageTag & | other | ) | const |
Comparison operator. Language tag comparisons are case-insensitive.
true if this tag and other differ. | bool Soprano::LanguageTag::operator< | ( | const LanguageTag & | other | ) | const |
Comparison operator.
true if this tag is lexically less than other. | bool Soprano::LanguageTag::operator<= | ( | const LanguageTag & | other | ) | const |
Comparison operator.
true if this tag is lexically less than or equal to other. | bool Soprano::LanguageTag::operator> | ( | const LanguageTag & | other | ) | const |
Comparison operator.
true if this tag is lexically greater than other. | bool Soprano::LanguageTag::operator>= | ( | const LanguageTag & | other | ) | const |
Comparison operator.
true if this tag is lexically greater than or equal to other. | bool Soprano::LanguageTag::matches | ( | const LanguageTag & | range, |
| MatchFilter | scheme = MatchFilterBasic |
||
| ) | const |
Match this language tag against range using the specified filtering scheme.
| range | the range against which to match |
| scheme | the filtering scheme to use |
true if this tag matches pattern, false if not. | bool Soprano::LanguageTag::isEmpty | ( | ) | const |
true if this language tag is empty. | bool Soprano::LanguageTag::isValid | ( | ) | const |
Determines if this language tag is valid. A valid language tag is divided into subtags that are divided by "-". The tag must adhere the following rules:
true if this language tag is valid | QStringList Soprano::LanguageTag::subTags | ( | ) | const |
| QString Soprano::LanguageTag::toString | ( | ) | const |
Converts this LanguageTag to a string.
| QString Soprano::LanguageTag::toPrettyString | ( | ) | const |
Converts this LanguageTag to a string formatted according to the case rules in RFC 4647 section 4.4 (page 44).
| QLocale Soprano::LanguageTag::toLocale | ( | ) | const |
Converts this LanguageTag to a locale, using the primary language tag and first two-letter language subtag, if any. If the conversion could not be performed, then the "C" QLocale is returned.
| Soprano::LanguageTag::operator QString | ( | ) | const [inline] |
A convenience operator to convert this LanguageTag to a string.
Definition at line 277 of file languagetag.h.
| static int Soprano::LanguageTag::lookup | ( | const QList< LanguageTag > & | choices, |
| const QList< LanguageTag > & | priority, | ||
| LookupFlags | flags = LookupFlagNone, |
||
| MatchFilter | scheme = MatchFilterBasic |
||
| ) | [static] |
Compares a language tag against a list of language tags and selects the most suitable tag according to the rules of RFC 4647 Section 3.4.
The arguments consist of choices, a list of tags from which to select, and priority, a list of acceptable language ranges. Both lists must be sorted in descending order of preference.
The matching algorithm works as follows:
| choices | the list of available language choices |
| priority | the language priority list |
| flags | flags for the lookup operation |
| scheme | the matching scheme to use. RFC 4647 specifies that basic (MatchFilterBasic) processing should be used. |
| static int Soprano::LanguageTag::lookup | ( | const QList< LanguageTag > & | choices, |
| const LanguageTag & | priority, | ||
| LookupFlags | flags = LookupFlagNone, |
||
| MatchFilter | scheme = MatchFilterBasic |
||
| ) | [static] |
A convenience method to select a language tag based on a single search pattern.
| choices | the list of available language choices |
| priority | the language range against which to match |
| flags | flags for the lookup operation |
| scheme | the matching scheme to use. RFC 4647 specifies that basic (MatchFilterBasic) processing should be used. |
1.7.5