PrevUpHomeNext

Struct template basic_text

boost::text::basic_text

Synopsis

// In header: <boost/text/text.hpp>

template<nf Normalization, typename Char, typename String> 
struct basic_text {
  // types
  typedef Char                                               char_type;             
  typedef String                                             string;                
  typedef basic_string_view< char_type >                     string_view;           
  typedef basic_text_view< Normalization, char_type >        text_view;             
  typedef grapheme                                           value_type;            
  typedef std::size_t                                        size_type;             
  typedef unspecified                                        iterator;              
  typedef unspecified                                        const_iterator;        
  typedef stl_interfaces::reverse_iterator< iterator >       reverse_iterator;      
  typedef stl_interfaces::reverse_iterator< const_iterator > const_reverse_iterator;
  typedef typename iterator::reference                       reference;             
  typedef typename const_iterator::reference                 const_reference;       

  // construct/copy/destruct
  basic_text();
  basic_text(basic_text const &) = default;
  basic_text(basic_text &&);
  basic_text(const_iterator, const_iterator);
  basic_text(char_type const *);
  explicit basic_text(text_view);
  explicit basic_text(rope_view);
  template<code_unit_range< utf_format > R> explicit basic_text(R const &);
  template<code_unit_iter< utf_format > I, std::sentinel_for< I > S> 
    basic_text(I, S);
  template<grapheme_range_code_unit< utf_format > R> 
    explicit basic_text(R const &);
  template<grapheme_iter_code_unit< utf_format > I> explicit basic_text(I, I);
  basic_text & operator=(basic_text const &) = default;
  basic_text & operator=(basic_text &&);
  basic_text & operator=(char_type const *);
  basic_text & operator=(string_view);
  basic_text & operator=(text_view);
  basic_text & operator=(rope_view);

  // public member functions
   BOOST_TEXT_STATIC_ASSERT_NORMALIZATION();
  operator text_view() const;
  char_type * data();
  char_type const * data() const;
  char_type const * c_str() const;
  const_reference front() const;
  const_reference back() const;
  reference front();
  reference back();
  void push_back(grapheme const &);
  template<typename CPIter> void push_back(grapheme_ref< CPIter >);
  void pop_back();
  iterator begin();
  iterator end();
  const_iterator begin() const;
  const_iterator end() const;
  const_iterator cbegin() const;
  const_iterator cend() const;
  reverse_iterator rbegin();
  reverse_iterator rend();
  const_reverse_iterator rbegin() const;
  const_reverse_iterator rend() const;
  const_reverse_iterator crbegin() const;
  const_reverse_iterator crend() const;
  bool empty() const;
  size_type storage_code_units() const;
  size_type capacity_bytes() const;
  size_type distance() const;
  size_type max_code_units() const;
  void clear();
  replace_result< iterator > erase(const_iterator, const_iterator);
  replace_result< iterator > erase(const_iterator);
  replace_result< iterator > 
  replace(const_iterator, const_iterator, const_iterator, const_iterator);
  replace_result< iterator > 
  replace(const_iterator, const_iterator, char_type const *);
  replace_result< iterator > 
  replace(const_iterator, const_iterator, string_view);
  replace_result< iterator > 
  replace(const_iterator, const_iterator, rope_view);
  template<code_unit_range< utf_format > R> 
    replace_result< iterator > 
    replace(const_iterator, const_iterator, R const &);
  template<code_unit_iter< utf_format > I> 
    replace_result< iterator > replace(const_iterator, const_iterator, I, I);
  template<grapheme_range_code_unit< utf_format > R> 
    replace_result< iterator > 
    replace(const_iterator, const_iterator, R const &);
  template<grapheme_iter_code_unit< utf_format > I> 
    replace_result< iterator > replace(const_iterator, const_iterator, I, I);
  replace_result< iterator > 
  replace(const_iterator, const_iterator, grapheme const &);
  template<typename CPIter> 
    replace_result< iterator > 
    replace(const_iterator, const_iterator, grapheme_ref< CPIter >);
  replace_result< iterator > 
  insert(const_iterator, const_iterator, const_iterator);
  template<typename T> auto insert(const_iterator, T const &);
  template<typename I> auto insert(const_iterator, I, I);
  void assign(const_iterator, const_iterator);
  template<typename T> auto assign(T const &);
  template<typename I> auto assign(I, I);
  void append(const_iterator, const_iterator);
  template<typename T> auto append(T const &);
  template<typename I> auto append(I, I);
  void reserve(size_type);
  void shrink_to_fit();
  void swap(basic_text &);
  string extract();
  void replace(string &&);
  template<typename T> auto operator+=(T const &);

  // friend functions
  std::ostream & operator<<(std::ostream &, basic_text const &);
  std::wostream & operator<<(std::wostream &, basic_text const &);
  template<typename T> bool operator==(basic_text const &, T const &);
  template<typename T> bool operator==(T const &, basic_text const &);
  template<typename T> bool operator!=(basic_text const &, T const &);
  template<typename T> bool operator!=(T const &, basic_text const &);

