facets.hpp
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_LOCALE_BOUNDARY_FACETS_HPP_INCLUDED
#define BOOST_LOCALE_BOUNDARY_FACETS_HPP_INCLUDED
#include <boost/locale/boundary/types.hpp>
#include <locale>
#include <vector>
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4275 4251 4231 4660)
#endif
namespace boost { namespace locale {
namespace boundary {
struct break_info {
break_info() : offset(0), rule(0) {}
break_info(size_t v) : offset(v), rule(0) {}
size_t offset;
rule_type rule;
bool operator<(const break_info& other) const { return offset < other.offset; }
};
typedef std::vector<break_info> index_type;
template<typename CharType>
class boundary_indexing;
#ifdef BOOST_LOCALE_DOXYGEN
template<typename Char>
class BOOST_LOCALE_DECL boundary_indexing : public std::locale::facet {
public:
boundary_indexing(size_t refs = 0) : std::locale::facet(refs) {}
virtual index_type map(boundary_type t, const Char* begin, const Char* end) const = 0;
static std::locale::id id;
};
#else
template<>
class BOOST_LOCALE_DECL boundary_indexing<char> : public std::locale::facet {
public:
boundary_indexing(size_t refs = 0) : std::locale::facet(refs) {}
~boundary_indexing();
virtual index_type map(boundary_type t, const char* begin, const char* end) const = 0;
static std::locale::id id;
};
template<>
class BOOST_LOCALE_DECL boundary_indexing<wchar_t> : public std::locale::facet {
public:
boundary_indexing(size_t refs = 0) : std::locale::facet(refs) {}
~boundary_indexing();
virtual index_type map(boundary_type t, const wchar_t* begin, const wchar_t* end) const = 0;
static std::locale::id id;
};
# ifdef BOOST_LOCALE_ENABLE_CHAR16_T
template<>
class BOOST_LOCALE_DECL boundary_indexing<char16_t> : public std::locale::facet {
public:
boundary_indexing(size_t refs = 0) : std::locale::facet(refs) {}
~boundary_indexing();
virtual index_type map(boundary_type t, const char16_t* begin, const char16_t* end) const = 0;
static std::locale::id id;
};
# endif
# ifdef BOOST_LOCALE_ENABLE_CHAR32_T
template<>
class BOOST_LOCALE_DECL boundary_indexing<char32_t> : public std::locale::facet {
public:
boundary_indexing(size_t refs = 0) : std::locale::facet(refs) {}
~boundary_indexing();
virtual index_type map(boundary_type t, const char32_t* begin, const char32_t* end) const = 0;
static std::locale::id id;
};
# endif
#endif
} // namespace boundary
}} // namespace boost::locale
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
#endif
boost::locale::boundary::boundary_indexing
This facet generates an index for boundary analysis for a given text.
Definition: facets.hpp:53
boost::locale::boundary::boundary_type
boundary_type
This type describes a possible boundary analysis alternatives.
Definition: types.hpp:30
boost::locale::boundary::break_info::break_info
break_info()
Create empty break point at beginning.
Definition: facets.hpp:31
boost::locale::boundary::break_info::break_info
break_info(size_t v)
Definition: facets.hpp:35
boost::locale::boundary::break_info
This structure is used for representing boundary points that follow the offset.
Definition: facets.hpp:29
boost::locale::boundary::rule_type
uint32_t rule_type
Flags used with word boundary analysis – the type of the word, line or sentence boundary found.
Definition: types.hpp:40
boost::locale::boundary::break_info::operator<
bool operator<(const break_info &other) const
Definition: facets.hpp:45
boost::locale::boundary::break_info::rule
rule_type rule
Definition: facets.hpp:41
boost::locale::boundary::boundary_indexing::boundary_indexing
boundary_indexing(size_t refs=0)
Default constructor typical for facets.
Definition: facets.hpp:64
boost::locale::boundary::boundary_indexing::id
static std::locale::id id
Identification of this facet.
Definition: facets.hpp:74
boost::locale::boundary::break_info::offset
size_t offset
Offset from the beginning of the text where a break occurs.
Definition: facets.hpp:38
boost::locale::category_t::boundary
Generate boundary analysis facet.
boost::locale::boundary::index_type
std::vector< break_info > index_type
Definition: facets.hpp:50
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.