crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
CommaLocale.hpp
Go to the documentation of this file.
1 /*
2  *
3  * ---
4  *
5  * Copyright (C) 2022 Anselm Schmidt (ans[ät]ohai.su)
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version in addition to the terms of any
11  * licences already herein identified.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  *
21  * ---
22  *
23  * CommaLocale.hpp
24  *
25  * Locale using commas as thousands separators.
26  *
27  * Created on: Aug 14, 2021
28  * Author: ans
29  */
30 
31 #ifndef COMMALOCALE_HPP_
32 #define COMMALOCALE_HPP_
33 
34 #include <locale> // std::locale, std::numpunct
35 #include <string> // std::string
36 
37 namespace crawlservpp::Helper {
38 
39  class CommaLocale : public std::numpunct<char> {
40  public:
41  CommaLocale() = default;
42  virtual ~CommaLocale() = default;
43 
44  static inline std::locale locale() {
45  return std::locale{std::locale(), new CommaLocale()};
46  }
47 
48  protected:
49  virtual char do_thousands_sep() const {
50  return ',';
51  }
52 
53  virtual std::string do_grouping() const {
54  return "\03";
55  }
56  };
57 
58 } /* namespace crawlservpp::Helper */
59 
60 #endif /* COMMALOCALE_HPP_ */
static std::locale locale()
Definition: CommaLocale.hpp:44
virtual char do_thousands_sep() const
Definition: CommaLocale.hpp:49
virtual std::string do_grouping() const
Definition: CommaLocale.hpp:53
Namespace for global helper functions.
Definition: CommaLocale.hpp:39