summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-12 09:10:08 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-12 09:14:09 +0100
commitb81241ce69a689629307832f802ac4faa6ed885f (patch)
tree307eb7b6bb562553e6e92e8939d5c89f7111e66a /src/lib
parent94056bf7f8fdef32da3cd78eff68d58560b4e6be (diff)
Move locale_convert into libdcp.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/audio_content.cc1
-rw-r--r--src/lib/colour_conversion.cc2
-rw-r--r--src/lib/config.cc2
-rw-r--r--src/lib/content.cc3
-rw-r--r--src/lib/ffmpeg_content.cc9
-rw-r--r--src/lib/film.cc2
-rw-r--r--src/lib/j2k_image_proxy.cc2
-rw-r--r--src/lib/locale_convert.cc122
-rw-r--r--src/lib/locale_convert.h81
-rw-r--r--src/lib/player_video.cc4
-rw-r--r--src/lib/raw_image_proxy.cc2
-rw-r--r--src/lib/subtitle_content.cc8
-rw-r--r--src/lib/user_property.h4
-rw-r--r--src/lib/util.cc3
-rw-r--r--src/lib/video_content.cc1
-rw-r--r--src/lib/wscript1
16 files changed, 21 insertions, 226 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc
index 25a7ef8a5..e66b8b998 100644
--- a/src/lib/audio_content.cc
+++ b/src/lib/audio_content.cc
@@ -24,7 +24,6 @@
#include "config.h"
#include "frame_rate_change.h"
#include "compose.hpp"
-#include "locale_convert.h"
#include <dcp/raw_convert.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc
index e4659a5d9..aa6b61fed 100644
--- a/src/lib/colour_conversion.cc
+++ b/src/lib/colour_conversion.cc
@@ -152,7 +152,7 @@ ColourConversion::as_xml (xmlpp::Node* node) const
in_node->add_child("B")->add_child_text (raw_convert<string> (tf->B ()));
}
- node->add_child("YUVToRGB")->add_child_text (raw_convert<string> (_yuv_to_rgb));
+ node->add_child("YUVToRGB")->add_child_text (raw_convert<string> (static_cast<int> (_yuv_to_rgb)));
node->add_child("RedX")->add_child_text (raw_convert<string> (_red.x));
node->add_child("RedY")->add_child_text (raw_convert<string> (_red.y));
node->add_child("GreenX")->add_child_text (raw_convert<string> (_green.x));
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 7f457439d..b5e4b4d00 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -380,7 +380,7 @@ Config::write_config_xml () const
}
root->add_child("OnlyServersEncode")->add_child_text (_only_servers_encode ? "1" : "0");
- root->add_child("TMSProtocol")->add_child_text (raw_convert<string> (_tms_protocol));
+ root->add_child("TMSProtocol")->add_child_text (raw_convert<string> (static_cast<int> (_tms_protocol)));
root->add_child("TMSIP")->add_child_text (_tms_ip);
root->add_child("TMSPath")->add_child_text (_tms_path);
root->add_child("TMSUser")->add_child_text (_tms_user);
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 536036ff7..9083635f2 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -27,9 +27,9 @@
#include "content_factory.h"
#include "exceptions.h"
#include "film.h"
-#include "locale_convert.h"
#include "job.h"
#include "compose.hpp"
+#include <dcp/locale_convert.h>
#include <dcp/raw_convert.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
@@ -46,6 +46,7 @@ using std::max;
using std::pair;
using boost::shared_ptr;
using dcp::raw_convert;
+using dcp::locale_convert;
int const ContentProperty::PATH = 400;
int const ContentProperty::POSITION = 401;
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index 71cda084c..b5c5ce0a8 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -33,7 +33,6 @@
#include "exceptions.h"
#include "frame_rate_change.h"
#include "subtitle_content.h"
-#include "locale_convert.h"
#include <dcp/raw_convert.h>
#include <libcxml/cxml.h>
extern "C" {
@@ -223,10 +222,10 @@ FFmpegContent::as_xml (xmlpp::Node* node) const
node->add_child("FirstVideo")->add_child_text (raw_convert<string> (_first_video.get().get()));
}
- node->add_child("ColorRange")->add_child_text (raw_convert<string> (_color_range));
- node->add_child("ColorPrimaries")->add_child_text (raw_convert<string> (_color_primaries));
- node->add_child("ColorTransferCharacteristic")->add_child_text (raw_convert<string> (_color_trc));
- node->add_child("Colorspace")->add_child_text (raw_convert<string> (_colorspace));
+ node->add_child("ColorRange")->add_child_text (raw_convert<string> (static_cast<int> (_color_range)));
+ node->add_child("ColorPrimaries")->add_child_text (raw_convert<string> (static_cast<int> (_color_primaries)));
+ node->add_child("ColorTransferCharacteristic")->add_child_text (raw_convert<string> (static_cast<int> (_color_trc)));
+ node->add_child("Colorspace")->add_child_text (raw_convert<string> (static_cast<int> (_colorspace)));
if (_bits_per_pixel) {
node->add_child("BitsPerPixel")->add_child_text (raw_convert<string> (_bits_per_pixel.get ()));
}
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 58c272eb1..a41ab3c95 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -361,7 +361,7 @@ Film::metadata () const
if (_audio_processor) {
root->add_child("AudioProcessor")->add_child_text (_audio_processor->id ());
}
- root->add_child("ReelType")->add_child_text (raw_convert<string> (_reel_type));
+ root->add_child("ReelType")->add_child_text (raw_convert<string> (static_cast<int> (_reel_type)));
root->add_child("ReelLength")->add_child_text (raw_convert<string> (_reel_length));
root->add_child("UploadAfterMakeDCP")->add_child_text (_upload_after_make_dcp ? "1" : "0");
_playlist->as_xml (root->add_child ("Playlist"));
diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc
index 707a088e9..fb38c9e99 100644
--- a/src/lib/j2k_image_proxy.cc
+++ b/src/lib/j2k_image_proxy.cc
@@ -143,7 +143,7 @@ J2KImageProxy::add_metadata (xmlpp::Node* node) const
node->add_child("Width")->add_child_text (raw_convert<string> (_size.width));
node->add_child("Height")->add_child_text (raw_convert<string> (_size.height));
if (_eye) {
- node->add_child("Eye")->add_child_text (raw_convert<string> (_eye.get ()));
+ node->add_child("Eye")->add_child_text (raw_convert<string> (static_cast<int> (_eye.get ())));
}
node->add_child("Size")->add_child_text (raw_convert<string> (_data.size ()));
}
diff --git a/src/lib/locale_convert.cc b/src/lib/locale_convert.cc
deleted file mode 100644
index 6358c0f8c..000000000
--- a/src/lib/locale_convert.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "locale_convert.h"
-#include <string>
-#include <inttypes.h>
-
-using std::string;
-
-template<>
-string
-locale_convert (int x, int)
-{
- char buffer[64];
- snprintf (buffer, sizeof(buffer), "%d", x);
- return buffer;
-}
-
-template<>
-string
-locale_convert (int64_t x, int)
-{
- char buffer[64];
- snprintf (buffer, sizeof(buffer), "%" PRId64, x);
- return buffer;
-}
-
-template<>
-string
-locale_convert (float x, int precision)
-{
- char format[64];
- snprintf (format, sizeof(format), "%%.%df", precision);
- char buffer[64];
- snprintf (buffer, sizeof(buffer), format, x);
- return buffer;
-}
-
-template<>
-string
-locale_convert (double x, int precision)
-{
- char format[64];
- snprintf (format, sizeof(format), "%%.%df", precision);
- char buffer[64];
- snprintf (buffer, sizeof(buffer), format, x);
- return buffer;
-}
-
-template<>
-string
-locale_convert (string x, int)
-{
- return x;
-}
-
-template<>
-string
-locale_convert (char* x, int)
-{
- return x;
-}
-
-template<>
-string
-locale_convert (char const * x, int)
-{
- return x;
-}
-
-template<>
-int
-locale_convert (string x, int)
-{
- int y = 0;
- sscanf (x.c_str(), "%d", &y);
- return y;
-}
-
-template<>
-int64_t
-locale_convert (string x, int)
-{
- int64_t y = 0;
- sscanf (x.c_str(), "%" PRId64, &y);
- return y;
-}
-
-template<>
-float
-locale_convert (string x, int)
-{
- float y = 0;
- sscanf (x.c_str(), "%f", &y);
- return y;
-}
-
-template<>
-double
-locale_convert (string x, int)
-{
- double y = 0;
- sscanf (x.c_str(), "%lf", &y);
- return y;
-}
diff --git a/src/lib/locale_convert.h b/src/lib/locale_convert.h
deleted file mode 100644
index b5c38caae..000000000
--- a/src/lib/locale_convert.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef DCPOMATIC_LOCALE_CONVERT_H
-#define DCPOMATIC_LOCALE_CONVERT_H
-
-#include <boost/static_assert.hpp>
-#include <string>
-
-template <typename P, typename Q>
-P
-locale_convert (Q x, int precision = 16)
-{
- /* We can't write a generic version of locale_convert; all required
- versions must be specialised.
- */
- BOOST_STATIC_ASSERT (sizeof (Q) == 0);
-}
-
-template <>
-std::string
-locale_convert (int x, int);
-
-template <>
-std::string
-locale_convert (int64_t x, int);
-
-template <>
-std::string
-locale_convert (float x, int precision);
-
-template <>
-std::string
-locale_convert (double x, int precision);
-
-template <>
-std::string
-locale_convert (std::string x, int);
-
-template <>
-std::string
-locale_convert (char* x, int);
-
-template <>
-std::string
-locale_convert (char const * x, int);
-
-template <>
-int
-locale_convert (std::string x, int);
-
-template <>
-int64_t
-locale_convert (std::string x, int);
-
-template <>
-float
-locale_convert (std::string x, int);
-
-template <>
-double
-locale_convert (std::string x, int);
-
-#endif
diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc
index a86ff1451..17d3dc522 100644
--- a/src/lib/player_video.cc
+++ b/src/lib/player_video.cc
@@ -159,8 +159,8 @@ PlayerVideo::add_metadata (xmlpp::Node* node) const
node->add_child("InterHeight")->add_child_text (raw_convert<string> (_inter_size.height));
node->add_child("OutWidth")->add_child_text (raw_convert<string> (_out_size.width));
node->add_child("OutHeight")->add_child_text (raw_convert<string> (_out_size.height));
- node->add_child("Eyes")->add_child_text (raw_convert<string> (_eyes));
- node->add_child("Part")->add_child_text (raw_convert<string> (_part));
+ node->add_child("Eyes")->add_child_text (raw_convert<string> (static_cast<int> (_eyes)));
+ node->add_child("Part")->add_child_text (raw_convert<string> (static_cast<int> (_part)));
if (_colour_conversion) {
_colour_conversion.get().as_xml (node);
}
diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc
index e182c0e5d..6ebcee60c 100644
--- a/src/lib/raw_image_proxy.cc
+++ b/src/lib/raw_image_proxy.cc
@@ -64,7 +64,7 @@ RawImageProxy::add_metadata (xmlpp::Node* node) const
node->add_child("Type")->add_child_text (N_("Raw"));
node->add_child("Width")->add_child_text (raw_convert<string> (_image->size().width));
node->add_child("Height")->add_child_text (raw_convert<string> (_image->size().height));
- node->add_child("PixelFormat")->add_child_text (raw_convert<string> (_image->pixel_format ()));
+ node->add_child("PixelFormat")->add_child_text (raw_convert<string> (static_cast<int> (_image->pixel_format ())));
}
void
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index d6bf54aef..21bfd8a2d 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -224,8 +224,8 @@ SubtitleContent::as_xml (xmlpp::Node* root) const
{
boost::mutex::scoped_lock lm (_mutex);
- root->add_child("UseSubtitles")->add_child_text (raw_convert<string> (_use));
- root->add_child("BurnSubtitles")->add_child_text (raw_convert<string> (_burn));
+ root->add_child("UseSubtitles")->add_child_text (_use ? "1" : "0");
+ root->add_child("BurnSubtitles")->add_child_text (_burn ? "1" : "0");
root->add_child("SubtitleXOffset")->add_child_text (raw_convert<string> (_x_offset));
root->add_child("SubtitleYOffset")->add_child_text (raw_convert<string> (_y_offset));
root->add_child("SubtitleXScale")->add_child_text (raw_convert<string> (_x_scale));
@@ -234,8 +234,8 @@ SubtitleContent::as_xml (xmlpp::Node* root) const
root->add_child("Red")->add_child_text (raw_convert<string> (_colour.r));
root->add_child("Green")->add_child_text (raw_convert<string> (_colour.g));
root->add_child("Blue")->add_child_text (raw_convert<string> (_colour.b));
- root->add_child("Outline")->add_child_text (raw_convert<string> (_outline));
- root->add_child("Shadow")->add_child_text (raw_convert<string> (_shadow));
+ root->add_child("Outline")->add_child_text (_outline ? "1" : "0");
+ root->add_child("Shadow")->add_child_text (_shadow ? "1" : "0");
root->add_child("EffectRed")->add_child_text (raw_convert<string> (_effect_colour.r));
root->add_child("EffectGreen")->add_child_text (raw_convert<string> (_effect_colour.g));
root->add_child("EffectBlue")->add_child_text (raw_convert<string> (_effect_colour.b));
diff --git a/src/lib/user_property.h b/src/lib/user_property.h
index 8b69b7687..ffbb99a5f 100644
--- a/src/lib/user_property.h
+++ b/src/lib/user_property.h
@@ -21,7 +21,7 @@
#ifndef DCPOMATIC_USER_PROPERTY_H
#define DCPOMATIC_USER_PROPERTY_H
-#include "locale_convert.h"
+#include <dcp/locale_convert.h>
class UserProperty
{
@@ -37,7 +37,7 @@ public:
UserProperty (Category category_, std::string key_, T value_, std::string unit_ = "")
: category (category_)
, key (key_)
- , value (locale_convert<std::string> (value_))
+ , value (dcp::locale_convert<std::string> (value_))
, unit (unit_)
{}
diff --git a/src/lib/util.cc b/src/lib/util.cc
index eedc7ddb5..d20fd7dc7 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -36,7 +36,7 @@
#include "digester.h"
#include "audio_processor.h"
#include "compose.hpp"
-#include "locale_convert.h"
+#include <dcp/locale_convert.h>
#include <dcp/util.h>
#include <dcp/raw_convert.h>
#include <dcp/picture_asset.h>
@@ -94,6 +94,7 @@ using boost::lexical_cast;
using boost::bad_lexical_cast;
using dcp::Size;
using dcp::raw_convert;
+using dcp::locale_convert;
/** Path to our executable, required by the stacktrace stuff and filled
* in during App::onInit().
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index ac038678c..4f1b08016 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -30,7 +30,6 @@
#include "exceptions.h"
#include "frame_rate_change.h"
#include "log.h"
-#include "locale_convert.h"
#include <dcp/raw_convert.h>
#include <libcxml/cxml.h>
#include <dcp/colour_matrix.h>
diff --git a/src/lib/wscript b/src/lib/wscript
index 074c12ad4..911ee0af4 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -94,7 +94,6 @@ sources = """
job.cc
job_manager.cc
json_server.cc
- locale_convert.cc
log.cc
log_entry.cc
magick_image_proxy.cc