diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-07-30 23:47:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-07-30 23:47:57 +0100 |
| commit | 9a9d4e014c16be88d72914a9480343445bc785a5 (patch) | |
| tree | 1857fcdd8963d51ac50f1467d9ae81d4d9be5f8e /src/types.cc | |
| parent | 34a25d89b16a33b5f619ae0eaaa03c17f93980af (diff) | |
Various.
Diffstat (limited to 'src/types.cc')
| -rw-r--r-- | src/types.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/types.cc b/src/types.cc new file mode 100644 index 00000000..85c5fd6e --- /dev/null +++ b/src/types.cc @@ -0,0 +1,20 @@ +#include <vector> +#include <boost/lexical_cast.hpp> +#include <boost/algorithm/string.hpp> +#include "types.h" +#include "exceptions.h" + +using namespace std; +using namespace libdcp; +using namespace boost; + +Fraction::Fraction (string s) +{ + vector<string> b; + split (b, s, is_any_of (" ")); + if (b.size() != 2) { + throw XMLError ("malformed fraction " + s + " in XML node"); + } + numerator = lexical_cast<int> (b[0]); + denominator = lexical_cast<int> (b[1]); +} |
