Bump lib{cxml,dcp}.
[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 };
43
44 enum Language {
45         LANGUAGE_UNKNOWN,
46         LANGUAGE_ALBANIAN,
47         LANGUAGE_BRETON,
48         LANGUAGE_CATALAN,
49         LANGUAGE_CROATIAN,
50         LANGUAGE_WELSH,
51         LANGUAGE_CZECH,
52         LANGUAGE_DANISH,
53         LANGUAGE_GERMAN,
54         LANGUAGE_ENGLISH,
55         LANGUAGE_SPANISH,
56         LANGUAGE_ESPERANTO,
57         LANGUAGE_ESTONIAN,
58         LANGUAGE_BASQUE,
59         LANGUAGE_FAROESE,
60         LANGUAGE_FRENCH,
61         LANGUAGE_FRISIAN,
62         LANGUAGE_IRISH,
63         LANGUAGE_GAELIC,
64         LANGUAGE_GALACIAN,
65         LANGUAGE_ICELANDIC,
66         LANGUAGE_ITALIAN,
67         LANGUAGE_LAPPISH,
68         LANGUAGE_LATIN,
69         LANGUAGE_LATVIAN,
70         LANGUAGE_LUXEMBORGIAN,
71         LANGUAGE_LITHUANIAN,
72         LANGUAGE_HUNGARIAN,
73         LANGUAGE_MALTESE,
74         LANGUAGE_DUTCH,
75         LANGUAGE_NORWEGIAN,
76         LANGUAGE_OCCITAN,
77         LANGUAGE_POLISH,
78         LANGUAGE_PORTUGESE,
79         LANGUAGE_ROMANIAN,
80         LANGUAGE_ROMANSH,
81         LANGUAGE_SERBIAN,
82         LANGUAGE_SLOVAK,
83         LANGUAGE_SLOVENIAN,
84         LANGUAGE_FINNISH,
85         LANGUAGE_SWEDISH,
86         LANGUAGE_TURKISH,
87         LANGUAGE_FLEMISH,
88         LANGUAGE_WALLON,
89         LANGUAGE_AMHARIC,
90         LANGUAGE_ARABIC,
91         LANGUAGE_ARMENIAN,
92         LANGUAGE_ASSAMESE,
93         LANGUAGE_AZERBAIJANI,
94         LANGUAGE_BAMBORA,
95         LANGUAGE_BIELORUSSIAN,
96         LANGUAGE_BENGALI,
97         LANGUAGE_BULGARIAN,
98         LANGUAGE_BURMESE,
99         LANGUAGE_CHINESE,
100         LANGUAGE_CHURASH,
101         LANGUAGE_DARI,
102         LANGUAGE_FULANI,
103         LANGUAGE_GEORGIAN,
104         LANGUAGE_GREEK,
105         LANGUAGE_GUJURATI,
106         LANGUAGE_GURANI,
107         LANGUAGE_HAUSA,
108         LANGUAGE_HEBREW,
109         LANGUAGE_HINDI,
110         LANGUAGE_INDONESIAN,
111         LANGUAGE_JAPANESE,
112         LANGUAGE_KANNADA,
113         LANGUAGE_KAZAKH,
114         LANGUAGE_KHMER,
115         LANGUAGE_KOREAN,
116         LANGUAGE_LAOTIAN,
117         LANGUAGE_MACEDONIAN,
118         LANGUAGE_MALAGASAY,
119         LANGUAGE_MALAYSIAN,
120         LANGUAGE_MOLDAVIAN,
121         LANGUAGE_MARATHI,
122         LANGUAGE_NDEBELE,
123         LANGUAGE_NEPALI,
124         LANGUAGE_ORIYA,
125         LANGUAGE_PAPAMIENTO,
126         LANGUAGE_PERSIAN,
127         LANGUAGE_PUNJABI,
128         LANGUAGE_PUSHTU,
129         LANGUAGE_QUECHUA,
130         LANGUAGE_RUSSIAN,
131         LANGUAGE_RUTHENIAN,
132         LANGUAGE_SERBO_CROAT,
133         LANGUAGE_SHONA,
134         LANGUAGE_SINHALESE,
135         LANGUAGE_SOMALI,
136         LANGUAGE_SRANAN_TONGO,
137         LANGUAGE_SWAHILI,
138         LANGUAGE_TADZHIK,
139         LANGUAGE_TAMIL,
140         LANGUAGE_TATAR,
141         LANGUAGE_TELUGU,
142         LANGUAGE_THAI,
143         LANGUAGE_UKRANIAN,
144         LANGUAGE_URDU,
145         LANGUAGE_UZBEK,
146         LANGUAGE_VIETNAMESE,
147         LANGUAGE_ZULU
148 };
149
150 enum TimecodeStatus {
151         TIMECODE_STATUS_NOT_INTENDED_FOR_USE,
152         TIMECODE_STATUS_INTENDED_FOR_USE
153 };
154
155 enum CumulativeStatus {
156         CUMULATIVE_STATUS_NOT_CUMULATIVE,
157         CUMULATIVE_STATUS_FIRST,
158         CUMULATIVE_STATUS_INTERMEDIATE,
159         CUMULATIVE_STATUS_LAST
160 };
161
162 enum Justification {
163         JUSTIFICATION_NONE,
164         JUSTIFICATION_LEFT,
165         JUSTIFICATION_CENTRE,
166         JUSTIFICATION_RIGHT
167 };
168
169 enum Comment {
170         COMMENT_NO,
171         COMMENT_YES
172 };
173
174 /** @class STLBinaryCode
175  *  @brief A value of some STL parameter and a human-readable description of what it means.
176  */
177 template<class T>
178 class STLBinaryCode
179 {
180 public:
181         STLBinaryCode ()
182                 : value ((T) 0)
183         {}
184
185         STLBinaryCode (T v, std::string d)
186                 : value (v)
187                 , description (d)
188         {}
189
190         T value;
191         std::string description;
192 };
193
194 /** @class STLBinaryTables
195  *  @brief A set of conversion tables for STL binary files.
196  */
197 class STLBinaryTables
198 {
199 public:
200         STLBinaryTables ();
201
202         DisplayStandard display_standard_file_to_enum (std::string) const;
203         LanguageGroup language_group_file_to_enum (std::string) const;
204         Language language_file_to_enum (std::string) const;
205         TimecodeStatus timecode_status_file_to_enum (std::string) const;
206         CumulativeStatus cumulative_status_file_to_enum (int) const;
207         Justification justification_file_to_enum (int) const;
208         Comment comment_file_to_enum (int) const;
209
210         std::string language_enum_to_file (Language) const;
211         int cumulative_status_enum_to_file (CumulativeStatus) const;
212         int justification_enum_to_file (Justification) const;
213         int comment_enum_to_file (Comment) const;
214
215         std::string display_standard_enum_to_description (DisplayStandard) const;
216         std::string language_group_enum_to_description (LanguageGroup) const;
217         std::string language_enum_to_description (Language) const;
218         std::string timecode_status_enum_to_description (TimecodeStatus) const;
219         std::string cumulative_status_enum_to_description (CumulativeStatus) const;
220         std::string justification_enum_to_description (Justification) const;
221         std::string comment_enum_to_description (Comment) const;
222
223         boost::optional<Language> language_description_to_enum (std::string) const;
224
225 private:
226         std::map<std::string, STLBinaryCode<DisplayStandard> > _display_standard_map;
227         std::map<std::string, STLBinaryCode<LanguageGroup> > _language_group_map;
228         std::map<std::string, STLBinaryCode<Language> > _language_map;
229         std::map<std::string, STLBinaryCode<TimecodeStatus> > _timecode_status_map;
230         std::map<int, STLBinaryCode<CumulativeStatus> > _cumulative_status_map;
231         std::map<int, STLBinaryCode<Justification> > _justification_map;
232         std::map<int, STLBinaryCode<Comment> > _comment_map;
233 };
234
235 }
236
237 #endif