Various.
[libdcp.git] / src / types.cc
1 #include <vector>
2 #include <boost/lexical_cast.hpp>
3 #include <boost/algorithm/string.hpp>
4 #include "types.h"
5 #include "exceptions.h"
6
7 using namespace std;
8 using namespace libdcp;
9 using namespace boost;
10
11 Fraction::Fraction (string s)
12 {
13         vector<string> b;
14         split (b, s, is_any_of (" "));
15         if (b.size() != 2) {
16                 throw XMLError ("malformed fraction " + s + " in XML node");
17         }
18         numerator = lexical_cast<int> (b[0]);
19         denominator = lexical_cast<int> (b[1]);
20 }