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;
71 bool operator== (
SubtagData const& other)
const {
72 return subtag == other.subtag && description == other.description;
75 bool operator!=(
SubtagData const& other)
const {
76 return subtag != other.subtag || description != other.description;
94 std::string subtag ()
const {
98 virtual SubtagType type ()
const = 0;
100 bool operator== (
Subtag const& other)
const {
101 return _subtag == other._subtag;
104 bool operator!=(
Subtag const& other)
const {
105 return _subtag != other._subtag;
108 bool operator<(
Subtag const& other)
const {
109 return _subtag < other._subtag;
113 Subtag (std::string subtag, SubtagType type);
123 :
Subtag(subtag, SubtagType::LANGUAGE) {}
125 :
Subtag(subtag, SubtagType::LANGUAGE) {}
127 SubtagType type ()
const override {
128 return SubtagType::LANGUAGE;
136 :
Subtag(subtag, SubtagType::SCRIPT) {}
138 :
Subtag(subtag, SubtagType::SCRIPT) {}
140 SubtagType type ()
const override {
141 return SubtagType::SCRIPT;
149 :
Subtag(subtag, SubtagType::REGION) {}
151 :
Subtag(subtag, SubtagType::REGION) {}
153 SubtagType type ()
const override {
154 return SubtagType::REGION;
162 :
Subtag(subtag, SubtagType::VARIANT) {}
164 :
Subtag(subtag, SubtagType::VARIANT) {}
166 SubtagType type ()
const override {
167 return SubtagType::VARIANT;
176 :
Subtag(subtag, SubtagType::EXTLANG) {}
178 :
Subtag(subtag, SubtagType::EXTLANG) {}
180 SubtagType type ()
const override {
181 return SubtagType::EXTLANG;
188 boost::optional<LanguageSubtag> language()
const {
192 void set_language (LanguageSubtag language);
194 boost::optional<ScriptSubtag> script()
const {
198 void set_script (ScriptSubtag script);
200 boost::optional<RegionSubtag> region()
const {
204 void set_region (RegionSubtag region);
206 std::vector<VariantSubtag> variants()
const {
210 void set_variants (std::vector<VariantSubtag> variants);
211 void add_variant (VariantSubtag variant);
213 std::vector<ExtlangSubtag> extlangs()
const {
217 void set_extlangs (std::vector<ExtlangSubtag> extlangs);
218 void add_extlang (ExtlangSubtag extlang);
220 std::vector<std::pair<SubtagType, SubtagData>> subtags ()
const;
222 static std::vector<SubtagData>
const& get_all (SubtagType type);
223 static std::string subtag_type_name (SubtagType type);
225 static boost::optional<std::string> get_subtag_description (SubtagType, std::string subtag);
226 static boost::optional<SubtagData> get_subtag_data (SubtagType, std::string subtag);
229 static boost::optional<std::string> get_subtag_description (T s) {
230 return get_subtag_description (s.type(), s.subtag());
234 static boost::optional<SubtagData> get_subtag_data (T s) {
235 return get_subtag_data (s.type(), s.subtag());
240 boost::optional<LanguageSubtag> _language;
241 boost::optional<ScriptSubtag> _script;
242 boost::optional<RegionSubtag> _region;
243 std::vector<VariantSubtag> _variants;
244 std::vector<ExtlangSubtag> _extlangs;
251 extern std::ostream& operator<<(std::ostream& os,
dcp::LanguageTag const& tag);
254 extern void load_language_tag_lists (boost::filesystem::path tags_directory);
257 extern std::vector<std::pair<std::string, std::string>> dcnc_tags ();
Namespace for everything in libdcp.