| Boost.Locale

facets.hpp
1//
2// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3//
4// Distributed under the Boost Software License, Version 1.0.
5// https://www.boost.org/LICENSE_1_0.txt
6
7#ifndef BOOST_LOCALE_BOUNDARY_FACETS_HPP_INCLUDED
8#define BOOST_LOCALE_BOUNDARY_FACETS_HPP_INCLUDED
9
10#include <boost/locale/boundary/types.hpp>
11#include <boost/locale/detail/facet_id.hpp>
12#include <boost/locale/detail/is_supported_char.hpp>
13#include <locale>
14#include <vector>
15
16#ifdef BOOST_MSVC
17# pragma warning(push)
18# pragma warning(disable : 4275 4251 4231 4660)
19#endif
20
21 namespace boost { namespace locale {
22
24 namespace boundary {
28
31 struct break_info {
33 break_info() : offset(0), rule(0) {}
34
37 break_info(size_t v) : offset(v), rule(0) {}
38
40 size_t offset;
43 rule_type rule;
44
47 bool operator<(const break_info& other) const { return offset < other.offset; }
48 };
49
52 typedef std::vector<break_info> index_type;
53
57 template<typename Char>
58 class BOOST_SYMBOL_VISIBLE boundary_indexing : public std::locale::facet,
59 public boost::locale::detail::facet_id<boundary_indexing<Char>> {
60 BOOST_LOCALE_ASSERT_IS_SUPPORTED(Char);
61
62 public:
64 boundary_indexing(size_t refs = 0) : std::locale::facet(refs) {}
65
71 virtual index_type map(boundary_type t, const Char* begin, const Char* end) const = 0;
72 };
73
75 } // namespace boundary
76
77}} // namespace boost::locale
78
79#ifdef BOOST_MSVC
80# pragma warning(pop)
81#endif
82
83#endif
boost::locale::boundary::boundary_indexing
This facet generates an index for boundary analysis of a given text.
Definition: facets.hpp:59
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::map
virtual index_type map(boundary_type t, const Char *begin, const Char *end) const =0
boost::locale::boundary::boundary_type
boundary_type
This type describes a possible boundary analysis alternatives.
Definition: types.hpp:30
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::index_type
std::vector< break_info > index_type
Definition: facets.hpp:52
boost::locale::category_t::boundary
@ boundary
Generate boundary analysis facet.
boost::locale::boundary::break_info
This structure is used for representing boundary points that follow the offset.
Definition: facets.hpp:31
boost::locale::boundary::break_info::operator<
bool operator<(const break_info &other) const
Definition: facets.hpp:47
boost::locale::boundary::break_info::rule
rule_type rule
Definition: facets.hpp:43
boost::locale::boundary::break_info::break_info
break_info()
Create empty break point at beginning.
Definition: facets.hpp:33
boost::locale::boundary::break_info::offset
size_t offset
Offset from the beginning of the text where a break occurs.
Definition: facets.hpp:40
boost::locale::boundary::break_info::break_info
break_info(size_t v)
Definition: facets.hpp:37
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.