Boost.Locale
boundary_point.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_BOUNDARY_POINT_HPP_INCLUDED
8#define BOOST_LOCALE_BOUNDARY_BOUNDARY_POINT_HPP_INCLUDED
9
10#include <boost/locale/boundary/types.hpp>
11#include <string>
12
13namespace boost { namespace locale { namespace boundary {
14
17
43 template<typename IteratorType>
45 public:
47 typedef IteratorType iterator_type;
48
50 boundary_point() : rule_(0) {}
51
53 boundary_point(iterator_type p, rule_type r) : iterator_(p), rule_(r) {}
54
56 void iterator(iterator_type i) { iterator_ = i; }
58 iterator_type iterator() const { return iterator_; }
59
61 void rule(rule_type r) { rule_ = r; }
63 rule_type rule() const { return rule_; }
64
66 bool operator==(const boundary_point& other) const
67 {
68 return iterator_ == other.iterator_ && rule_ = other.rule_;
69 }
71 bool operator!=(const boundary_point& other) const { return !(*this == other); }
72
74 bool operator==(const iterator_type& other) const { return iterator_ == other; }
76 bool operator!=(const iterator_type& other) const { return iterator_ != other; }
77
79 operator iterator_type() const { return iterator_; }
80
81 private:
82 iterator_type iterator_;
83 rule_type rule_;
84 };
85
87 template<typename BaseIterator>
88 bool operator==(const BaseIterator& l, const boundary_point<BaseIterator>& r)
89 {
90 return r == l;
91 }
93 template<typename BaseIterator>
94 bool operator!=(const BaseIterator& l, const boundary_point<BaseIterator>& r)
95 {
96 return r != l;
97 }
98
100
103#ifndef BOOST_LOCALE_NO_CXX20_STRING8
105#endif
106#ifdef BOOST_LOCALE_ENABLE_CHAR16_T
108#endif
109#ifdef BOOST_LOCALE_ENABLE_CHAR32_T
111#endif
112
115#ifdef __cpp_char8_t
116 typedef boundary_point<const char8_t*> u8cboundary_point;
117#endif
118#ifdef BOOST_LOCALE_ENABLE_CHAR16_T
120#endif
121#ifdef BOOST_LOCALE_ENABLE_CHAR32_T
123#endif
124
125}}} // namespace boost::locale::boundary
126
127#endif
This class represents a boundary point in the text.
Definition: boundary_point.hpp:44
bool operator!=(const iterator_type &other) const
Check if the boundary point points to different location from an iterator other.
Definition: boundary_point.hpp:76
void iterator(iterator_type i)
Set an new iterator value i.
Definition: boundary_point.hpp:56
rule_type rule() const
Fetch a rule.
Definition: boundary_point.hpp:63
boundary_point(iterator_type p, rule_type r)
Create a new boundary_point using iterator and a rule r.
Definition: boundary_point.hpp:53
void rule(rule_type r)
Set an new rule value r.
Definition: boundary_point.hpp:61
bool operator!=(const boundary_point &other) const
Check if two boundary points are different.
Definition: boundary_point.hpp:71
bool operator==(const iterator_type &other) const
Check if the boundary point points to same location as an iterator other.
Definition: boundary_point.hpp:74
iterator_type iterator() const
Fetch an iterator.
Definition: boundary_point.hpp:58
boundary_point()
Empty default constructor.
Definition: boundary_point.hpp:50
IteratorType iterator_type
The type of the base iterator that iterates the original text.
Definition: boundary_point.hpp:47
bool operator==(const boundary_point &other) const
Check if two boundary points are the same.
Definition: boundary_point.hpp:66
uint32_t rule_type
Flags used with word boundary analysis – the type of the word, line or sentence boundary found.
Definition: types.hpp:40
bool operator!=(const BaseIterator &l, const boundary_point< BaseIterator > &r)
Check if the boundary point r points to different location from an iterator l.
Definition: boundary_point.hpp:94
bool operator==(const BaseIterator &l, const boundary_point< BaseIterator > &r)
Check if the boundary point r points to same location as an iterator l.
Definition: boundary_point.hpp:88
boundary_point< std::u8string::const_iterator > u8sboundary_point
convenience typedef
Definition: boundary_point.hpp:104
boundary_point< std::u16string::const_iterator > u16sboundary_point
convenience typedef
Definition: boundary_point.hpp:107
boundary_point< std::wstring::const_iterator > wsboundary_point
convenience typedef
Definition: boundary_point.hpp:102
boundary_point< const char32_t * > u32cboundary_point
convenience typedef
Definition: boundary_point.hpp:122
boundary_point< const char16_t * > u16cboundary_point
convenience typedef
Definition: boundary_point.hpp:119
boundary_point< const char * > cboundary_point
convenience typedef
Definition: boundary_point.hpp:113
boundary_point< std::u32string::const_iterator > u32sboundary_point
convenience typedef
Definition: boundary_point.hpp:110
boundary_point< const wchar_t * > wcboundary_point
convenience typedef
Definition: boundary_point.hpp:114
boundary_point< std::string::const_iterator > sboundary_point
convenience typedef
Definition: boundary_point.hpp:101
@ boundary
Generate boundary analysis facet.