summaryrefslogtreecommitdiff
path: root/src/types.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-05-11 23:59:19 +0100
committerCarl Hetherington <cth@carlh.net>2014-05-11 23:59:19 +0100
commit4de8f0118e1baf31cf4c859881dfbf39014b566f (patch)
tree91be88947914d05ff942cbefff6c71eab187cc3c /src/types.cc
parent3390da35584709ea0626ec1fefd3bf5d797bcc00 (diff)
Use raw_convert instead of boost::lexical_cast as it seems
that lexical_cast will sometimes use a thousands separator (i.e. it will convert 1234 to a string 1,234). It appears not to be possible safely to turn this off (you have to set the global locale). Instead, raw_convert uses a stringstream which you can imbue() with std::locale::classic() to turn off the locale-specific behaviour.
Diffstat (limited to 'src/types.cc')
-rw-r--r--src/types.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/types.cc b/src/types.cc
index 693b9ab2..f45e3345 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -1,3 +1,22 @@
+/*
+ Copyright (C) 2012-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.
+
+*/
+
#include <vector>
#include <cstdio>
#include <iomanip>
@@ -5,6 +24,7 @@
#include <boost/algorithm/string.hpp>
#include "types.h"
#include "exceptions.h"
+#include "raw_convert.h"
using namespace std;
using namespace libdcp;
@@ -17,8 +37,8 @@ Fraction::Fraction (string s)
if (b.size() != 2) {
boost::throw_exception (XMLError ("malformed fraction " + s + " in XML node"));
}
- numerator = lexical_cast<int> (b[0]);
- denominator = lexical_cast<int> (b[1]);
+ numerator = raw_convert<int> (b[0]);
+ denominator = raw_convert<int> (b[1]);
}
bool