diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-10-09 14:53:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-10-09 14:53:10 +0100 |
| commit | 3ad05d11dce653b33c6f0ea2d6cdba5a7e1bf4e5 (patch) | |
| tree | 4ecb0f405f61e38e87049194f52b0980d06e18c6 | |
| parent | 6ff5bc54fafcb9332609912514c287ac332ab7e5 (diff) | |
More _convert functions.
| -rw-r--r-- | src/locale_convert.cc | 18 | ||||
| -rw-r--r-- | src/locale_convert.h | 8 | ||||
| -rw-r--r-- | src/raw_convert.cc | 14 | ||||
| -rw-r--r-- | src/raw_convert.h | 8 |
4 files changed, 48 insertions, 0 deletions
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 @@ -40,6 +40,24 @@ 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) { char buffer[64]; 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 @@ -53,6 +53,14 @@ locale_convert (Q x, int precision = 16, bool fixed = false) 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); template <> 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 @@ -62,6 +62,20 @@ make_local (string v) template <> string +dcp::raw_convert (unsigned char v, int precision, bool fixed) +{ + return make_raw (locale_convert<string> (v, precision, fixed)); +} + +template <> +string +dcp::raw_convert (unsigned short int v, int precision, bool fixed) +{ + return make_raw (locale_convert<string> (v, precision, fixed)); +} + +template <> +string dcp::raw_convert (int v, int precision, bool fixed) { return make_raw (locale_convert<string> (v, precision, 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 @@ -54,6 +54,14 @@ raw_convert (Q v, int precision = 16, bool fixed = false) 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); template <> |
