diff options
| -rw-r--r-- | src/compose.hpp | 112 | ||||
| -rw-r--r-- | src/locale_convert.cc | 15 | ||||
| -rw-r--r-- | src/locale_convert.h | 5 | ||||
| -rw-r--r-- | src/raw_convert.cc | 9 | ||||
| -rw-r--r-- | wscript | 2 |
5 files changed, 23 insertions, 120 deletions
diff --git a/src/compose.hpp b/src/compose.hpp index ec016e97..faffc41c 100644 --- a/src/compose.hpp +++ b/src/compose.hpp @@ -34,6 +34,7 @@ #ifndef STRING_COMPOSE_H #define STRING_COMPOSE_H +#include "locale_convert.h" #include <boost/filesystem.hpp> #include <string> #include <list> @@ -113,120 +114,11 @@ namespace StringPrivate } } - template <typename T> - inline void write(std::string& s, const T& obj) - { - /* Assume anything not specialized has a to_string() method */ - s += to_string (obj); - } - - template <> - inline void write(std::string& s, const int64_t& obj) - { - char buffer[64]; -#ifdef LIBDCP_WINDOWS - __mingw_snprintf(buffer, 64, "%" PRId64, obj); -#else - snprintf(buffer, 64, "%" PRId64, obj); -#endif - s += buffer; - } - - template <> - inline void write(std::string& s, const uint64_t& obj) - { - char buffer[64]; -#ifdef LIBDCP_WINDOWS - __mingw_snprintf(buffer, 64, "%" PRIu64, obj); -#else - snprintf(buffer, 64, "%" PRIu64, obj); -#endif - s += buffer; - } - - template <> - inline void write(std::string& s, const int32_t& obj) - { - char buffer[64]; - snprintf(buffer, 64, "%" PRId32, obj); - s += buffer; - } - - template <> - inline void write(std::string& s, const uint32_t& obj) - { - char buffer[64]; - snprintf(buffer, 64, "%d" PRIu32, obj); - s += buffer; - } - - template <> - inline void write(std::string& s, const int16_t& obj) - { - char buffer[64]; - snprintf(buffer, 64, "%" PRId16, obj); - s += buffer; - } - - template <> - inline void write(std::string& s, const uint16_t& obj) - { - char buffer[64]; - snprintf(buffer, 64, "%d" PRIu16, obj); - s += buffer; - } - - template <> - inline void write(std::string& s, const float& obj) - { - char buffer[64]; - snprintf(buffer, 64, "%f", obj); - s += buffer; - } - - template <> - inline void write(std::string& s, const char& obj) - { - s += obj; - } - - template <> - inline void write(std::string& s, const double& obj) - { - char buffer[64]; - snprintf(buffer, 64, "%f", obj); - s += buffer; - } - - template <> - inline void write(std::string& s, char const * const & obj) - { - s += obj; - } - - template <> - inline void write(std::string& s, char* const & obj) - { - s += obj; - } - - template <> - inline void write(std::string& s, const std::string& obj) - { - s += obj; - } - - template <> - inline void write(std::string& s, const boost::filesystem::path & obj) - { - s += obj.string(); - } - // implementation of class Composition template <typename T> inline Composition &Composition::arg(const T &obj) { - write(os, obj); + os += dcp::locale_convert<std::string> (obj); if (!os.empty()) { // manipulators don't produce output for (specification_map::const_iterator i = specs.lower_bound(arg_no), end = specs.upper_bound(arg_no); i != end; ++i) { diff --git a/src/locale_convert.cc b/src/locale_convert.cc index 4cd24a7f..64b21274 100644 --- a/src/locale_convert.cc +++ b/src/locale_convert.cc @@ -78,7 +78,11 @@ string dcp::locale_convert (long long int x, int, bool) { char buffer[64]; +#ifdef LIBDCP_WINDOWS + __mingw_snprintf (buffer, sizeof(buffer), "%lld", x); +#else snprintf (buffer, sizeof(buffer), "%lld", x); +#endif return buffer; } @@ -87,7 +91,11 @@ string dcp::locale_convert (unsigned long long int x, int, bool) { char buffer[64]; +#ifdef LIBDCP_WINDOWS + __mingw_snprintf (buffer, sizeof(buffer), "%llu", x); +#else snprintf (buffer, sizeof(buffer), "%llu", x); +#endif return buffer; } @@ -143,6 +151,13 @@ dcp::locale_convert (char const * x, int, bool) } template<> +string +dcp::locale_convert (boost::filesystem::path x, int, bool) +{ + return x.string(); +} + +template<> int dcp::locale_convert (string x, int, bool) { diff --git a/src/locale_convert.h b/src/locale_convert.h index 25f5cfa4..3d55a00e 100644 --- a/src/locale_convert.h +++ b/src/locale_convert.h @@ -34,6 +34,7 @@ #ifndef LIBDCP_LOCALE_CONVERT_H #define LIBDCP_LOCALE_CONVERT_H +#include <boost/filesystem.hpp> #include <boost/static_assert.hpp> #include <string> #include <cstdio> @@ -95,6 +96,10 @@ std::string locale_convert (char const * x, int, bool); template <> +std::string +locale_convert (boost::filesystem::path x, int, bool); + +template <> int locale_convert (std::string x, int, bool); diff --git a/src/raw_convert.cc b/src/raw_convert.cc index 5ee0aed5..b7685ab8 100644 --- a/src/raw_convert.cc +++ b/src/raw_convert.cc @@ -99,15 +99,6 @@ dcp::raw_convert (unsigned long long v, int precision, bool fixed) return make_raw (locale_convert<string> (v, precision, fixed)); } -#ifdef LIBDCP_OSX -template <> -string -dcp::raw_convert (unsigned long int v, int precision, bool fixed) -{ - return make_raw (locale_convert<string> (v, precision, fixed)); -} -#endif - template <> string dcp::raw_convert (float v, int precision, bool fixed) @@ -74,7 +74,7 @@ def configure(conf): conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX') if conf.env.TARGET_OSX: - conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef', '-DLIBDCP_OSX']) + conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef']) # Disable libxml++ deprecation warnings for now conf.env.append_value('CXXFLAGS', ['-Wno-deprecated-declarations']) |
