summaryrefslogtreecommitdiff
path: root/src/stl_binary_tables.h
blob: 4a6a7d86d6afa5ee236c7a0f51c7640ff58d9ee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef LIBSUB_STL_BINARY_TABLES_H
#define LIBSUB_STL_BINARY_TABLES_H

#include <string>
#include <map>
#include <boost/optional.hpp>

namespace sub {

enum DisplayStandard {
	DISPLAY_STANDARD_UNDEFINED,
	DISPLAY_STANDARD_OPEN_SUBTITLING,
	DISPLAY_STANDARD_LEVEL_1_TELETEXT,
	DISPLAY_STANDARD_LEVEL_2_TELETEXT
};

enum LanguageGroup {
	LANGUAGE_GROUP_LATIN,
	LANGUAGE_GROUP_LATIN_CYRILLIC,
	LANGUAGE_GROUP_LATIN_ARABIC,
	LANGUAGE_GROUP_LATIN_GREEK,
	LANGUAGE_GROUP_LATIN_HEBREW
};

enum Language {
	LANGUAGE_UNKNOWN,
	LANGUAGE_ALBANIAN,
	LANGUAGE_BRETON,
	LANGUAGE_CATALAN,
	LANGUAGE_CROATIAN,
	LANGUAGE_WELSH,
	LANGUAGE_CZECH,
	LANGUAGE_DANISH,
	LANGUAGE_GERMAN,
	LANGUAGE_ENGLISH,
	LANGUAGE_SPANISH,
	LANGUAGE_ESPERANTO,
	LANGUAGE_ESTONIAN,
	LANGUAGE_BASQUE,
	LANGUAGE_FAROESE,
	LANGUAGE_FRENCH,
	LANGUAGE_FRISIAN,
	LANGUAGE_IRISH,
	LANGUAGE_GAELIC,
	LANGUAGE_GALACIAN,
	LANGUAGE_ICELANDIC,
	LANGUAGE_ITALIAN,
	LANGUAGE_LAPPISH,
	LANGUAGE_LATIN,
	LANGUAGE_LATVIAN,
	LANGUAGE_LUXEMBORGIAN,
	LANGUAGE_LITHUANIAN,
	LANGUAGE_HUNGARIAN,
	LANGUAGE_MALTESE,
	LANGUAGE_DUTCH,
	LANGUAGE_NORWEGIAN,
	LANGUAGE_OCCITAN,
	LANGUAGE_POLISH,
	LANGUAGE_PORTUGESE,
	LANGUAGE_ROMANIAN,
	LANGUAGE_ROMANSH,
	LANGUAGE_SERBIAN,
	LANGUAGE_SLOVAK,
	LANGUAGE_SLOVENIAN,
	LANGUAGE_FINNISH,
	LANGUAGE_SWEDISH,
	LANGUAGE_TURKISH,
	LANGUAGE_FLEMISH,
	LANGUAGE_WALLON,
	LANGUAGE_AMHARIC,
	LANGUAGE_ARABIC,
	LANGUAGE_ARMENIAN,
	LANGUAGE_ASSAMESE,
	LANGUAGE_AZERBAIJANI,
	LANGUAGE_BAMBORA,
	LANGUAGE_BIELORUSSIAN,
	LANGUAGE_BENGALI,
	LANGUAGE_BULGARIAN,
	LANGUAGE_BURMESE,
	LANGUAGE_CHINESE,
	LANGUAGE_CHURASH,
	LANGUAGE_DARI,
	LANGUAGE_FULANI,
	LANGUAGE_GEORGIAN,
	LANGUAGE_GREEK,
	LANGUAGE_GUJURATI,
	LANGUAGE_GURANI,
	LANGUAGE_HAUSA,
	LANGUAGE_HEBREW,
	LANGUAGE_HINDI,
	LANGUAGE_INDONESIAN,
	LANGUAGE_JAPANESE,
	LANGUAGE_KANNADA,
	LANGUAGE_KAZAKH,
	LANGUAGE_KHMER,
	LANGUAGE_KOREAN,
	LANGUAGE_LAOTIAN,
	LANGUAGE_MACEDONIAN,
	LANGUAGE_MALAGASAY,
	LANGUAGE_MALAYSIAN,
	LANGUAGE_MOLDAVIAN,
	LANGUAGE_MARATHI,
	LANGUAGE_NDEBELE,
	LANGUAGE_NEPALI,
	LANGUAGE_ORIYA,
	LANGUAGE_PAPAMIENTO,
	LANGUAGE_PERSIAN,
	LANGUAGE_PUNJABI,
	LANGUAGE_PUSHTU,
	LANGUAGE_QUECHUA,
	LANGUAGE_RUSSIAN,
	LANGUAGE_RUTHENIAN,
	LANGUAGE_SERBO_CROAT,
	LANGUAGE_SHONA,
	LANGUAGE_SINHALESE,
	LANGUAGE_SOMALI,
	LANGUAGE_SRANAN_TONGO,
	LANGUAGE_SWAHILI,
	LANGUAGE_TADZHIK,
	LANGUAGE_TAMIL,
	LANGUAGE_TATAR,
	LANGUAGE_TELUGU,
	LANGUAGE_THAI,
	LANGUAGE_UKRANIAN,
	LANGUAGE_URDU,
	LANGUAGE_UZBEK,
	LANGUAGE_VIETNAMESE,
	LANGUAGE_ZULU
};

enum TimecodeStatus {
	TIMECODE_STATUS_NOT_INTENDED_FOR_USE,
	TIMECODE_STATUS_INTENDED_FOR_USE
};

enum CumulativeStatus {
	CUMULATIVE_STATUS_NOT_CUMULATIVE,
	CUMULATIVE_STATUS_FIRST,
	CUMULATIVE_STATUS_INTERMEDIATE,
	CUMULATIVE_STATUS_LAST
};

enum Justification {
	JUSTIFICATION_NONE,
	JUSTIFICATION_LEFT,
	JUSTIFICATION_CENTRE,
	JUSTIFICATION_RIGHT
};

enum Comment {
	COMMENT_NO,
	COMMENT_YES
};

/** @class STLBinaryCode
 *  @brief A value of some STL parameter and a human-readable description of what it means.
 */
template<class T>
class STLBinaryCode
{
public:
	STLBinaryCode ()
		: value ((T) 0)
	{}