  // public data members
  static constexpr nf normalization;
  static constexpr format utf_format;
};

Description

A mutable sequence of graphemes over an underlying container of contiguous null-terminated code units. The underlying storage is a String, and is kept in normalization form Normalization. The String is responsible for maintaining null-termination.

basic_text public types

  1. typedef Char char_type;

    The type of code unit used in the underlying storage.

  2. typedef String string;

    The type of the container used as underlying storage.

  3. typedef basic_string_view< char_type > string_view;

    The specialization of std::basic_string_view (or boost::basic_string_view in pre-C++17 code) compatible with string.

  4. typedef basic_text_view< Normalization, char_type > text_view;

    The specialization of basic_text_view with the same normalization form and underlying code unit type.

basic_text public construct/copy/destruct

  1. basic_text();

    Default ctor.

  2. basic_text(basic_text const &) = default;
  3. basic_text(basic_text &&);
  4. basic_text(const_iterator first, const_iterator last);

    Constructs a basic_text from a pair of iterators.

  5. basic_text(char_type const * c_str);

    Constructs a basic_text from a null-terminated string.

  6. explicit basic_text(text_view tv);

    Constructs a basic_text from a text_view.

  7. explicit basic_text(rope_view rv);

    Constructs a basic_text from a rope_view.

  8. template<code_unit_range< utf_format > R> explicit basic_text(R const & r);

    Constructs a basic_text from a range of char_type.

  9. template<code_unit_iter< utf_format > I, std::sentinel_for< I > S> 
      basic_text(I first, S last);

    Constructs a basic_text from a sequence of char_type.

  10. template<grapheme_range_code_unit< utf_format > R> 
      explicit basic_text(R const & r);

    Constructs a basic_text from a range of graphemes.

  11. template<grapheme_iter_code_unit< utf_format > I> 
      explicit basic_text(I first, I last);

    Constructs a basic_text from a sequence of graphemes.

  12. basic_text & operator=(basic_text const &) = default;
  13. basic_text & operator=(basic_text &&);
  14. basic_text & operator=(char_type const * c_str);

    Assignment from a null-terminated string.

  15. basic_text & operator=(string_view sv);

    Assignment from a string_view.

  16. basic_text & operator=(text_view tv);

    Assignment from a text_view.

  17. basic_text & operator=(rope_view rv);

    Assignment from a rope_view.

