From 3ad05d11dce653b33c6f0ea2d6cdba5a7e1bf4e5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 9 Oct 2018 14:53:10 +0100 Subject: [PATCH] More _convert functions. --- src/locale_convert.cc | 18 ++++++++++++++++++ src/locale_convert.h | 8 ++++++++ src/raw_convert.cc | 14 ++++++++++++++ src/raw_convert.h | 8 ++++++++ 4 files changed, 48 insertions(+) diff --git a/src/locale_convert.cc b/src/locale_convert.cc index 133c8a3a..0f0b5fa2 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) diff --git a/src/locale_convert.h b/src/locale_convert.h index ccce7b82..96309fd2 100644 --- a/src/locale_convert.h +++ b/src/locale_convert.h @@ -51,6 +51,14 @@ locale_convert (Q x, int precision = 16, bool fixed = false) BOOST_STATIC_ASSERT (sizeof (Q) == 0); } +template <> +std::string +locale_convert (unsigned char x, int, bool); + +template <> +std::string +locale_convert (unsigned short int x, int, bool); + template <> std::string locale_convert (int x, int, bool); diff --git a/src/raw_convert.cc b/src/raw_convert.cc index 35a57a52..e1b909c0 100644 --- a/src/raw_convert.cc +++ b/src/raw_convert.cc @@ -60,6 +60,20 @@ make_local (string v) return v; } +template <> +string +dcp::raw_convert (unsigned char v, int precision, bool fixed) +{ + return make_raw (locale_convert (v, precision, fixed)); +} + +template <> +string +dcp::raw_convert (unsigned short int v, int precision, bool fixed) +{ + return make_raw (locale_convert (v, precision, fixed)); +} + template <> string dcp::raw_convert (int v, int precision, bool fixed) diff --git a/src/raw_convert.h b/src/raw_convert.h index af2a1e37..90d94771 100644 --- a/src/raw_convert.h +++ b/src/raw_convert.h @@ -52,6 +52,14 @@ raw_convert (Q v, int precision = 16, bool fixed = false) BOOST_STATIC_ASSERT (sizeof (Q) == 0); } +template <> +std::string +raw_convert (unsigned char v, int, bool); + +template <> +std::string +raw_convert (unsigned short int v, int, bool); + template <> std::string raw_convert (int v, int, bool); -- 2.30.2