Missing finalize() in dcpdecryptmxf.
[libdcp.git] / src / language_tag.h
index a419914c4449091eea5e2b47007e70381d01ee27..6b4bebe63c7d43c0fca67adce4e270aa8c29eff3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
     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
 
@@ -67,7 +73,7 @@ public:
                }
        };
 
-       enum SubtagType
+       enum class SubtagType
        {
                LANGUAGE,
                SCRIPT,
@@ -102,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;
+               SubtagType type () const override {
+                       return SubtagType::LANGUAGE;
                }
        };
 
@@ -115,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;
+               SubtagType type () const override {
+                       return SubtagType::SCRIPT;
                }
        };
 
@@ -128,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;
+               SubtagType type () const override {
+                       return SubtagType::REGION;
                }
        };
 
@@ -141,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;
+               SubtagType type () const override {
+                       return SubtagType::VARIANT;
                }
 
                bool operator== (VariantSubtag const& other) const;
@@ -158,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;
+               SubtagType type () const override {
+                       return SubtagType::EXTLANG;
                }
 
                bool operator== (ExtlangSubtag const& other) const;
@@ -171,7 +177,7 @@ public:
        };
 
        LanguageTag () {}
-       LanguageTag (std::string tag);
+       explicit LanguageTag (std::string tag);
 
        boost::optional<LanguageSubtag> language() const {
                return _language;
@@ -205,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> 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) {
@@ -232,12 +238,20 @@ private:
        std::vector<ExtlangSubtag> _extlangs;
 };
 
+
 extern bool operator==(dcp::LanguageTag const& a, dcp::LanguageTag const& b);
+extern bool operator!=(dcp::LanguageTag const& a, dcp::LanguageTag const& b);
+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);
 
+
+extern std::vector<std::pair<std::string, std::string>> dcnc_tags ();
+
+
 }
 
+
 #endif