X-Git-Url: https://main.carlh.net/gitweb/?p=libdcp.git;a=blobdiff_plain;f=src%2Flanguage_tag.h;h=3b0b6ac9f19dd2601c66cc171b96e08bd9b782a6;hp=74b4a8a77023a774ed2cc31234388d8dd0715bb1;hb=ceaf7bc52712cb60708ed5eb5c62c5e463dd8e89;hpb=b933775fc54e0b51ad3777d72bf2866f0c04bacc diff --git a/src/language_tag.h b/src/language_tag.h index 74b4a8a7..3b0b6ac9 100644 --- a/src/language_tag.h +++ b/src/language_tag.h @@ -31,10 +31,17 @@ files in the program, then also delete it here. */ + +/** @file src/language_tag.cc + * @brief LanguageTag class + */ + + #ifndef LIBDCP_LANGUAGE_TAG_H #define LIBDCP_LANGUAGE_TAG_H +#include #include #include #include @@ -66,7 +73,7 @@ public: } }; - enum SubtagType + enum class SubtagType { LANGUAGE, SCRIPT, @@ -78,6 +85,8 @@ public: class Subtag { public: + virtual ~Subtag () {} + std::string subtag () const { return _subtag; } @@ -99,12 +108,12 @@ public: { public: LanguageSubtag (std::string subtag) - : Subtag(subtag, LANGUAGE) {} + : Subtag(subtag, SubtagType::LANGUAGE) {} LanguageSubtag (char const* subtag) - : Subtag(subtag, LANGUAGE) {} + : Subtag(subtag, SubtagType::LANGUAGE) {} SubtagType type () const { - return LANGUAGE; + return SubtagType::LANGUAGE; } }; @@ -112,12 +121,12 @@ public: { public: ScriptSubtag (std::string subtag) - : Subtag(subtag, SCRIPT) {} + : Subtag(subtag, SubtagType::SCRIPT) {} ScriptSubtag (char const* subtag) - : Subtag(subtag, SCRIPT) {} + : Subtag(subtag, SubtagType::SCRIPT) {} SubtagType type () const { - return SCRIPT; + return SubtagType::SCRIPT; } }; @@ -125,12 +134,12 @@ public: { public: RegionSubtag (std::string subtag) - : Subtag(subtag, REGION) {} + : Subtag(subtag, SubtagType::REGION) {} RegionSubtag (char const* subtag) - : Subtag(subtag, REGION) {} + : Subtag(subtag, SubtagType::REGION) {} SubtagType type () const { - return REGION; + return SubtagType::REGION; } }; @@ -138,12 +147,12 @@ public: { public: VariantSubtag (std::string subtag) - : Subtag(subtag, VARIANT) {} + : Subtag(subtag, SubtagType::VARIANT) {} VariantSubtag (char const* subtag) - : Subtag(subtag, VARIANT) {} + : Subtag(subtag, SubtagType::VARIANT) {} SubtagType type () const { - return VARIANT; + return SubtagType::VARIANT; } bool operator== (VariantSubtag const& other) const; @@ -155,12 +164,12 @@ public: { public: ExtlangSubtag (std::string subtag) - : Subtag(subtag, EXTLANG) {} + : Subtag(subtag, SubtagType::EXTLANG) {} ExtlangSubtag (char const* subtag) - : Subtag(subtag, EXTLANG) {} + : Subtag(subtag, SubtagType::EXTLANG) {} SubtagType type () const { - return EXTLANG; + return SubtagType::EXTLANG; } bool operator== (ExtlangSubtag const& other) const; @@ -168,9 +177,9 @@ public: }; LanguageTag () {} - LanguageTag (std::string tag); + explicit LanguageTag (std::string tag); - boost::optional language() { + boost::optional language() const { return _language; } @@ -202,13 +211,13 @@ public: void set_extlangs (std::vector extlangs); void add_extlang (ExtlangSubtag extlang); - std::vector > subtags () const; + std::vector> subtags () const; - static std::vector get_all (SubtagType type); + static std::vector const& get_all (SubtagType type); static std::string subtag_type_name (SubtagType type); static boost::optional get_subtag_description (SubtagType, std::string subtag); - static boost::optional get_subtag_data (SubtagType, std::string subtag); + static boost::optional get_subtag_data (SubtagType, std::string subtag); template static boost::optional get_subtag_description (T s) { @@ -229,9 +238,14 @@ private: std::vector _extlangs; }; + extern bool operator==(dcp::LanguageTag const& a, dcp::LanguageTag const& b); extern std::ostream& operator<<(std::ostream& os, dcp::LanguageTag const& tag); + +extern void load_language_tag_lists (boost::filesystem::path tags_directory); + + } #endif