Stringshare class. More...
Public Member Functions | |
stringshare () | |
Default constructor. More... | |
stringshare (const char *str) | |
Share an instance of the given string wrapped by the newly created stringshare object. More... | |
stringshare (const char *str, steal_stringshare_ref_t) | |
Create an eina::stringshare that steal the ownership of the given shared string. More... | |
template<typename InputIterator > | |
stringshare (InputIterator i, InputIterator j, typename eina::enable_if<!eina::is_integral< InputIterator >::value &&!eina::is_contiguous_iterator< InputIterator >::value >::type *=0) | |
Share the string between the iterator. More... | |
template<typename ContiguousMemoryIterator > | |
stringshare (ContiguousMemoryIterator i, ContiguousMemoryIterator j, typename eina::enable_if< eina::is_contiguous_iterator< ContiguousMemoryIterator >::value >::type *=0) | |
Share the string between the iterator. More... | |
~stringshare () | |
Destructor. More... | |
stringshare (stringshare const &other) | |
Copy constructor. More... | |
stringshare & | operator= (stringshare const &other) |
Replace the current shared string. More... | |
stringshare & | operator= (const char *c_string) |
Replace the current shared string. More... | |
const_iterator | begin () const |
Get a constant iterator pointing to the first character of the string. More... | |
const_iterator | end () const |
Get a constant iterator to the position following the last character of the string. More... | |
const_reverse_iterator | rbegin () const |
Get a constant reverse iterator pointing to the reverse begin of the string. More... | |
const_reverse_iterator | rend () const |
Get a constant reverse iterator pointing to the reverse end of the string. More... | |
const_iterator | cbegin () const |
Get a constant iterator pointing to the first character of the string. More... | |
const_iterator | cend () const |
Get a constant iterator to the position following the last character of the string. More... | |
const_reverse_iterator | crbegin () const |
Get a constant reverse iterator pointing to the reverse begin of the string. More... | |
const_reverse_iterator | crend () const |
Get a constant reverse iterator pointing to the reverse end of the string. More... | |
size_type | size () const |
Get the size of the string. More... | |
size_type | length () const |
Alias to size() const. | |
size_type | max_size () const |
Get the maximum number of characters a string can hold. More... | |
bool | empty () const |
Check if the string has no characters. More... | |
const_reference | operator[] (size_type i) const |
Get the character at the given position. More... | |
const_reference | at (size_type i) const |
Get the character at the given position. More... | |
const_reference | back () const |
Get the last character of the string. More... | |
const_reference | front () const |
Get the first character of the string. More... | |
void | swap (stringshare &other) |
Swap shared strings with other eina::stringshare . | |
const char * | c_str () const |
Get the c-like shared string currently associated with the object. More... | |
const char * | data () const |
Alias to c_str() const. | |
Stringshare class.
It provides an OOP interface to the Eina_Stringshare
functions, and automatically take care of sharing the string upon construction and deleting it upon destruction using the RAII programming idiom.
It also provides additional member functions to facilitate the access to the string content, much like a STL string.
|
inline |
Default constructor.
Creates a new object holding an shared empty string.
|
inline |
Share an instance of the given string wrapped by the newly created stringshare
object.
<tt>NULL</tt>-terminated | string to be shared. |
This constructor creates an eina::stringshare
object that shares the given string and wraps the shared pointer, providing an OOP interface to the string content. If the string is already shared this constructor simple increment its reference counter and wraps the shared pointer.
|
inline |
Create an eina::stringshare
that steal the ownership of the given shared string.
str | Shared string whose ownership should be stolen. |
This constructor creates an eina::stringshare
object that steals the ownership of the given shared string. At destruction time, the reference counter for the shared string will be decremented.
The second parameter is an empty object of a specific type that should be supplied to explicitly inform that this is the intended constructor; and to differentiate this from stringshare(const char* str).
str
should be a string that was previously shared (most likely by an call to the native eina_stringshare_add
function). If the string is not shared, upon destruction time bad things will happen, likely a segmentation fault.
|
inline |
Share the string between the iterator.
i | Iterator to the initial position of the string (inclusive). |
j | Iterator to the final position of the string (exclusive). |
j
) is not considered. References eina_stringshare_add().
|
inline |
Share the string between the iterator.
i | Iterator to the initial position of the string (inclusive). |
j | Iterator to the final position of the string (exclusive). |
j
) is not considered.
|
inline |
Destructor.
Delete the shared string.
Decreases the reference counter associated with the shared string. If the reference counter reaches 0, the memory associated with the string is freed.
References eina_stringshare_del().
|
inline |
Copy constructor.
Creates a new eina::stringshare
associated with the same shared string.
other | Another eina::stringshare . |
This constructor increments the reference counter to the shared string associated with other
.
|
inline |
Replace the current shared string.
other | Another eina::stringshare . |
This operator replaces the current shared string by the string shared by other
. The reference counter of the older shared string is decremented (the string is released if needed) and the reference counter of the given shared string is incremented.
|
inline |
Replace the current shared string.
c_string | NULL -terminated string. |
This operator replaces the shared string currently associated with this object by a shared instance of c_string
.
|
inline |
Get a constant iterator pointing to the first character of the string.
This member function returns a constant iterator pointing to the first character of the string. If the string is empty the iterator is equal to the one returned by end() const.
|
inline |
Get a constant iterator to the position following the last character of the string.
This member function returns an constant iterator to the position following the last character in the string. If the string is empty the iterator is equal to the one returned by begin().
|
inline |
Get a constant reverse iterator pointing to the reverse begin of the string.
This member function returns a constant reverse iterator pointing to the last character of the string. If the string is empty the returned reverse iterator is the same as the one returned by rend() const.
|
inline |
Get a constant reverse iterator pointing to the reverse end of the string.
This member function returns a constant reverse iterator pointing to the position before the first character of the string. If the string is empty the returned iterator is the same as the one returned by rbegin() const.
|
inline |
Get a constant iterator pointing to the first character of the string.
This member function works just like begin() const. But it is granted to always return a constant iterator.
|
inline |
Get a constant iterator to the position following the last character of the string.
This member function works just like end() const. But it is granted to always return a constant iterator.
|
inline |
Get a constant reverse iterator pointing to the reverse begin of the string.
This member function works just like rbegin() const. But it is granted to always return a constant reverse iterator.
|
inline |
Get a constant reverse iterator pointing to the reverse end of the string.
This member function works just like rend() const. But it is granted to always return a constant reverse iterator.
|
inline |
Get the size of the string.
References eina_stringshare_strlen().
|
inline |
Get the maximum number of characters a string can hold.
|
inline |
Check if the string has no characters.
true
if the string has no characters, false
otherwise.
|
inline |
Get the character at the given position.
i | Position of the character in the string. |
|
inline |
Get the character at the given position.
i | Position of the character in the string. |
<tt>std::out_of_range</tt> | if the given position exceeds the string size. |
This member function returns a constant reference to the character at the position i
. If i
exceeds the string size this function will throw a std::out_of_range
.
|
inline |
Get the last character of the string.
|
inline |
Get the first character of the string.
|
inline |
Get the c-like shared string currently associated with the object.
Referenced by efl::eina::operator==().