-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5789ae2
commit d1598d3
Showing
6 changed files
with
164 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// Copyright (c) 2021-2021 Salvo Miosi | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See | ||
// accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
|
||
#ifndef BOOST_LOCALE_NUMPUNCT_HPP_INCLUDED | ||
#define BOOST_LOCALE_NUMPUNCT_HPP_INCLUDED | ||
#include <boost/locale/config.hpp> | ||
#ifdef BOOST_MSVC | ||
# pragma warning(push) | ||
# pragma warning(disable : 4275 4251 4231 4660) | ||
#endif | ||
#include <locale> | ||
#include <string> | ||
|
||
namespace boost { | ||
namespace locale { | ||
|
||
template<typename CharType> | ||
class BOOST_LOCALE_DECL numpunct_base : public std::locale::facet | ||
{ | ||
typedef std::basic_string<CharType> string_type; | ||
public: | ||
numpunct_base(size_t refs = 0) : std::locale::facet(refs) {} | ||
|
||
string_type decimal_point() const { | ||
return do_decimal_point(); | ||
} | ||
|
||
string_type thousands_sep() const { | ||
return do_thousands_sep(); | ||
} | ||
|
||
std::string grouping() const { | ||
return do_grouping(); | ||
} | ||
|
||
string_type truename() const { | ||
return do_truename(); | ||
} | ||
|
||
string_type falsename() const { | ||
return do_falsename(); | ||
} | ||
|
||
protected: | ||
virtual string_type do_decimal_point() const { | ||
static const char t[] = "."; | ||
return string_type(t, t + sizeof(t) - 1); | ||
} | ||
virtual string_type do_thousands_sep() const { | ||
static const char t[] = ","; | ||
return string_type(t, t + sizeof(t) - 1); | ||
} | ||
virtual std::string do_grouping() const { | ||
return ""; | ||
} | ||
virtual string_type do_truename() const { | ||
static const char t[] = "true"; | ||
return string_type(t, t + sizeof(t) - 1); | ||
} | ||
virtual string_type do_falsename() const { | ||
static const char t[] = "false"; | ||
return string_type(t, t + sizeof(t) - 1); | ||
} | ||
}; | ||
|
||
template<typename CharType> struct numpunct {}; | ||
|
||
template<> struct numpunct<char> : numpunct_base<char> { | ||
static std::locale::id id; | ||
|
||
numpunct (size_t refs = 0) : numpunct_base<char>(refs) {} | ||
}; | ||
|
||
template<> struct numpunct<wchar_t> : numpunct_base<wchar_t> { | ||
static std::locale::id id; | ||
|
||
numpunct (size_t refs = 0) : numpunct_base<wchar_t>(refs) {} | ||
}; | ||
|
||
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T | ||
template<> struct numpunct<char16_t> : numpunct_base<char16_t> { | ||
static std::locale::id id; | ||
|
||
numpunct (size_t refs = 0) : numpunct_base<char16_t>(refs) {} | ||
}; | ||
#endif | ||
#ifdef BOOST_LOCALE_ENABLE_CHAR32_T | ||
template<> struct numpunct<char32_t> : numpunct_base<char32_t> { | ||
static std::locale::id id; | ||
|
||
numpunct (size_t refs = 0) : numpunct_base<char32_t>(refs) {} | ||
}; | ||
#endif | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters