boost::text::basic_rope
// In header: <boost/text/rope.hpp> template<nf Normalization, typename Char, typename String> struct basic_rope { // types typedef Char char_type; typedef String string; typedef basic_unencoded_rope< char_type, string > unencoded_rope; typedef basic_text< normalization, char_type, string > text; typedef basic_string_view< char_type > string_view; typedef basic_rope_view< normalization, char_type, string > rope_view; typedef grapheme value_type; typedef std::size_t size_type; typedef unspecified iterator; typedef iterator const_iterator; typedef stl_interfaces::reverse_iterator< iterator > reverse_iterator; typedef reverse_iterator const_reverse_iterator; typedef typename const_iterator::reference reference; typedef reference const_reference; // construct/copy/destruct basic_rope(); basic_rope(const_iterator, const_iterator); basic_rope(char_type const *); explicit basic_rope(rope_view); explicit basic_rope(text); template<code_unit_range< utf_format > R> explicit basic_rope(R const &); template<typename CUIter, typename Sentinel> basic_rope(CUIter, Sentinel, unspecified = 0); template<grapheme_range_code_unit< utf_format > R> explicit basic_rope(R const &); template<grapheme_iter_code_unit< utf_format > I> explicit basic_rope(I, I); basic_rope & operator=(char_type const *); basic_rope & operator=(rope_view); basic_rope & operator=(string_view); basic_rope & operator=(string); basic_rope & operator=(text); // public member functions BOOST_TEXT_STATIC_ASSERT_NORMALIZATION(); operator rope_view() const; const_reference front() const; const_reference back() const; void push_back(grapheme const &); template<typename CPIter> void push_back(grapheme_ref< CPIter >); void pop_back(); const_iterator begin() const; const_iterator end() const; const_iterator cbegin() const; const_iterator cend() const; 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 distance() const; size_type max_code_units() const; bool equal_root(basic_rope) const; void clear(); replace_result< const_iterator > erase(const_iterator, const_iterator); replace_result< const_iterator > erase(const_iterator); replace_result< const_iterator > replace(const_iterator, const_iterator, const_iterator, const_iterator); replace_result< const_iterator > replace(const_iterator, const_iterator, char_type const *); replace_result< const_iterator > replace(const_iterator, const_iterator, string_view); replace_result< const_iterator > replace(const_iterator, const_iterator, rope_view); template<code_unit_range< utf_format > R> replace_result< const_iterator > replace(const_iterator, const_iterator, R const &); template<code_unit_iter< utf_format > I> replace_result< const_iterator > replace(const_iterator, const_iterator, I, I); replace_result< const_iterator > replace(const_iterator, const_iterator, grapheme const &); template<typename CPIter> replace_result< const_iterator > replace(const_iterator, const_iterator, grapheme_ref< CPIter >); replace_result< const_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 swap(basic_rope &); unencoded_rope extract(); void replace(unencoded_rope &&); template<typename T> auto operator+=(T &&); // friend functions std::ostream & operator<<(std::ostream &, basic_rope const &); std::wostream & operator<<(std::wostream &, basic_rope const &); template<typename T> bool operator==(basic_rope const &, T const &); template<typename T> bool operator==(T const &, basic_rope const &); template<typename T> bool operator!=(basic_rope const &, T const &); template<typename T> bool operator!=(T const &, basic_rope const &); // public data members static constexpr nf normalization; static constexpr format utf_format; };
A mutable sequence of graphemes with copy-on-write semantics. A basic_rope
is non-contiguous and is not null-terminated. The underlying storage is an unencoded_rope that is UTF-8-encoded and kept in normalization form Normalization
.
basic_rope
public
typesThe type of code unit used in the underlying storage.
The type of the container used in the underlying storage.
typedef basic_unencoded_rope< char_type, string > unencoded_rope;
A specialization of basic_unencoded_rope
with the same char_type
and string
.
typedef basic_text< normalization, char_type, string > text;
A specialization of basic_text
with the same normalization
, char_type
, and string
.
typedef basic_string_view< char_type > string_view;
A specialization of std::basic_string_view
with the same char_type
.
typedef basic_rope_view< normalization, char_type, string > rope_view;
A specialization of basic_rope_view
with the same normalization
, char_type
, and string
.
basic_rope
public
construct/copy/destructbasic_rope();
Default ctor.
basic_rope(const_iterator first, const_iterator last);
Constructs a
from a pair of iterators. basic_rope
basic_rope(char_type const * c_str);
Constructs a
from a null-terminated string. basic_rope
explicit basic_rope(rope_view rv);
Constructs a
from a basic_rope
rope_view
.
explicit basic_rope(text t);
Constructs a
from a basic_rope
text
.
template<code_unit_range< utf_format > R> explicit basic_rope(R const & r);
Constructs a
from a range of basic_rope
char_type
.
template<typename CUIter, typename Sentinel> basic_rope(CUIter first, Sentinel last, unspecified = 0);
Constructs a
from a sequence of basic_rope
char_type
.
template<grapheme_range_code_unit< utf_format > R> explicit basic_rope(R const & r);
Constructs a
from a range of graphemes. basic_rope
template<grapheme_iter_code_unit< utf_format > I> explicit basic_rope(I first, I last);
Constructs a
from a sequence of graphemes. basic_rope
basic_rope & operator=(char_type const * c_str);
Assignment from a null-terminated string.
basic_rope & operator=(rope_view rv);
Assignment from a rope_view
.
basic_rope & operator=(string_view sv);
Assignment from a string_view
.
basic_rope & operator=(string s);
Assignment from a string
.
basic_rope & operator=(text t);
Move-assignment from a text
.
basic_rope
public member functionsBOOST_TEXT_STATIC_ASSERT_NORMALIZATION();
operator rope_view() const;
const_reference front() const;
const_reference back() const;
void push_back(grapheme const & g);
template<typename CPIter> void push_back(grapheme_ref< CPIter > g);
void pop_back();
const_iterator begin() const;
const_iterator end() const;
const_iterator cbegin() const;
const_iterator cend() const;
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
bool empty() const;
Returns true iff begin() == end()
.
size_type storage_code_units() const;
Returns the number of code units controlled by *this
, not including the null terminator.
size_type distance() const;
Returns the number of graphemes in *this
. This operation is O(n).
size_type max_code_units() const;
Returns the maximum size in code units a
can have. basic_rope
bool equal_root(basic_rope rhs) const;
Returns true if *this
and rhs
contain the same root node pointer. This is useful when you want to check for equality between two
s that are likely to have originated from the same initial basic_rope
, and may have since been mutated. basic_rope
void clear();
Clear.
replace_result< const_iterator > erase(const_iterator first, const_iterator last);
Erases the portion of *this
delimited by [first, last)
.
Requires: |
first <= last |
replace_result< const_iterator > erase(const_iterator at);
Erases the grapheme at position at
.
Requires: |
at != end() |
replace_result< const_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()) |
replace_result< const_iterator > replace(const_iterator first, const_iterator last, char_type const * c_str);
Replaces the portion of *this
delimited by [first, last)
with c_str
.
Requires: |
!std::less(first.base().base(), begin().base().base()) && !std::less(end().base().base(), last.base().base()) |
replace_result< const_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()) |
replace_result< const_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()) |
template<code_unit_range< utf_format > R> replace_result< const_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()) |
template<code_unit_iter< utf_format > I> replace_result< const_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(first1.base().base(), begin().base().base()) && !std::less(end().base().base(), last1.base().base()) |
replace_result< const_iterator > replace(const_iterator first, const_iterator last, grapheme const & g);
Replaces the portion of *this
delimited by [first, last)
with g
.
template<typename CPIter> replace_result< const_iterator > replace(const_iterator first, const_iterator last, grapheme_ref< CPIter > g);
Replaces the portion of *this
delimited by [first, last)
with g
.
replace_result< const_iterator > insert(const_iterator at, const_iterator first, const_iterator last);
Inserts the sequence [first, last) into *this
starting at position at
.
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
.
template<typename I> auto insert(const_iterator at, I first, I last);
Inserts the sequence [first, last)
into *this
starting at position at
.
void assign(const_iterator first, const_iterator last);
Assigns the sequence [first, last)
to *this
.
template<typename T> auto assign(T const & x);
Assigns the sequence of char_type
from x
to *this
.
template<typename I> auto assign(I first, I last);
Assigns the sequence [first, last)
to *this
.
void append(const_iterator first, const_iterator last);
Appends the sequence [first, last)
to *this
.
template<typename T> auto append(T const & x);
Appends the sequence of char_type
from x
to *this
.
template<typename I> auto append(I first, I last);
Appends the sequence [first, last)
to *this
.
void swap(basic_rope & rhs);
Swaps *this
with rhs
.
unencoded_rope extract();
Removes and returns the underlying unencoded_rope
from *this
.
void replace(unencoded_rope && ur);
Replaces the underlying unencoded_rope
in *this
.
Requires: |
ur is in normalization form |
template<typename T> auto operator+=(T && x);
Appends x
to *this
. T
may be any type for which *this = x
is well-formed.
basic_rope
friend functionsstd::ostream & operator<<(std::ostream & os, basic_rope const & r);
Stream inserter; performs formatted output, in UTF-8 encoding.
std::wostream & operator<<(std::wostream & os, basic_rope const & r);
Stream inserter; performs formatted output, in UTF-16 encoding. Defined on Windows only.
template<typename T> bool operator==(basic_rope const & lhs, T const & rhs);
Returns true iff lhs
== rhs
, where rhs
is an object for which lhs = rhs
is well-formed.
template<typename T> bool operator==(T const & lhs, basic_rope const & rhs);
Returns true iff lhs
== rhs
, where rhs
is an object for which rhs = lhs
is well-formed.
template<typename T> bool operator!=(basic_rope const & lhs, T const & rhs);
Returns true iff lhs
!= rhs
, where rhs
is an object for which lhs = rhs
is well-formed.
template<typename T> bool operator!=(T const & lhs, basic_rope const & rhs);
Returns true iff lhs
!= rhs
, where rhs
is an object for which rhs = lhs
is well-formed.
basic_rope
public
public data membersstatic constexpr nf normalization;
The normalization form used in this basic_rope
.
static constexpr format utf_format;
The UTF format used in the underlying storage.