summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-10-09 19:20:01 +0100
committerCarl Hetherington <cth@carlh.net>2018-10-09 19:20:01 +0100
commit7930f7685811eb9e9f76651b6ef3dd9fe140b6fe (patch)
treedae8be03c59a7c722e3988cd98a6d8ea8c28c2e3 /src
parent7c47ecfd45bca468bf1a53f31d6f21cb00f73f26 (diff)
More raw/locale_convert.
Diffstat (limited to 'src')
-rw-r--r--src/locale_convert.cc27
-rw-r--r--src/locale_convert.h12
-rw-r--r--src/raw_convert.cc14
-rw-r--r--src/raw_convert.h8
4 files changed, 61 insertions, 0 deletions
diff --git a/src/locale_convert.cc b/src/locale_convert.cc
index 0f0b5fa2..5e7c350f 100644
--- a/src/locale_convert.cc
+++ b/src/locale_convert.cc
@@ -198,6 +198,33 @@ dcp::locale_convert (boost::filesystem::path x, int, bool)
}
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)
{
diff --git a/src/locale_convert.h b/src/locale_convert.h
index 96309fd2..7d09c8e7 100644
--- a/src/locale_convert.h
+++ b/src/locale_convert.h
@@ -116,6 +116,18 @@ 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);
diff --git a/src/raw_convert.cc b/src/raw_convert.cc
index e1b909c0..f51a10f6 100644
--- a/src/raw_convert.cc
+++ b/src/raw_convert.cc
@@ -169,6 +169,20 @@ dcp::raw_convert (wchar_t const * v, int, bool)
}
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)
{
diff --git a/src/raw_convert.h b/src/raw_convert.h
index 90d94771..4945c7f8 100644
--- a/src/raw_convert.h
+++ b/src/raw_convert.h
@@ -113,6 +113,14 @@ 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);