summaryrefslogtreecommitdiff
path: root/src/stl_binary_tables.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-06-04 10:50:57 +0100
committerCarl Hetherington <cth@carlh.net>2014-06-04 10:50:57 +0100
commitdf5e7ee155351ecd6e7ef52b1764149b5fcb258a (patch)
tree5726abe72ccb97b979449d221bee132d642e9157 /src/stl_binary_tables.cc
parentd8cc379d5dd638e26ee0b46bc610fd2e33be2311 (diff)
Add language description -> enum.
Diffstat (limited to 'src/stl_binary_tables.cc')
-rw-r--r--src/stl_binary_tables.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/stl_binary_tables.cc b/src/stl_binary_tables.cc
index 7fdad7b..df571c4 100644
--- a/src/stl_binary_tables.cc
+++ b/src/stl_binary_tables.cc
@@ -33,7 +33,6 @@ code (map<F, STLBinaryCode<E> >& m, F k, E v, string d)
m[k] = STLBinaryCode<E> (v, d);
}
-
template <class E, class F>
E
file_to_enum (F k, map<F, STLBinaryCode<E> > m, string name)
@@ -72,6 +71,19 @@ enum_to_description (E v, map<F, STLBinaryCode<E> > const & m)
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
@@ -181,6 +193,12 @@ STLBinaryTables::comment_enum_to_description (Comment 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");