diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-14 09:33:23 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-14 09:33:23 +0100 |
| commit | 2f0e6ee9d883abbbc31aca0d1cc80e89eb9b0af2 (patch) | |
| tree | f1215070c7a4458f8b474fc7163345c6c1c10744 /src | |
| parent | e64f6002a413f7aaffca60387d82c2e91b931ab9 (diff) | |
| parent | 110dc70856bd0f6ae5ec1931f51a4817c5e38f42 (diff) | |
Merge master.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset.cc | 7 | ||||
| -rw-r--r-- | src/cpl.cc | 2 | ||||
| -rw-r--r-- | src/dcp.cc | 5 | ||||
| -rw-r--r-- | src/dcp_time.cc | 10 | ||||
| -rw-r--r-- | src/font.cc | 2 | ||||
| -rw-r--r-- | src/mxf.cc | 1 | ||||
| -rw-r--r-- | src/raw_convert.h | 39 | ||||
| -rw-r--r-- | src/reel_asset.cc | 8 | ||||
| -rw-r--r-- | src/subtitle.cc | 1 | ||||
| -rw-r--r-- | src/subtitle_content.cc | 15 | ||||
| -rw-r--r-- | src/types.cc | 6 | ||||
| -rw-r--r-- | src/wscript | 1 |
12 files changed, 69 insertions, 28 deletions
diff --git a/src/asset.cc b/src/asset.cc index aaa79dc7..6bf8fec5 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -21,15 +21,14 @@ * @brief Asset class. */ +#include "raw_convert.h" #include "asset.h" #include "util.h" #include "exceptions.h" #include "compose.hpp" #include <libxml++/libxml++.h> -#include <boost/lexical_cast.hpp> using std::string; -using boost::lexical_cast; using boost::function; using boost::optional; using namespace dcp; @@ -68,7 +67,7 @@ Asset::write_to_pkl (xmlpp::Node* node, Standard standard) const asset->add_child("Id")->add_child_text ("urn:uuid:" + _id); asset->add_child("AnnotationText")->add_child_text (_id); asset->add_child("Hash")->add_child_text (hash ()); - asset->add_child("Size")->add_child_text (lexical_cast<string> (boost::filesystem::file_size (_file))); + asset->add_child("Size")->add_child_text (raw_convert<string> (boost::filesystem::file_size (_file))); asset->add_child("Type")->add_child_text (pkl_type (standard)); } @@ -88,7 +87,7 @@ Asset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const chunk->add_child("Path")->add_child_text (path.get().string ()); chunk->add_child("VolumeIndex")->add_child_text ("1"); chunk->add_child("Offset")->add_child_text ("0"); - chunk->add_child("Length")->add_child_text (lexical_cast<string> (boost::filesystem::file_size (_file))); + chunk->add_child("Length")->add_child_text (raw_convert<string> (boost::filesystem::file_size (_file))); } string @@ -17,6 +17,7 @@ */ +#include "raw_convert.h" #include "cpl.h" #include "util.h" #include "mono_picture_mxf.h" @@ -42,7 +43,6 @@ using std::list; using std::pair; using std::make_pair; using boost::shared_ptr; -using boost::lexical_cast; using boost::optional; using namespace dcp; @@ -21,6 +21,7 @@ * @brief DCP class. */ +#include "raw_convert.h" #include "dcp.h" #include "sound_mxf.h" #include "picture_mxf.h" @@ -42,7 +43,6 @@ #include <libxml++/libxml++.h> #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> -#include <boost/lexical_cast.hpp> #include <sstream> #include <iomanip> #include <cassert> @@ -57,7 +57,6 @@ using std::map; using std::cout; using std::exception; using boost::shared_ptr; -using boost::lexical_cast; using boost::algorithm::starts_with; using namespace dcp; @@ -372,7 +371,7 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, int pkl_length, XMLMeta chunk->add_child("Path")->add_child_text (pkl_uuid + "_pkl.xml"); chunk->add_child("VolumeIndex")->add_child_text ("1"); chunk->add_child("Offset")->add_child_text ("0"); - chunk->add_child("Length")->add_child_text (lexical_cast<string> (pkl_length)); + chunk->add_child("Length")->add_child_text (raw_convert<string> (pkl_length)); for (list<shared_ptr<Asset> >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { (*i)->write_to_assetmap (asset_list, _directory); diff --git a/src/dcp_time.cc b/src/dcp_time.cc index 5376b972..a3822ed0 100644 --- a/src/dcp_time.cc +++ b/src/dcp_time.cc @@ -21,10 +21,10 @@ * @brief Time class. */ +#include "raw_convert.h" #include "dcp_time.h" #include "exceptions.h" #include <boost/algorithm/string.hpp> -#include <boost/lexical_cast.hpp> #include <iostream> #include <vector> #include <cmath> @@ -78,10 +78,10 @@ Time::Time (string time) boost::throw_exception (DCPReadError ("unrecognised time specification")); } - h = lexical_cast<int> (b[0]); - m = lexical_cast<int> (b[1]); - s = lexical_cast<int> (b[2]); - t = lexical_cast<int> (b[3]); + h = raw_convert<int> (b[0]); + m = raw_convert<int> (b[1]); + s = raw_convert<int> (b[2]); + t = raw_convert<int> (b[3]); } bool diff --git a/src/font.cc b/src/font.cc index 52996a73..51bd866e 100644 --- a/src/font.cc +++ b/src/font.cc @@ -17,6 +17,8 @@ */ +#include "types.h" +#include "raw_convert.h" #include "font.h" #include "xml.h" #include "text.h" @@ -21,6 +21,7 @@ * @brief Parent class for assets of DCPs made up of MXF files. */ +#include "raw_convert.h" #include "AS_DCP.h" #include "KM_prng.h" #include "KM_util.h" diff --git a/src/raw_convert.h b/src/raw_convert.h new file mode 100644 index 00000000..68bbaf7a --- /dev/null +++ b/src/raw_convert.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 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 <sstream> + +namespace dcp { + +/** A sort-of version of boost::lexical_cast that does uses the "C" + * locale (i.e. no thousands separators and a . for the decimal separator). + */ +template <typename P, typename Q> +P +raw_convert (Q v) +{ + std::stringstream s; + s.imbue (std::locale::classic ()); + s << v; + P r; + s >> r; + return r; +} + +}; diff --git a/src/reel_asset.cc b/src/reel_asset.cc index fa0068c5..7987a155 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -17,6 +17,7 @@ */ +#include "raw_convert.h" #include "reel_asset.h" #include "content.h" #include "compose.hpp" @@ -26,7 +27,6 @@ using std::pair; using std::string; using std::make_pair; using boost::shared_ptr; -using boost::lexical_cast; using namespace dcp; ReelAsset::ReelAsset () @@ -89,9 +89,9 @@ ReelAsset::write_to_cpl (xmlpp::Node* node, Standard) const a->add_child("Id")->add_child_text ("urn:uuid:" + _id); a->add_child("AnnotationText")->add_child_text (_annotation_text); a->add_child("EditRate")->add_child_text (String::compose ("%1 %2", _edit_rate.numerator, _edit_rate.denominator)); - a->add_child("IntrinsicDuration")->add_child_text (lexical_cast<string> (_intrinsic_duration)); - a->add_child("EntryPoint")->add_child_text (lexical_cast<string> (_entry_point)); - a->add_child("Duration")->add_child_text (lexical_cast<string> (_duration)); + a->add_child("IntrinsicDuration")->add_child_text (raw_convert<string> (_intrinsic_duration)); + a->add_child("EntryPoint")->add_child_text (raw_convert<string> (_entry_point)); + a->add_child("Duration")->add_child_text (raw_convert<string> (_duration)); if (!_key_id.empty ()) { a->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id); } diff --git a/src/subtitle.cc b/src/subtitle.cc index 8c40254a..12714961 100644 --- a/src/subtitle.cc +++ b/src/subtitle.cc @@ -22,6 +22,7 @@ #include "font.h" #include "text.h" #include <libcxml/cxml.h> +#include <boost/lexical_cast.hpp> using std::string; using boost::shared_ptr; diff --git a/src/subtitle_content.cc b/src/subtitle_content.cc index 0aaab9a2..a622e7b0 100644 --- a/src/subtitle_content.cc +++ b/src/subtitle_content.cc @@ -17,6 +17,7 @@ */ +#include "raw_convert.h" #include "subtitle_content.h" #include "util.h" #include "xml.h" @@ -27,7 +28,6 @@ #include "AS_DCP.h" #include "KM_util.h" #include <libxml++/nodes/element.h> -#include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <fstream> @@ -38,7 +38,6 @@ using std::ofstream; using std::stringstream; using std::cout; using boost::shared_ptr; -using boost::lexical_cast; using boost::optional; using namespace dcp; @@ -258,7 +257,7 @@ SubtitleContent::xml_as_string () const if (_movie_title) { root->add_child("MovieTitle")->add_child_text (_movie_title.get ()); } - root->add_child("ReelNumber")->add_child_text (lexical_cast<string> (_reel_number)); + root->add_child("ReelNumber")->add_child_text (raw_convert<string> (_reel_number)); root->add_child("Language")->add_child_text (_language); if (_load_font_nodes.size() > 1) { @@ -326,7 +325,7 @@ SubtitleContent::xml_as_string () const font->set_attribute ("Id", id); font->set_attribute ("Italic", italic ? "yes" : "no"); font->set_attribute ("Color", color.to_argb_string()); - font->set_attribute ("Size", lexical_cast<string> (size)); + font->set_attribute ("Size", raw_convert<string> (size)); font->set_attribute ("Effect", effect_to_string (effect)); font->set_attribute ("EffectColor", effect_color.to_argb_string()); font->set_attribute ("Script", "normal"); @@ -342,11 +341,11 @@ SubtitleContent::xml_as_string () const )) { subtitle = font->add_child ("Subtitle"); - subtitle->set_attribute ("SpotNumber", lexical_cast<string> (spot_number++)); + subtitle->set_attribute ("SpotNumber", raw_convert<string> (spot_number++)); subtitle->set_attribute ("TimeIn", (*i)->in().to_string()); subtitle->set_attribute ("TimeOut", (*i)->out().to_string()); - subtitle->set_attribute ("FadeUpTime", lexical_cast<string> ((*i)->fade_up_time().to_ticks())); - subtitle->set_attribute ("FadeDownTime", lexical_cast<string> ((*i)->fade_down_time().to_ticks())); + subtitle->set_attribute ("FadeUpTime", raw_convert<string> ((*i)->fade_up_time().to_ticks())); + subtitle->set_attribute ("FadeDownTime", raw_convert<string> ((*i)->fade_down_time().to_ticks())); last_in = (*i)->in (); last_out = (*i)->out (); @@ -356,7 +355,7 @@ SubtitleContent::xml_as_string () const xmlpp::Element* text = subtitle->add_child ("Text"); text->set_attribute ("VAlign", valign_to_string ((*i)->v_align())); - text->set_attribute ("VPosition", lexical_cast<string> ((*i)->v_position())); + text->set_attribute ("VPosition", raw_convert<string> ((*i)->v_position())); text->add_child_text ((*i)->text()); } diff --git a/src/types.cc b/src/types.cc index 0ecf7a16..fc6d50f3 100644 --- a/src/types.cc +++ b/src/types.cc @@ -17,9 +17,9 @@ */ +#include "raw_convert.h" #include "types.h" #include "exceptions.h" -#include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <vector> #include <cstdio> @@ -39,8 +39,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 diff --git a/src/wscript b/src/wscript index fbbd9f2b..e5f0c2a5 100644 --- a/src/wscript +++ b/src/wscript @@ -91,6 +91,7 @@ def build(bld): object.h picture_mxf.h picture_mxf_writer.h + raw_convert.h rgb_xyz.h reel.h reel_asset.h |
