util.hpp
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
//
// 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_UTIL_HPP
#define BOOST_LOCALE_UTIL_HPP
#include <locale>
#include <typeinfo>
#include <boost/cstdint.hpp>
#include <boost/locale/utf.hpp>
#include <boost/locale/generator.hpp>
#include <boost/assert.hpp>
#include <vector>
namespace boost {
namespace locale {
namespace util {
BOOST_LOCALE_DECL
std::string get_system_locale(bool use_utf8_on_windows = false);
BOOST_LOCALE_DECL
std::locale create_info(std::locale const &in,std::string const &name);
class base_converter {
public:
static const uint32_t illegal=utf::illegal;
static const uint32_t incomplete=utf::incomplete;
virtual ~base_converter()
{
}
virtual int max_len() const
{
return 1;
}
virtual bool is_thread_safe() const
{
return false;
}
virtual base_converter *clone() const
{
BOOST_ASSERT(typeid(*this)==typeid(base_converter));
return new base_converter();
}
virtual uint32_t to_unicode(char const *&begin,char const *end)
{
if(begin == end)
return incomplete;
unsigned char cp = *begin;
if(cp <= 0x7F) {
begin++;
return cp;
}
return illegal;
}
virtual uint32_t from_unicode(uint32_t u,char *begin,char const *end)
{
if(begin==end)
return incomplete;
if(u >= 0x80)
return illegal;
*begin = static_cast<char>(u);
return 1;
}
};
BOOST_LOCALE_DECL std::auto_ptr<base_converter> create_utf8_converter();
BOOST_LOCALE_DECL std::auto_ptr<base_converter> create_simple_converter(std::string const &encoding);
BOOST_LOCALE_DECL
std::locale create_codecvt(std::locale const &in,std::auto_ptr<base_converter> cvt,character_facet_type type);
BOOST_LOCALE_DECL
std::locale create_utf8_codecvt(std::locale const &in,character_facet_type type);
BOOST_LOCALE_DECL
std::locale create_simple_codecvt(std::locale const &in,std::string const &encoding,character_facet_type type);
} // util
} // locale
} // boost
#endif
// 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.