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 
13 namespace 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 #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
105 #endif
106 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
108 #endif
109 
112 #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
114 #endif
115 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
117 #endif
118 
119 }}} // namespace boost::locale::boundary
120 
121 #endif
boundary_point< const wchar_t * > wcboundary_point
convenience typedef
Definition: boundary_point.hpp:111
bool operator!=(const boundary_point &other) const
Check if two boundary points are different.
Definition: boundary_point.hpp:71
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 the same.
Definition: boundary_point.hpp:66
iterator_type iterator() const
Fetch an iterator.
Definition: boundary_point.hpp:58
rule_type rule() const
Fetch a rule.
Definition: boundary_point.hpp:63
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
uint32_t rule_type
Flags used with word boundary analysis – the type of the word, line or sentence boundary found.
Definition: types.hpp:40
boundary_point< std::string::const_iterator > sboundary_point
convenience typedef
Definition: boundary_point.hpp:101
boundary_point< const char32_t * > u32cboundary_point
convenience typedef
Definition: boundary_point.hpp:116
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
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
boundary_point< std::u32string::const_iterator > u32sboundary_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 char16_t * > u16cboundary_point
convenience typedef
Definition: boundary_point.hpp:113
boundary_point< const char * > cboundary_point
convenience typedef
Definition: boundary_point.hpp:110
boundary_point()
Empty default constructor.
Definition: boundary_point.hpp:50
This class represents a boundary point in the text.
Definition: boundary_point.hpp:44
void iterator(iterator_type i)
Set an new iterator value i.
Definition: boundary_point.hpp:56
IteratorType iterator_type
The type of the base iterator that iterates the original text.
Definition: boundary_point.hpp:47
Generate boundary analysis facet.
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
boundary_point< std::u16string::const_iterator > u16sboundary_point
convenience typedef
Definition: boundary_point.hpp:104