diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-08-15 13:25:45 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-08-15 13:25:45 +0100 |
| commit | ce66af3d9056d2b8de6d5b2f8ce0caa100a66dec (patch) | |
| tree | e259a0285662cadf6fba0b9dc4859d19701ca65f /src | |
| parent | 886a2080dd9aa90fff8a567b0e4df43b737e36c6 (diff) | |
Hack.
Diffstat (limited to 'src')
| -rw-r--r-- | src/locale_convert.cc | 26 | ||||
| -rw-r--r-- | src/locale_convert.h | 12 | ||||
| -rw-r--r-- | src/raw_convert.cc | 14 | ||||
| -rw-r--r-- | src/raw_convert.h | 8 |
4 files changed, 54 insertions, 6 deletions
diff --git a/src/locale_convert.cc b/src/locale_convert.cc index 3858006e..1a25ceeb 100644 --- a/src/locale_convert.cc +++ b/src/locale_convert.cc @@ -39,19 +39,37 @@ using std::string; template<> string -dcp::locale_convert (int x, int, bool) +dcp::locale_convert (int16_t x, int, bool) { char buffer[64]; - snprintf (buffer, sizeof(buffer), "%d", x); + snprintf (buffer, sizeof(buffer), "%" PRId16, x); return buffer; } template<> string -dcp::locale_convert (unsigned int x, int, bool) +dcp::locale_convert (uint16_t x, int, bool) { char buffer[64]; - snprintf (buffer, sizeof(buffer), "%ud", x); + snprintf (buffer, sizeof(buffer), "%" PRIu16, x); + return buffer; +} + +template<> +string +dcp::locale_convert (int32_t x, int, bool) +{ + char buffer[64]; + snprintf (buffer, sizeof(buffer), "%" PRId32, x); + return buffer; +} + +template<> +string +dcp::locale_convert (uint32_t x, int, bool) +{ + char buffer[64]; + snprintf (buffer, sizeof(buffer), "%" PRIu32, x); return buffer; } diff --git a/src/locale_convert.h b/src/locale_convert.h index f7552f68..be99e70f 100644 --- a/src/locale_convert.h +++ b/src/locale_convert.h @@ -53,11 +53,19 @@ locale_convert (Q x, int precision = 16, bool fixed = false) template <> std::string -locale_convert (int x, int, bool); +locale_convert (int16_t x, int, bool); template <> std::string -locale_convert (unsigned int x, int, bool); +locale_convert (uint16_t x, int, bool); + +template <> +std::string +locale_convert (int32_t x, int, bool); + +template <> +std::string +locale_convert (uint32_t x, int, bool); template <> std::string diff --git a/src/raw_convert.cc b/src/raw_convert.cc index 09523b54..9be10b98 100644 --- a/src/raw_convert.cc +++ b/src/raw_convert.cc @@ -59,6 +59,20 @@ make_local (string v) template <> string +dcp::raw_convert (int16_t v, int precision, bool fixed) +{ + return make_raw (locale_convert<string> (v, precision, fixed)); +} + +template <> +string +dcp::raw_convert (uint16_t v, int precision, bool fixed) +{ + return make_raw (locale_convert<string> (v, precision, fixed)); +} + +template <> +string dcp::raw_convert (int32_t 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 4a77b6a0..ecae19d5 100644 --- a/src/raw_convert.h +++ b/src/raw_convert.h @@ -55,6 +55,14 @@ raw_convert (Q v, int precision = 16, bool fixed = false) template <> std::string +raw_convert (int16_t v, int, bool); + +template <> +std::string +raw_convert (uint16_t v, int, bool); + +template <> +std::string raw_convert (int32_t v, int, bool); template <> |
