diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-01 14:08:56 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-01 20:51:21 +0100 |
| commit | c90d68049f56110436927aa847da882ee4b4f67c (patch) | |
| tree | 1a1b8ee748d40a76c6e99fdf12e3da3306df7c4e /src/raw_convert.cc | |
| parent | 68533f20f9f2e0ca9efc9360f20d047a79e4fd8a (diff) | |
Replace raw_convert<string> with direct calls to fmt.v1.10.3
Diffstat (limited to 'src/raw_convert.cc')
| -rw-r--r-- | src/raw_convert.cc | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/src/raw_convert.cc b/src/raw_convert.cc index eeab0dad..7bb703fb 100644 --- a/src/raw_convert.cc +++ b/src/raw_convert.cc @@ -33,7 +33,6 @@ #include "raw_convert.h" -#include <fmt/format.h> #include <fast_float/fast_float.h> #include <boost/algorithm/string.hpp> @@ -42,153 +41,6 @@ using std::string; using std::wstring; -template <> -string -dcp::raw_convert(unsigned char v, int, bool) -{ - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert(unsigned short int v, int, bool) -{ - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert(int v, int, bool) -{ - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert(unsigned int v, int, bool) -{ - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert(long v, int, bool) -{ - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert(unsigned long v, int, bool) -{ - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert(long long v, int, bool) -{ - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert(unsigned long long v, int, bool) -{ - return fmt::to_string(v); -} - - -static -void -make_format_string(char* buffer, int buffer_length, int precision, bool fixed) -{ - if (fixed) { - snprintf(buffer, buffer_length, "{:.%df}", precision); - } else { - snprintf(buffer, buffer_length, "{:.%d}", precision); - } -} - - -template <> -string -dcp::raw_convert (float v, int precision, bool fixed) -{ - if (precision < 16) { - char format[16]; - make_format_string(format, 16, precision, fixed); - return fmt::format(format, v); - } - - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert (double v, int precision, bool fixed) -{ - if (precision < 16) { - char format[16]; - make_format_string(format, 16, precision, fixed); - return fmt::format(format, v); - } - - return fmt::to_string(v); -} - - -template <> -string -dcp::raw_convert (char const * v, int, bool) -{ - return v; -} - - -template <> -string -dcp::raw_convert (char* v, int, bool) -{ - return v; -} - - -template <> -string -dcp::raw_convert (string v, int, bool) -{ - return v; -} - - -template <> -string -dcp::raw_convert (char v, int, bool) -{ - string s; - s += v; - return s; -} - - -template <> -string -dcp::raw_convert (wchar_t const * v, int, bool) -{ - wstring w (v); - return string (w.begin(), w.end()); -} - - template <typename T> T convert_with_fast_float(string v) |
