40 #ifndef LIBDCP_LANGUAGE_TAG_H
41 #define LIBDCP_LANGUAGE_TAG_H
44 #include <boost/filesystem.hpp>
45 #include <boost/optional.hpp>
56 std::string to_string ()
const;
57 std::string description ()
const;
63 SubtagData (std::string subtag_, std::string description_)
65 , description(description_)
69 std::string description;
72 return subtag == other.subtag && description == other.description;
90 std::string subtag ()
const {
94 virtual SubtagType type ()
const = 0;
96 bool operator== (
Subtag const& other) {
97 return _subtag == other._subtag;
101 Subtag (std::string subtag, SubtagType type);
111 :
Subtag(subtag, SubtagType::LANGUAGE) {}
113 :
Subtag(subtag, SubtagType::LANGUAGE) {}
115 SubtagType type ()
const override {
116 return SubtagType::LANGUAGE;
124 :
Subtag(subtag, SubtagType::SCRIPT) {}
126 :
Subtag(subtag, SubtagType::SCRIPT) {}
128 SubtagType type ()
const override {
129 return SubtagType::SCRIPT;
137 :
Subtag(subtag, SubtagType::REGION) {}
139 :
Subtag(subtag, SubtagType::REGION) {}
141 SubtagType type ()
const override {
142 return SubtagType::REGION;
150 :
Subtag(subtag, SubtagType::VARIANT) {}
152 :
Subtag(subtag, SubtagType::VARIANT) {}
154 SubtagType type ()
const override {
155 return SubtagType::VARIANT;
167 :
Subtag(subtag, SubtagType::EXTLANG) {}
169 :
Subtag(subtag, SubtagType::EXTLANG) {}
171 SubtagType type ()
const override {
172 return SubtagType::EXTLANG;
182 boost::optional<LanguageSubtag> language()
const {
186 void set_language (LanguageSubtag language);
188 boost::optional<ScriptSubtag> script()
const {
192 void set_script (ScriptSubtag script);
194 boost::optional<RegionSubtag> region()
const {
198 void set_region (RegionSubtag region);
200 std::vector<VariantSubtag> variants()
const {
204 void set_variants (std::vector<VariantSubtag> variants);
205 void add_variant (VariantSubtag variant);
207 std::vector<ExtlangSubtag> extlangs()
const {
211 void set_extlangs (std::vector<ExtlangSubtag> extlangs);
212 void add_extlang (ExtlangSubtag extlang);
214 std::vector<std::pair<SubtagType, SubtagData>> subtags ()
const;
216 static std::vector<SubtagData>
const& get_all (SubtagType type);
217 static std::string subtag_type_name (SubtagType type);
219 static boost::optional<std::string> get_subtag_description (SubtagType, std::string subtag);
220 static boost::optional<SubtagData> get_subtag_data (SubtagType, std::string subtag);
223 static boost::optional<std::string> get_subtag_description (T s) {
224 return get_subtag_description (s.type(), s.subtag());
228 static boost::optional<SubtagData> get_subtag_data (T s) {
229 return get_subtag_data (s.type(), s.subtag());
234 boost::optional<LanguageSubtag> _language;
235 boost::optional<ScriptSubtag> _script;
236 boost::optional<RegionSubtag> _region;
237 std::vector<VariantSubtag> _variants;
238 std::vector<ExtlangSubtag> _extlangs;
245 extern std::ostream& operator<<(std::ostream& os,
dcp::LanguageTag const& tag);
248 extern void load_language_tag_lists (boost::filesystem::path tags_directory);
251 extern std::vector<std::pair<std::string, std::string>> dcnc_tags ();
Namespace for everything in libdcp.