Tidying.
[libdcp.git] / src / language_tag.h
index 74b4a8a77023a774ed2cc31234388d8dd0715bb1..3b0b6ac9f19dd2601c66cc171b96e08bd9b782a6 100644 (file)
     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 <boost/filesystem.hpp>
 #include <boost/optional.hpp>
 #include <string>
 #include <vector>
@@ -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<LanguageSubtag> language() {
+       boost::optional<LanguageSubtag> language() const {
                return _language;
        }
 
@@ -202,13 +211,13 @@ public:
        void set_extlangs (std::vector<ExtlangSubtag> extlangs);
        void add_extlang (ExtlangSubtag extlang);
 
-       std::vector<std::pair<SubtagType, SubtagData> > subtags () const;
+       std::vector<std::pair<SubtagType, SubtagData>> subtags () const;
 
-       static std::vector<SubtagData> get_all (SubtagType type);
+       static std::vector<SubtagData> const& get_all (SubtagType type);
        static std::string subtag_type_name (SubtagType type);
 
        static boost::optional<std::string> get_subtag_description (SubtagType, std::string subtag);
-       static boost::optional<SubtagData > get_subtag_data (SubtagType, std::string subtag);
+       static boost::optional<SubtagData> get_subtag_data (SubtagType, std::string subtag);
 
        template <class T>
        static boost::optional<std::string> get_subtag_description (T s) {
@@ -229,9 +238,14 @@ private:
        std::vector<ExtlangSubtag> _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