	STLBinaryCode (T v, std::string d)
		: value (v)
		, description (d)
	{}

	T value;
	std::string description;
};

/** @class STLBinaryTables
 *  @brief A set of conversion tables for STL binary files.
 */
class STLBinaryTables
{
public:
	STLBinaryTables ();

	DisplayStandard display_standard_file_to_enum (std::string) const;
	LanguageGroup language_group_file_to_enum (std::string) const;
	Language language_file_to_enum (std::string) const;
	TimecodeStatus timecode_status_file_to_enum (std::string) const;
	CumulativeStatus cumulative_status_file_to_enum (int) const;
	Justification justification_file_to_enum (int) const;
	Comment comment_file_to_enum (int) const;

	std::string language_enum_to_file (Language) const;
	int cumulative_status_enum_to_file (CumulativeStatus) const;
	int justification_enum_to_file (Justification) const;
	int comment_enum_to_file (Comment) const;

	std::string display_standard_enum_to_description (DisplayStandard) const;
	std::string language_group_enum_to_description (LanguageGroup) const;
	std::string language_enum_to_description (Language) const;
	std::string timecode_status_enum_to_description (TimecodeStatus) const;
	std::string cumulative_status_enum_to_description (CumulativeStatus) const;
	std::string justification_enum_to_description (Justification) const;
	std::string comment_enum_to_description (Comment) const;

	boost::optional<Language> language_description_to_enum (std::string) const;

private:
	std::map<std::string, STLBinaryCode<DisplayStandard> > _display_standard_map;
	std::map<std::string, STLBinaryCode<LanguageGroup> > _language_group_map;
	std::map<std::string, STLBinaryCode<Language> > _language_map;
	std::map<std::string, STLBinaryCode<TimecodeStatus> > _timecode_status_map;
	std::map<int, STLBinaryCode<CumulativeStatus> > _cumulative_status_map;
	std::map<int, STLBinaryCode<Justification> > _justification_map;
	std::map<int, STLBinaryCode<Comment> > _comment_map;
};

}

#endif