basic_text public member functions

  1.  BOOST_TEXT_STATIC_ASSERT_NORMALIZATION();
  2. operator text_view() const;
  3. char_type * data();
  4. char_type const * data() const;
  5. char_type const * c_str() const;
  6. const_reference front() const;
  7. const_reference back() const;
  8. reference front();
  9. reference back();
  10. void push_back(grapheme const & g);
  11. template<typename CPIter> void push_back(grapheme_ref< CPIter > g);
  12. void pop_back();
  13. iterator begin();
  14. iterator end();
  15. const_iterator begin() const;
  16. const_iterator end() const;
  17. const_iterator cbegin() const;
  18. const_iterator cend() const;
  19. reverse_iterator rbegin();
  20. reverse_iterator rend();
  21. const_reverse_iterator rbegin() const;
  22. const_reverse_iterator rend() const;
  23. const_reverse_iterator crbegin() const;
  24. const_reverse_iterator crend() const;
  25. bool empty() const;

    Returns true iff size() == 0.

  26. size_type storage_code_units() const;

    Returns the number of code units controlled by *this, not including the null terminator.

  27. size_type capacity_bytes() const;

    Returns the number of bytes of storage currently in use by *this.

  28. size_type distance() const;

    Returns the number of graphemes in *this. This operation is O(n).

  29. size_type max_code_units() const;

    Returns the maximum size in code units a basic_text can have.

  30. void clear();

    Clear.

    Postconditions:

    size() == 0 && capacity() == 0; begin(), end() delimit an empty string

  31. replace_result< iterator > erase(const_iterator first, const_iterator last);

    Erases the portion of *this delimited by [first, last).

    Requires:

    first <= last

  32. replace_result< iterator > erase(const_iterator at);

    Erases the grapheme at position at.

    Requires:

    at != end()

  33. replace_result< iterator > 
    replace(const_iterator first1, const_iterator last1, const_iterator first2, 
            const_iterator last2);

    Replaces the portion of *this delimited by [first1, last1) with the sequence [first2, last2).

    Requires:

    !std::less(first1.base().base(), begin().base().base()) && !std::less(end().base().base(), last1.base().base())

  34. replace_result< iterator > 
    replace(const_iterator first, const_iterator last, 
            char_type const * new_substr);

    Replaces the portion of *this delimited by [first, last) with new_substr.

    Requires:

    !std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base())

  35. replace_result< iterator > 
    replace(const_iterator first, const_iterator last, string_view new_substr);

    Replaves the portion of *this delimited by [first, last) with new_substr.

    Requires:

    !std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base())

  36. replace_result< iterator > 
    replace(const_iterator first, const_iterator last, rope_view new_substr);

    Replaces the portion of *this delimited by [first, last) with new_substr.

    Requires:

    !std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base())

  37. template<code_unit_range< utf_format > R> 
      replace_result< iterator > 
      replace(const_iterator first, const_iterator last, R const & r);

    Replaces the portion of *this delimited by [first, last) with r.

    Requires:

    !std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base())

  38. template<code_unit_iter< utf_format > I> 
      replace_result< iterator > 
      replace(const_iterator first1, const_iterator last1, I first2, I last2);

    Replaces the portion of *this delimited by [first1, last1) with [first2, last2).

    Requires:

    !std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base())

  39. template<grapheme_range_code_unit< utf_format > R> 
      replace_result< iterator > 
      replace(const_iterator first, const_iterator last, R const & r);

    Replaces the portion of *this delimited by [first, last) with r.

    Requires:

    !std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base())

  40. template<grapheme_iter_code_unit< utf_format > I> 
      replace_result< iterator > 
      replace(const_iterator first1, const_iterator last1, I first2, I last2);

    Replaces the portion of *this delimited by [first1, last1) with [first2, last2).

    Requires:

    !std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base())

  41. replace_result< iterator > 
    replace(const_iterator first, const_iterator last, grapheme const & g);

    Replaces the portion of *this delimited by [first, last) with g.

  42. template<typename CPIter> 
      replace_result< iterator > 
      replace(const_iterator first, const_iterator last, grapheme_ref< CPIter > g);

    Replaces the portion of *this delimited by [first, last) with g.

  43. replace_result< iterator > 
    insert(const_iterator at, const_iterator first, const_iterator last);

    Inserts the sequence [first, last) into *this starting at position at.

  44. template<typename T> auto insert(const_iterator at, T const & x);

    Inserts the sequence of char_type from x into *this starting at position at.

  45. template<typename I> auto insert(const_iterator at, I first, I last);

    Inserts the sequence [first, last) into *this starting at position at.

  46. void assign(const_iterator first, const_iterator last);

    Assigns the sequence [first, last) to *this.

  47. template<typename T> auto assign(T const & x);

    Assigns the sequence of char_type from x to *this.

  48. template<typename I> auto assign(I first, I last);

    Assigns the sequence [first, last) to *this.

  49. void append(const_iterator first, const_iterator last);

    Appends the sequence [first, last) to *this.

  50. template<typename T> auto append(T const & x);

    Appends the sequence of char_type from x to *this.

  51. template<typename I> auto append(I first, I last);

    Appends the sequence [first, last) to *this.

  52. void reserve(size_type new_size);

    Reserves storage enough for a string of at least new_size bytes.

    Postconditions:

    capacity() >= new_size + 1

  53. void shrink_to_fit();

    Reduces storage used by *this to just the amount necessary to contain size() chars.

    Postconditions:

    capacity() == 0 || capacity() == size() + 1

  54. void swap(basic_text & rhs);

    Swaps *this with rhs.

  55. string extract();

    Removes and returns the underlying string from *this.

  56. void replace(string && s);

    Replaces the underlying string in *this.

    Requires:

    s is in normalization form NFD or FCC.

  57. template<typename T> auto operator+=(T const & x);

    Appends x to *this. T may be any type for which *this = x is well-formed.

basic_text friend functions

  1. std::ostream & operator<<(std::ostream & os, basic_text const & t);

    Stream inserter; performs formatted output, in UTF-8 encoding.

  2. std::wostream & operator<<(std::wostream & os, basic_text const & t);

    Stream inserter; performs formatted output, in UTF-16 encoding. Defined on Windows only.

  3. template<typename T> bool operator==(basic_text const & lhs, T const & rhs);

    Returns true iff lhs == rhs, where rhs is an object for which lhs = rhs is well-formed.

  4. template<typename T> bool operator==(T const & lhs, basic_text const & rhs);

    Returns true iff lhs == rhs, where rhs is an object for which rhs = lhs is well-formed.

  5. template<typename T> bool operator!=(basic_text const & lhs, T const & rhs);

    Returns true iff lhs != rhs, where rhs is an object for which lhs = rhs is well-formed.

  6. template<typename T> bool operator!=(T const & lhs, basic_text const & rhs);

    Returns true iff lhs != rhs, where rhs is an object for which rhs = lhs is well-formed.

basic_text public public data members

  1. static constexpr nf normalization;

    The normalization form used in this basic_text.

  2. static constexpr format utf_format;

    The UTF format used in the underlying storage.


PrevUpHomeNext