#include "stl_binary_tables.h"
#include "exceptions.h"
+#include "sub_assert.h"
#include "compose.hpp"
-#include <cassert>
using std::map;
using std::string;
m[k] = STLBinaryCode<E> (v, d);
}
-
template <class E, class F>
E
file_to_enum (F k, map<F, STLBinaryCode<E> > m, string name)
}
}
- assert (false);
+ SUB_ASSERT (false);
return F ();
}
return "";
}
-
+
+template <class E, class F>
+boost::optional<E>
+description_to_enum (string d, map<F, STLBinaryCode<E> > const & m)
+{
+ for (typename map<F, STLBinaryCode<E> >::const_iterator i = m.begin(); i != m.end(); ++i) {
+ if (i->second.description == d) {
+ return i->second.value;
+ }
+ }
+
+ return boost::optional<E> ();
+}
+
DisplayStandard
STLBinaryTables::display_standard_file_to_enum (string s) const
{
{
return enum_to_file (v, _comment_map);
}
-
+
string
STLBinaryTables::display_standard_enum_to_description (DisplayStandard v) const
{
return enum_to_description (v, _display_standard_map);
}
-
+
string
STLBinaryTables::language_group_enum_to_description (LanguageGroup v) const
{
return enum_to_description (v, _comment_map);
}
+boost::optional<Language>
+STLBinaryTables::language_description_to_enum (string d) const
+{
+ return description_to_enum (d, _language_map);
+}
+
STLBinaryTables::STLBinaryTables ()
{
code<DisplayStandard, string> (_display_standard_map, " ", DISPLAY_STANDARD_UNDEFINED, "Undefined");
code<DisplayStandard, string> (_display_standard_map, "0", DISPLAY_STANDARD_OPEN_SUBTITLING, "Open subtitling");
code<DisplayStandard, string> (_display_standard_map, "1", DISPLAY_STANDARD_LEVEL_1_TELETEXT, "Level 1 teletext");
code<DisplayStandard, string> (_display_standard_map, "2", DISPLAY_STANDARD_LEVEL_2_TELETEXT, "Level 2 teletext");
-
+
code<LanguageGroup, string> (_language_group_map, "00", LANGUAGE_GROUP_LATIN, "Latin");
code<LanguageGroup, string> (_language_group_map, "01", LANGUAGE_GROUP_LATIN_CYRILLIC, "Latin/Cyrillic");
code<LanguageGroup, string> (_language_group_map, "02", LANGUAGE_GROUP_LATIN_ARABIC, "Latin/Arabic");
code<LanguageGroup, string> (_language_group_map, "03", LANGUAGE_GROUP_LATIN_GREEK, "Latin/Greek");
code<LanguageGroup, string> (_language_group_map, "04", LANGUAGE_GROUP_LATIN_HEBREW, "Latin/Hebrew");
-
+ code<LanguageGroup, string> (_language_group_map, "U8", LANGUAGE_GROUP_LATIN_HEBREW, "UTF-8");
+
code<Language, string> (_language_map, "00", LANGUAGE_UNKNOWN, "Unknown");
code<Language, string> (_language_map, "01", LANGUAGE_ALBANIAN, "Albanian");
code<Language, string> (_language_map, "02", LANGUAGE_BRETON, "Breton");
code<Justification, int> (_justification_map, 0, JUSTIFICATION_NONE, "No justification");
code<Justification, int> (_justification_map, 1, JUSTIFICATION_LEFT, "Left justification");
code<Justification, int> (_justification_map, 2, JUSTIFICATION_CENTRE, "Centre justification");
- code<Justification, int> (_justification_map, 3, JUSTIFICATION_CENTRE, "Right justification");
+ code<Justification, int> (_justification_map, 3, JUSTIFICATION_RIGHT, "Right justification");
code<Comment, int> (_comment_map, 0, COMMENT_NO, "Not a comment");
code<Comment, int> (_comment_map, 1, COMMENT_YES, "Is a comment");