X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flocale_convert.cc;h=89c797599a4374eb60286f8d0a630ce6f9e88d48;hb=refs%2Fheads%2F1.0-templates;hp=549a104172903135bb94e4e3db0e57cb42e0f1cf;hpb=b80f65a2f7cf3e8a02fe0ad8bebb19640f63b5d2;p=libdcp.git diff --git a/src/locale_convert.cc b/src/locale_convert.cc index 549a1041..89c79759 100644 --- a/src/locale_convert.cc +++ b/src/locale_convert.cc @@ -36,6 +36,7 @@ #include using std::string; +using std::wstring; template<> string @@ -48,19 +49,54 @@ dcp::locale_convert (int x, int, bool) template<> string -dcp::locale_convert (int64_t x, int, bool) +dcp::locale_convert (unsigned int x, int, bool) { char buffer[64]; - snprintf (buffer, sizeof(buffer), "%" PRId64, x); + snprintf (buffer, sizeof(buffer), "%u", x); return buffer; } template<> string -dcp::locale_convert (uint64_t x, int, bool) +dcp::locale_convert (long int x, int, bool) { char buffer[64]; - snprintf (buffer, sizeof(buffer), "%" PRIu64, x); + snprintf (buffer, sizeof(buffer), "%ld", x); + return buffer; +} + +template<> +string +dcp::locale_convert (unsigned long int x, int, bool) +{ + char buffer[64]; + snprintf (buffer, sizeof(buffer), "%lu", x); + return buffer; +} + +template<> +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; +} + +template<> +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; } @@ -115,6 +151,30 @@ dcp::locale_convert (char const * x, int, bool) return x; } +template<> +string +dcp::locale_convert (wchar_t const * x, int, bool) +{ + wstring s (x); + return string (s.begin(), s.end()); +} + +template<> +string +dcp::locale_convert (char x, int, bool) +{ + string s; + s += x; + return s; +} + +template<> +string +dcp::locale_convert (boost::filesystem::path x, int, bool) +{ + return x.string(); +} + template<> int dcp::locale_convert (string x, int, bool) @@ -125,11 +185,20 @@ dcp::locale_convert (string x, int, bool) } template<> -int64_t +long +dcp::locale_convert (string x, int, bool) +{ + long int y = 0; + sscanf (x.c_str(), "%ld", &y); + return y; +} + +template<> +long long dcp::locale_convert (string x, int, bool) { - int64_t y = 0; - sscanf (x.c_str(), "%" PRId64, &y); + long long y = 0; + sscanf (x.c_str(), "%lld", &y); return y; }