Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::locale::boundary::segment_index< BaseIterator > Class Template Reference

This class holds an index of segments in the text range and allows to iterate over them. More...

#include <index.hpp>

Public Types

typedef BaseIterator base_iterator
 The type of the iterator used to iterate over the original text. More...
 
typedef
details::segment_index_iterator
< base_iterator
iterator
 
typedef
details::segment_index_iterator
< base_iterator
const_iterator
 
typedef segment< base_iteratorvalue_type
 The type dereferenced by the iterator and const_iterator. More...
 

Public Member Functions

 segment_index ()
 Default constructor. More...
 
 segment_index (boundary_type type, base_iterator begin, base_iterator end, rule_type mask, std::locale const &loc=std::locale())
 Create a segment_index for boundary analysis type of the text in range [begin,end) using a rule mask for locale loc. More...
 
 segment_index (boundary_type type, base_iterator begin, base_iterator end, std::locale const &loc=std::locale())
 Create a segment_index for boundary analysis type of the text in range [begin,end) selecting all possible segments (full mask) for locale loc. More...
 
 segment_index (boundary_point_index< base_iterator > const &)
 Create a segment_index from a boundary_point_index. More...
 
segment_index const & operator= (boundary_point_index< base_iterator > const &)
 Copy an index from a boundary_point_index. More...
 
void map (boundary_type type, base_iterator begin, base_iterator end, std::locale const &loc=std::locale())
 Create a new index for boundary analysis type of the text in range [begin,end) for locale loc. More...
 
iterator begin () const
 Get the iterator on the beginning of the segments range. More...
 
iterator end () const
 Get the iterator on the ending of the segments range. More...
 
iterator find (base_iterator p) const
 Find a first valid segment following a position p. More...
 
rule_type rule () const
 Get the mask of rules that are used. More...
 
void rule (rule_type v)
 Set the mask of rules that are used. More...
 
bool full_select () const
 Get the full_select property value - should segment include in the range values that not belong to specific rule() or not. More...
 
void full_select (bool v)
 Set the full_select property value - should segment include in the range values that not belong to specific rule() or not. More...
 

Friends

class boundary_point_index< base_iterator >
 

Detailed Description

template<typename BaseIterator>
class boost::locale::boundary::segment_index< BaseIterator >

This class holds an index of segments in the text range and allows to iterate over them.

This class is provides begin() and end() member functions that return bidirectional iterators to the segment objects.

It provides two options on way of selecting segments:

  • rule(rule_type mask) - a mask that allows to select only specific types of segments according to various masks as word_any.
    The default is to select any types of boundaries.
    For example: using word boundary analysis, when the provided mask is word_kana then the iterators would iterate only over the words containing Kana letters and word_any would select all types of words excluding ranges that consist of white space and punctuation marks. So iterating over the text "to be or not to be?" with word_any rule would return segments "to", "be", "or", "not", "to", "be", instead of default "to", " ", "be", " ", "or", " ", "not", " ", "to", " ", "be", "?".
  • full_select(bool how) - a flag that defines the way a range is selected if the rule of the previous boundary point does not fit the selected rule.
    For example: We want to fetch all sentences from the following text: "Hello! How\nare you?".
    This text contains three boundary points separating it to sentences by different rules:
    • The exclamation mark "!" ends the sentence "Hello!"
    • The line feed that splits the sentence "How\nare you?" into two parts.
    • The question mark that ends the second sentence.
      If you would only change the rule() to sentence_term then the segment_index would provide two sentences "Hello!" and "are you?" as only them actually terminated with required terminator "!" or "?". But changing full_select() to true, the selected segment would include all the text up to previous valid boundary point and would return two expected sentences: "Hello!" and "How\nare you?".

This class allows to find a segment according to the given iterator in range using find() member function.

Note
See also

The documentation for this class was generated from the following file: