Bump libdcp.
[libsub.git] / src / stl_binary_tables.h
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBSUB_STL_BINARY_TABLES_H
21 #define LIBSUB_STL_BINARY_TABLES_H
22
23 #include <string>
24 #include <map>
25 #include <boost/optional.hpp>
26
27 namespace sub {
28
29 enum DisplayStandard {
30         DISPLAY_STANDARD_UNDEFINED,
31         DISPLAY_STANDARD_OPEN_SUBTITLING,
32         DISPLAY_STANDARD_LEVEL_1_TELETEXT,
33         DISPLAY_STANDARD_LEVEL_2_TELETEXT
34 };
35
36 enum LanguageGroup {
37         LANGUAGE_GROUP_LATIN,
38         LANGUAGE_GROUP_LATIN_CYRILLIC,
39         LANGUAGE_GROUP_LATIN_ARABIC,
40         LANGUAGE_GROUP_LATIN_GREEK,
41         LANGUAGE_GROUP_LATIN_HEBREW,
42         LANGUAGE_GROUP_UTF8,
43 };
44
45 enum Language {
46         LANGUAGE_UNKNOWN,
47         LANGUAGE_ALBANIAN,
48         LANGUAGE_BRETON,
49         LANGUAGE_CATALAN,
50         LANGUAGE_CROATIAN,
51         LANGUAGE_WELSH,
52         LANGUAGE_CZECH,
53         LANGUAGE_DANISH,
54         LANGUAGE_GERMAN,
55         LANGUAGE_ENGLISH,
56         LANGUAGE_SPANISH,
57         LANGUAGE_ESPERANTO,
58         LANGUAGE_ESTONIAN,
59         LANGUAGE_BASQUE,
60         LANGUAGE_FAROESE,
61         LANGUAGE_FRENCH,
62         LANGUAGE_FRISIAN,
63         LANGUAGE_IRISH,
64         LANGUAGE_GAELIC,
65         LANGUAGE_GALACIAN,
66         LANGUAGE_ICELANDIC,
67         LANGUAGE_ITALIAN,
68         LANGUAGE_LAPPISH,
69         LANGUAGE_LATIN,
70         LANGUAGE_LATVIAN,
71         LANGUAGE_LUXEMBORGIAN,
72         LANGUAGE_LITHUANIAN,
73         LANGUAGE_HUNGARIAN,
74         LANGUAGE_MALTESE,
75         LANGUAGE_DUTCH,
76         LANGUAGE_NORWEGIAN,
77         LANGUAGE_OCCITAN,
78         LANGUAGE_POLISH,
79         LANGUAGE_PORTUGESE,
80         LANGUAGE_ROMANIAN,
81         LANGUAGE_ROMANSH,
82         LANGUAGE_SERBIAN,
83         LANGUAGE_SLOVAK,
84         LANGUAGE_SLOVENIAN,
85         LANGUAGE_FINNISH,
86         LANGUAGE_SWEDISH,
87         LANGUAGE_TURKISH,
88         LANGUAGE_FLEMISH,
89         LANGUAGE_WALLON,
90         LANGUAGE_AMHARIC,
91         LANGUAGE_ARABIC,
92         LANGUAGE_ARMENIAN,
93         LANGUAGE_ASSAMESE,
94         LANGUAGE_AZERBAIJANI,
95         LANGUAGE_BAMBORA,
96         LANGUAGE_BIELORUSSIAN,
97         LANGUAGE_BENGALI,
98         LANGUAGE_BULGARIAN,
99         LANGUAGE_BURMESE,
100         LANGUAGE_CHINESE,
101         LANGUAGE_CHURASH,
102         LANGUAGE_DARI,
103         LANGUAGE_FULANI,
104         LANGUAGE_GEORGIAN,
105         LANGUAGE_GREEK,
106         LANGUAGE_GUJURATI,
107         LANGUAGE_GURANI,
108         LANGUAGE_HAUSA,
109         LANGUAGE_HEBREW,
110         LANGUAGE_HINDI,
111         LANGUAGE_INDONESIAN,
112         LANGUAGE_JAPANESE,
113         LANGUAGE_KANNADA,
114         LANGUAGE_KAZAKH,
115         LANGUAGE_KHMER,
116         LANGUAGE_KOREAN,
117         LANGUAGE_LAOTIAN,
118         LANGUAGE_MACEDONIAN,
119         LANGUAGE_MALAGASAY,
120         LANGUAGE_MALAYSIAN,
121         LANGUAGE_MOLDAVIAN,
122         LANGUAGE_MARATHI,
123         LANGUAGE_NDEBELE,
124         LANGUAGE_NEPALI,
125         LANGUAGE_ORIYA,
126         LANGUAGE_PAPAMIENTO,
127         LANGUAGE_PERSIAN,
128         LANGUAGE_PUNJABI,
129         LANGUAGE_PUSHTU,
130         LANGUAGE_QUECHUA,
131         LANGUAGE_RUSSIAN,
132         LANGUAGE_RUTHENIAN,
133         LANGUAGE_SERBO_CROAT,
134         LANGUAGE_SHONA,
135         LANGUAGE_SINHALESE,
136         LANGUAGE_SOMALI,
137         LANGUAGE_SRANAN_TONGO,
138         LANGUAGE_SWAHILI,
139         LANGUAGE_TADZHIK,
140         LANGUAGE_TAMIL,
141         LANGUAGE_TATAR,
142         LANGUAGE_TELUGU,
143         LANGUAGE_THAI,
144         LANGUAGE_UKRANIAN,
145         LANGUAGE_URDU,
146         LANGUAGE_UZBEK,
147         LANGUAGE_VIETNAMESE,
148         LANGUAGE_ZULU
149 };
150
151 enum TimecodeStatus {
152         TIMECODE_STATUS_NOT_INTENDED_FOR_USE,
153         TIMECODE_STATUS_INTENDED_FOR_USE
154 };
155
156 enum CumulativeStatus {
157         CUMULATIVE_STATUS_NOT_CUMULATIVE,
158         CUMULATIVE_STATUS_FIRST,
159         CUMULATIVE_STATUS_INTERMEDIATE,
160         CUMULATIVE_STATUS_LAST
161 };
162
163 enum Justification {
164         JUSTIFICATION_NONE,
165         JUSTIFICATION_LEFT,
166         JUSTIFICATION_CENTRE,
167         JUSTIFICATION_RIGHT
168 };
169
170 enum Comment {
171         COMMENT_NO,
172         COMMENT_YES
173 };
174
175 /** @class STLBinaryCode
176  *  @brief A value of some STL parameter and a human-readable description of what it means.
177  */
178 template<class T>
179 class STLBinaryCode
180 {
181 public:
182         STLBinaryCode ()
183                 : value ((T) 0)
184         {}
185
186         STLBinaryCode (T v, std::string d)
187                 : value (v)
188                 , description (d)
189         {}
190
191         T value;
192         std::string description;
193 };
194
195 /** @class STLBinaryTables
196  *  @brief A set of conversion tables for STL binary files.
197  */
198 class STLBinaryTables
199 {
200 public:
201         STLBinaryTables ();
202
203         DisplayStandard display_standard_file_to_enum (std::string) const;
204         LanguageGroup language_group_file_to_enum (std::string) const;
205         Language language_file_to_enum (std::string) const;
206         TimecodeStatus timecode_status_file_to_enum (std::string) const;
207         CumulativeStatus cumulative_status_file_to_enum (int) const;
208         Justification justification_file_to_enum (int) const;
209         Comment comment_file_to_enum (int) const;
210
211         std::string language_enum_to_file (Language) const;
212         int cumulative_status_enum_to_file (CumulativeStatus) const;
213         int justification_enum_to_file (Justification) const;
214         int comment_enum_to_file (Comment) const;
215
216         std::string display_standard_enum_to_description (DisplayStandard) const;
217         std::string language_group_enum_to_description (LanguageGroup) const;
218         std::string language_enum_to_description (Language) const;
219         std::string timecode_status_enum_to_description (TimecodeStatus) const;
220         std::string cumulative_status_enum_to_description (CumulativeStatus) const;
221         std::string justification_enum_to_description (Justification) const;
222         std::string comment_enum_to_description (Comment) const;
223
224         boost::optional<Language> language_description_to_enum (std::string) const;
225
226 private:
227         std::map<std::string, STLBinaryCode<DisplayStandard> > _display_standard_map;
228         std::map<std::string, STLBinaryCode<LanguageGroup> > _language_group_map;
229         std::map<std::string, STLBinaryCode<Language> > _language_map;
230         std::map<std::string, STLBinaryCode<TimecodeStatus> > _timecode_status_map;
231         std::map<int, STLBinaryCode<CumulativeStatus> > _cumulative_status_map;
232         std::map<int, STLBinaryCode<Justification> > _justification_map;
233         std::map<int, STLBinaryCode<Comment> > _comment_map;
234 };
235
236 }
237
238 #endif