-
-
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 77d1e5c
Showing
7 changed files
with
143 additions
and
32 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,77 @@ | ||
// | ||
// 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 numpunct; | ||
|
||
template<typename CharType> | ||
class BOOST_LOCALE_DECL numpunct : public std::locale::facet | ||
{ | ||
typedef std::basic_string<CharType> string_type; | ||
public: | ||
static inline std::locale::id id; | ||
|
||
numpunct (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(); | ||
} | ||
|
||
string_type 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); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
#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
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,14 @@ | ||
#include <iostream> | ||
#include "boost/locale.hpp" | ||
|
||
int main(int argc, char **argv) { | ||
const char *lang = ""; | ||
if (argc > 1) { | ||
lang = argv[1]; | ||
} | ||
boost::locale::generator gen; | ||
std::locale loc = gen(lang); | ||
|
||
auto &facet = std::use_facet<boost::locale::numpunct<char>>(loc); | ||
std::cout << facet.decimal_point() << ' ' << facet.thousands_sep() << '\n'; | ||
} |