X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcompose.hpp;h=479493f1461e5e7b0b9ab012eed013bfb96acc35;hb=182b9d2e2feb6545592868606aaf0f0146095481;hp=477000e5dce9fd56e52e2b3e19b1a5a5cba4a946;hpb=e7cd5e4ee467386ff579a76c5f6a6fee03a78fc4;p=dcpomatic.git diff --git a/src/lib/compose.hpp b/src/lib/compose.hpp index 477000e5d..479493f14 100644 --- a/src/lib/compose.hpp +++ b/src/lib/compose.hpp @@ -31,9 +31,10 @@ // more details. // -#ifndef STRING_COMPOSE_H -#define STRING_COMPOSE_H +#ifndef DCPOMATIC_STRING_COMPOSE_H +#define DCPOMATIC_STRING_COMPOSE_H +#include #include #include #include @@ -113,143 +114,11 @@ namespace StringPrivate } } - template - 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 int16_t& obj) - { - char buffer[64]; -#ifdef DCPOMATIC_WINDOWS - __mingw_snprintf(buffer, 64, "%" PRId16, obj); -#else - snprintf(buffer, 64, "%" PRId16, obj); -#endif - s += buffer; - } - - template <> - inline void write(std::string& s, const uint16_t& obj) - { - char buffer[64]; -#ifdef DCPOMATIC_WINDOWS - __mingw_snprintf(buffer, 64, "%" PRIu16, obj); -#else - snprintf(buffer, 64, "%" PRIu16, obj); -#endif - s += buffer; - } - - template <> - inline void write(std::string& s, const int32_t& obj) - { - char buffer[64]; -#ifdef DCPOMATIC_WINDOWS - __mingw_snprintf(buffer, 64, "%" PRId32, obj); -#else - snprintf(buffer, 64, "%" PRId32, obj); -#endif - s += buffer; - } - - template <> - inline void write(std::string& s, const uint32_t& obj) - { - char buffer[64]; -#ifdef DCPOMATIC_WINDOWS - __mingw_snprintf(buffer, 64, "%" PRIu32, obj); -#else - snprintf(buffer, 64, "%" PRIu32, obj); -#endif - s += buffer; - } - - template <> - inline void write(std::string& s, const int64_t& obj) - { - char buffer[64]; -#ifdef DCPOMATIC_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 DCPOMATIC_WINDOWS - __mingw_snprintf(buffer, 64, "%" PRIu64, obj); -#else - snprintf(buffer, 64, "%" PRIu64, obj); -#endif - 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; - } - - inline void write(std::string& s, wchar_t const * const & obj) - { - std::wstring ws (obj); - std::string w (ws.begin(), ws.end()); - s += w; - } - - template <> - inline void write(std::string& s, const boost::filesystem::path & obj) - { - s += obj.string(); - } - // implementation of class Composition template inline Composition &Composition::arg(const T &obj) { - write(os, obj); + os += dcp::locale_convert(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) {