From c9a79405c38ef596a821a4db9955a33f4437b9d3 Mon Sep 17 00:00:00 2001 From: cah Date: Mon, 13 Jan 2020 14:24:04 +0100 Subject: Add some new conversions. --- src/cxml.cc | 44 ++++++++++++++++++++++++++++++++++++++++++-- src/cxml.h | 8 ++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cxml.cc b/src/cxml.cc index a51b9a4..667da55 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -349,6 +349,19 @@ locale_convert (string x) return y; } +template<> +long unsigned int +locale_convert (string x) +{ + long unsigned int y = 0; +#ifdef LIBCXML_WINDOWS + __mingw_sscanf (x.c_str(), "%lud", &y); +#else + sscanf (x.c_str(), "%lud", &y); +#endif + return y; +} + template<> long long locale_convert (string x) @@ -362,6 +375,19 @@ locale_convert (string x) return y; } +template<> +long long unsigned +locale_convert (string x) +{ + long long unsigned y = 0; +#ifdef LIBCXML_WINDOWS + __mingw_sscanf (x.c_str(), "%llud", &y); +#else + sscanf (x.c_str(), "%llud", &y); +#endif + return y; +} + template<> float locale_convert (string x) @@ -387,6 +413,13 @@ cxml::raw_convert (string v) return locale_convert (make_local(v)); } +template <> +unsigned int +cxml::raw_convert (string v) +{ + return locale_convert (make_local(v)); +} + template <> long int cxml::raw_convert (string v) @@ -394,6 +427,13 @@ cxml::raw_convert (string v) return locale_convert (make_local(v)); } +template <> +long unsigned int +cxml::raw_convert (string v) +{ + return locale_convert (make_local(v)); +} + template <> long long cxml::raw_convert (string v) @@ -402,10 +442,10 @@ cxml::raw_convert (string v) } template <> -unsigned int +long long unsigned cxml::raw_convert (string v) { - return locale_convert (make_local(v)); + return locale_convert (make_local(v)); } template <> diff --git a/src/cxml.h b/src/cxml.h index bd04af1..b6f2c63 100644 --- a/src/cxml.h +++ b/src/cxml.h @@ -90,10 +90,18 @@ template <> long int raw_convert (std::string v); +template <> +long unsigned int +raw_convert (std::string v); + template <> long long raw_convert (std::string v); +template <> +long long unsigned +raw_convert (std::string v); + template <> float raw_convert (std::string v); -- cgit v1.2.3