More raw/locale_convert.
authorCarl Hetherington <cth@carlh.net>
Tue, 9 Oct 2018 18:20:01 +0000 (19:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 9 Oct 2018 18:20:01 +0000 (19:20 +0100)
src/locale_convert.cc
src/locale_convert.h
src/raw_convert.cc
src/raw_convert.h

index 0f0b5fa2311bda699d23e94ad92e17793d7710f3..5e7c350f4098138370ee763c3deeae548330c066 100644 (file)
@@ -197,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)
+{
+       int y = 0;
+       sscanf (x.c_str(), "%u", &y);
+       return y;
+}
+
 template<>
 int
 dcp::locale_convert (string x, int, bool)
index 96309fd2a7abe7515d9c26eb5dedb426505d35c4..7d09c8e7e6e93f65115115fe4417e8931d78a7f1 100644 (file)
@@ -115,6 +115,18 @@ template <>
 std::string
 locale_convert (boost::filesystem::path x, int, bool);
 
+template <>
+unsigned char
+locale_convert (std::string x, int, bool);
+
+template <>
+unsigned short int
+locale_convert (std::string x, int, bool);
+
+template <>
+unsigned int
+locale_convert (std::string x, int, bool);
+
 template <>
 int
 locale_convert (std::string x, int, bool);
index e1b909c085d52c935387007a7bbefb8b8459e183..f51a10f6806c6cbac22d2c92dc9a41f6045b6509 100644 (file)
@@ -168,6 +168,20 @@ dcp::raw_convert (wchar_t const * v, int, bool)
        return string (w.begin(), w.end());
 }
 
+template <>
+unsigned char
+dcp::raw_convert (std::string v, int precision, bool fixed)
+{
+       return locale_convert<unsigned char> (make_local (v), precision, fixed);
+}
+
+template <>
+unsigned short int
+dcp::raw_convert (std::string v, int precision, bool fixed)
+{
+       return locale_convert<unsigned short int> (make_local (v), precision, fixed);
+}
+
 template <>
 int
 dcp::raw_convert (string v, int precision, bool fixed)
index 90d94771f89c50546d79e9535945d3017b9e9f3b..4945c7f8bcc3f2f69f7d8ab88b2086579894804d 100644 (file)
@@ -112,6 +112,14 @@ template <>
 std::string
 raw_convert (char v, int, bool);
 
+template <>
+unsigned char
+raw_convert (std::string v, int, bool);
+
+template <>
+unsigned short int
+raw_convert (std::string v, int, bool);
+
 template <>
 int
 raw_convert (std::string v, int, bool);