X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flocale_convert.cc;h=915cac826bbe58387977ed1c355c1a5243ed8985;hb=b789839b6c6a9d9df63818fb88d117c2bde22660;hp=133c8a3a2e0b00af9b8e24ea768b3afe897c0d11;hpb=4e1c04f5448364f0931a2d2d5fe8dcc8619463fc;p=libdcp.git diff --git a/src/locale_convert.cc b/src/locale_convert.cc index 133c8a3a..915cac82 100644 --- a/src/locale_convert.cc +++ b/src/locale_convert.cc @@ -38,6 +38,24 @@ using std::string; using std::wstring; +template<> +string +dcp::locale_convert (unsigned char x, int, bool) +{ + char buffer[64]; + snprintf (buffer, sizeof(buffer), "%hhd", x); + return buffer; +} + +template<> +string +dcp::locale_convert (unsigned short int x, int, bool) +{ + char buffer[64]; + snprintf (buffer, sizeof(buffer), "%hd", x); + return buffer; +} + template<> string dcp::locale_convert (int x, int, bool) @@ -179,6 +197,33 @@ dcp::locale_convert (boost::filesystem::path x, int, bool) return x.string(); } +template<> +unsigned char +dcp::locale_convert (string x, int, bool) +{ + unsigned char y = 0; + sscanf (x.c_str(), "%hhu", &y); + return y; +} + +template<> +unsigned short int +dcp::locale_convert (string x, int, bool) +{ + unsigned short int y = 0; + sscanf (x.c_str(), "%hu", &y); + return y; +} + +template<> +unsigned int +dcp::locale_convert (string x, int, bool) +{ + unsigned int y = 0; + sscanf (x.c_str(), "%u", &y); + return y; +} + template<> int dcp::locale_convert (string x, int, bool) @@ -197,6 +242,19 @@ dcp::locale_convert (string x, int, bool) return y; } +template<> +unsigned long +dcp::locale_convert (string x, int, bool) +{ + unsigned long y = 0; +#ifdef LIBDCP_WINDOWS + __mingw_sscanf (x.c_str(), "%lud", &y); +#else + sscanf (x.c_str(), "%lud", &y); +#endif + return y; +} + template<> long long dcp::locale_convert (string x, int, bool) @@ -210,6 +268,19 @@ dcp::locale_convert (string x, int, bool) return y; } +template<> +unsigned long long +dcp::locale_convert (string x, int, bool) +{ + unsigned long long y = 0; +#ifdef LIBDCP_WINDOWS + __mingw_sscanf (x.c_str(), "%llud", &y); +#else + sscanf (x.c_str(), "%llud", &y); +#endif + return y; +} + template<> float dcp::locale_convert (string x, int, bool)