Boost.Locale: boost/locale/util.hpp Source File

| Boost.Locale

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List

util.hpp
1 //
2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOST_LOCALE_UTIL_HPP
9 #define BOOST_LOCALE_UTIL_HPP
10 #include <locale>
11 #include <typeinfo>
12 #include <boost/cstdint.hpp>
13 #include <boost/locale/utf.hpp>
14 #include <boost/locale/generator.hpp>
15 #include <boost/assert.hpp>
16
17 #include <vector>
18 namespace boost {
19 namespace locale {
24 namespace util {
25
39 BOOST_LOCALE_DECL
40 std::string get_system_locale(bool use_utf8_on_windows = false);
41
59 BOOST_LOCALE_DECL
60 std::locale create_info(std::locale const &in,std::string const &name);
61
62
77 class base_converter {
78 public:
79
85 static const uint32_t illegal=utf::illegal;
86
91 static const uint32_t incomplete=utf::incomplete;
92
93 virtual ~base_converter()
94 {
95 }
100 virtual int max_len() const
101 {
102 return 1;
103 }
113 virtual bool is_thread_safe() const
114 {
115 return false;
116 }
120 virtual base_converter *clone() const
121 {
122 BOOST_ASSERT(typeid(*this)==typeid(base_converter));
123 return new base_converter();
124 }
125
141 virtual uint32_t to_unicode(char const *&begin,char const *end)
142 {
143 if(begin == end)
144 return incomplete;
145 unsigned char cp = *begin;
146 if(cp <= 0x7F) {
147 begin++;
148 return cp;
149 }
150 return illegal;
151 }
163
164 virtual uint32_t from_unicode(uint32_t u,char *begin,char const *end)
165 {
166 if(begin==end)
167 return incomplete;
168 if(u >= 0x80)
169 return illegal;
170 *begin = static_cast<char>(u);
171 return 1;
172 }
173 };
174
179 BOOST_LOCALE_DECL std::auto_ptr<base_converter> create_utf8_converter();
187 BOOST_LOCALE_DECL std::auto_ptr<base_converter> create_simple_converter(std::string const &encoding);
188
189
201 BOOST_LOCALE_DECL
202 std::locale create_codecvt(std::locale const &in,std::auto_ptr<base_converter> cvt,character_facet_type type);
203
208 BOOST_LOCALE_DECL
209 std::locale create_utf8_codecvt(std::locale const &in,character_facet_type type);
210
217 BOOST_LOCALE_DECL
218 std::locale create_simple_codecvt(std::locale const &in,std::string const &encoding,character_facet_type type);
219 } // util
220 } // locale
221 } // boost
222
223 #endif
224 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
boost::locale::util::base_converter::is_thread_safe
virtual bool is_thread_safe() const
Definition: util.hpp:113
boost::locale::util::base_converter::max_len
virtual int max_len() const
Definition: util.hpp:100
boost::locale::util::base_converter::incomplete
static const uint32_t incomplete
Definition: util.hpp:91
boost::locale::utf::incomplete
static const code_point incomplete
Special constant that defines incomplete code point.
Definition: utf.hpp:44
boost::locale::util::base_converter::to_unicode
virtual uint32_t to_unicode(char const *&begin, char const *end)
Definition: util.hpp:141
boost::locale::util::create_info
std::locale create_info(std::locale const &in, std::string const &name)
Installs information facet to locale in based on locale name name.
boost::locale::util::create_codecvt
std::locale create_codecvt(std::locale const &in, std::auto_ptr< base_converter > cvt, character_facet_type type)
boost::locale::character_facet_type
uint32_t character_facet_type
type that specifies the character type that locales can be generated for
Definition: generator.hpp:43
boost::locale::utf::illegal
static const code_point illegal
Special constant that defines illegal code point.
Definition: utf.hpp:39
boost::locale::util::create_utf8_converter
std::auto_ptr< base_converter > create_utf8_converter()
boost::locale::util::base_converter
This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point...
Definition: util.hpp:77
boost::locale::util::base_converter::clone
virtual base_converter * clone() const
Definition: util.hpp:120
boost::locale::util::get_system_locale
std::string get_system_locale(bool use_utf8_on_windows=false)
Return default system locale name in POSIX format.
boost::locale::util::base_converter::illegal
static const uint32_t illegal
Definition: util.hpp:85
boost::locale::util::create_simple_converter
std::auto_ptr< base_converter > create_simple_converter(std::string const &encoding)
boost::locale::util::create_simple_codecvt
std::locale create_simple_codecvt(std::locale const &in, std::string const &encoding, character_facet_type type)
boost::locale::util::base_converter::from_unicode
virtual uint32_t from_unicode(uint32_t u, char *begin, char const *end)
Definition: util.hpp:164
boost::locale::util::create_utf8_codecvt
std::locale create_utf8_codecvt(std::locale const &in, character_facet_type type)
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.