Boost.Locale: boost/locale/boundary/facets.hpp Source File

| Boost.Locale

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

- File List

facets.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_BOUNDARY_FACETS_HPP_INCLUDED
9 #define BOOST_LOCALE_BOUNDARY_FACETS_HPP_INCLUDED
10
11 #include <boost/locale/config.hpp>
12 #include <boost/locale/boundary/types.hpp>
13 #ifdef BOOST_MSVC
14 # pragma warning(push)
15 # pragma warning(disable : 4275 4251 4231 4660)
16 #endif
17 #include <locale>
18 #include <vector>
19
20
21
22
23 namespace boost {
24
25 namespace locale {
26
30 namespace boundary {
36
37
42 struct break_info {
43
47 break_info() :
48 offset(0),
49 rule(0)
50 {
51 }
56 break_info(size_t v) :
57 offset(v),
58 rule(0)
59 {
60 }
61
65 size_t offset;
70 rule_type rule;
71
76 bool operator<(break_info const &other) const
77 {
78 return offset < other.offset;
79 }
80 };
81
86 typedef std::vector<break_info> index_type;
87
88
89 template<typename CharType>
90 class boundary_indexing;
91
92 #ifdef BOOST_LOCALE_DOXYGEN
93 template<typename Char>
100 class BOOST_LOCALE_DECL boundary_indexing : public std::locale::facet {
101 public:
105 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
106 {
107 }
115 virtual index_type map(boundary_type t,Char const *begin,Char const *end) const = 0;
119 static std::locale::id id;
120
121 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
122 std::locale::id& __get_id (void) const { return id; }
123 #endif
124 };
125
126 #else
127
128 template<>
129 class BOOST_LOCALE_DECL boundary_indexing<char> : public std::locale::facet {
130 public:
131 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
132 {
133 }
134 virtual index_type map(boundary_type t,char const *begin,char const *end) const = 0;
135 static std::locale::id id;
136 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
137 std::locale::id& __get_id (void) const { return id; }
138 #endif
139 };
140
141 template<>
142 class BOOST_LOCALE_DECL boundary_indexing<wchar_t> : public std::locale::facet {
143 public:
144 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
145 {
146 }
147 virtual index_type map(boundary_type t,wchar_t const *begin,wchar_t const *end) const = 0;
148
149 static std::locale::id id;
150 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
151 std::locale::id& __get_id (void) const { return id; }
152 #endif
153 };
154
155 #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
156 template<>
157 class BOOST_LOCALE_DECL boundary_indexing<char16_t> : public std::locale::facet {
158 public:
159 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
160 {
161 }
162 virtual index_type map(boundary_type t,char16_t const *begin,char16_t const *end) const = 0;
163 static std::locale::id id;
164 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
165 std::locale::id& __get_id (void) const { return id; }
166 #endif
167 };
168 #endif
169
170 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
171 template<>
172 class BOOST_LOCALE_DECL boundary_indexing<char32_t> : public std::locale::facet {
173 public:
174 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
175 {
176 }
177 virtual index_type map(boundary_type t,char32_t const *begin,char32_t const *end) const = 0;
178 static std::locale::id id;
179 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
180 std::locale::id& __get_id (void) const { return id; }
181 #endif
182 };
183 #endif
184
185 #endif
186
190
191
192 } // boundary
193
194 } // locale
195 } // boost
196
197
198 #ifdef BOOST_MSVC
199 #pragma warning(pop)
200 #endif
201
202 #endif
203 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
boost::locale::boundary::boundary_indexing
This facet generates an index for boundary analysis for a given text.
Definition: facets.hpp:90
boost::locale::boundary::boundary_type
boundary_type
Definition: types.hpp:39
boost::locale::boundary::break_info::break_info
break_info()
Definition: facets.hpp:47
boost::locale::boundary::break_info::break_info
break_info(size_t v)
Definition: facets.hpp:56
boost::locale::boundary::boundary_indexing::id
static std::locale::id id
Definition: facets.hpp:119
boost::locale::boundary::break_info
This structure is used for representing boundary point that follows the offset.
Definition: facets.hpp:42
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:51
boost::locale::boundary::break_info::operator<
bool operator<(break_info const &other) const
Definition: facets.hpp:76
boost::locale::boundary::break_info::rule
rule_type rule
Definition: facets.hpp:70
boost::locale::boundary::break_info::offset
size_t offset
Definition: facets.hpp:65
boost::locale::boundary::boundary_indexing::boundary_indexing
boundary_indexing(size_t refs=0)
Definition: facets.hpp:105
boost::locale::boundary::index_type
std::vector< break_info > index_type
Definition: facets.hpp:86
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.