boost::log::basic_slim_string — A slim string class with shared data and read-only access.
// In header: <boost/log/utility/slim_string.hpp> template<typename CharT, typename TraitsT = std::char_traits< CharT > > class basic_slim_string : private std::allocator< char > { public: // types typedef CharT char_type; // Character type. typedef TraitsT traits_type; // Character traits type. typedef std::allocator< char_type > allocator_type; // Underlying allocator type. typedef std::basic_string< char_type, traits_type > string_type; // Compatible string type. typedef allocator_type::value_type value_type; typedef allocator_type::pointer pointer; typedef allocator_type::const_pointer const_pointer; typedef allocator_type::reference reference; typedef allocator_type::const_reference const_reference; typedef allocator_type::size_type size_type; typedef allocator_type::difference_type difference_type; typedef const_pointer const_iterator; typedef std::reverse_iterator< const_iterator > const_reverse_iterator; enum @0 { npos = ~0U }; // construct/copy/destruct basic_slim_string(); basic_slim_string(basic_slim_string const &); explicit basic_slim_string(string_type const &); basic_slim_string(string_type const &, size_type, size_type = npos); basic_slim_string(basic_slim_string const &, size_type, size_type = npos); basic_slim_string(const_pointer); basic_slim_string(const_pointer, size_type); basic_slim_string(size_type, char_type); basic_slim_string& operator=(basic_slim_string const &); template<typename T> basic_slim_string& operator=(T const &); ~basic_slim_string(); // public member functions const_reference operator[](size_type) const; template<typename T> bool operator==(T const &) const; template<typename T> bool operator!=(T const &) const; template<typename T> bool operator<(T const &) const; template<typename T> bool operator>(T const &) const; template<typename T> bool operator<=(T const &) const; template<typename T> bool operator>=(T const &) const; const_reference at(size_type) const; const_pointer data() const; const_pointer c_str() const; size_type size() const; size_type length() const; bool empty() const; size_type capacity() const; size_type max_size() const; const_iterator begin() const; const_iterator end() const; const_reverse_iterator rbegin() const; const_reverse_iterator rend() const; size_type copy(pointer, size_type, size_type = 0) const; basic_slim_string substr(size_type = 0, size_type = npos) const; void swap(basic_slim_string &); size_type find(basic_slim_string const &, size_type = 0) const; size_type find(string_type const &, size_type = 0) const; size_type find(const_pointer, size_type = 0) const; size_type find(const_pointer, size_type, size_type) const; size_type find(char_type, size_type = 0) const; size_type rfind(basic_slim_string const &, size_type = npos) const; size_type rfind(string_type const &, size_type = npos) const; size_type rfind(const_pointer, size_type = npos) const; size_type rfind(const_pointer, size_type, size_type) const; size_type rfind(char_type, size_type = npos) const; size_type find_first_of(basic_slim_string const &, size_type = 0) const; size_type find_first_of(string_type const &, size_type = 0) const; size_type find_first_of(const_pointer, size_type = 0) const; size_type find_first_of(const_pointer, size_type, size_type) const; size_type find_first_of(char_type, size_type = 0) const; size_type find_last_of(basic_slim_string const &, size_type = npos) const; size_type find_last_of(string_type const &, size_type = npos) const; size_type find_last_of(const_pointer, size_type = npos) const; size_type find_last_of(const_pointer, size_type, size_type) const; size_type find_last_of(char_type, size_type = npos) const; size_type find_first_not_of(basic_slim_string const &, size_type = 0) const; size_type find_first_not_of(string_type const &, size_type = 0) const; size_type find_first_not_of(const_pointer, size_type = 0) const; size_type find_first_not_of(const_pointer, size_type, size_type) const; size_type find_first_not_of(char_type, size_type = 0) const; size_type find_last_not_of(basic_slim_string const &, size_type = npos) const; size_type find_last_not_of(string_type const &, size_type = npos) const; size_type find_last_not_of(const_pointer, size_type = npos) const; size_type find_last_not_of(const_pointer, size_type, size_type) const; size_type find_last_not_of(char_type, size_type = npos) const; int compare(basic_slim_string const &) const; int compare(string_type const &) const; int compare(size_type, size_type, basic_slim_string const &) const; int compare(size_type, size_type, string_type const &) const; int compare(size_type, size_type, basic_slim_string const &, size_type, size_type) const; int compare(size_type, size_type, string_type const &, size_type, size_type) const; int compare(const_pointer) const; int compare(const_pointer, size_type) const; int compare(size_type, size_type, const_pointer) const; int compare(size_type, size_type, const_pointer, size_type) const; };
The slim string class is used within the library to optimize attribute names storage and copying. The basic_slim_string
class template provides interface similar to std::basic_string
with regard to read-only capabilities.
basic_slim_string
public
construct/copy/destructbasic_slim_string();
Default constructor
Postconditions: |
|
basic_slim_string(basic_slim_string const & that);
Copy constructor
Parameters: |
|
||
Postconditions: |
|
explicit basic_slim_string(string_type const & that);
Constructs a slim string from an STL string.
Parameters: |
|
||
Postconditions: |
|
basic_slim_string(string_type const & s, size_type pos, size_type n = npos);
Constructs a slim string from an STL string part.
Parameters: |
|
||||||
Postconditions: |
|
basic_slim_string(basic_slim_string const & that, size_type pos, size_type n = npos);
Constructs a slim string from a slim string part.
Parameters: |
|
||||||
Postconditions: |
|
basic_slim_string(const_pointer s);
Constructs a slim string from a C-style string
Parameters: |
|
||
Postconditions: |
|
basic_slim_string(const_pointer s, size_type n);
Constructs a slim string from a C-style string
Parameters: |
|
||||
Postconditions: |
|
basic_slim_string(size_type n, char_type c);
Constructs a slim string from a number of characters
Parameters: |
|
||||
Postconditions: |
|
basic_slim_string& operator=(basic_slim_string const & that);
Assignment operator
Parameters: |
|
||
Postconditions: |
|
template<typename T> basic_slim_string& operator=(T const & that);
Assignment operator
Parameters: |
|
||
Postconditions: |
|
~basic_slim_string();
Destructor
basic_slim_string
public member functionsconst_reference operator[](size_type n) const;
Indexing operator
Parameters: |
|
||
Requires: | n |
||
Returns: | Constant reference to the requested character |
template<typename T> bool operator==(T const & that) const;
Lexicographical comparison operator (equality).
Parameters: |
|
template<typename T> bool operator!=(T const & that) const;
Lexicographical comparison operator (inequality).
Parameters: |
|
template<typename T> bool operator<(T const & that) const;
Lexicographical comparison operator (less).
Parameters: |
|
template<typename T> bool operator>(T const & that) const;
Lexicographical comparison operator (greater).
Parameters: |
|
template<typename T> bool operator<=(T const & that) const;
Lexicographical comparison operator (less or equal).
Parameters: |
|
template<typename T> bool operator>=(T const & that) const;
Lexicographical comparison operator (greater or equal).
Parameters: |
|
const_reference at(size_type n) const;
Checked accessor to a character within the string
Throws: An std::exception
-based exception to indicate that n is out of range.
Parameters: |
|
||
Returns: | Constant reference to the requested character |
const_pointer data() const;
Returns: | A constant pointer to the beginning of the string |
const_pointer c_str() const;
Returns: | A constant pointer to the beginning of the string |
size_type size() const;
Returns: | The stored string length |
size_type length() const;
Returns: | The stored string length |
bool empty() const;
Returns: |
|
size_type capacity() const;
Returns: |
|
size_type max_size() const;
Returns: |
|
const_iterator begin() const;
Returns: | Constant iterator to the beginning of the string |
const_iterator end() const;
Returns: | Constant iterator to the end of the string |
const_reverse_iterator rbegin() const;
Returns: | Constant reverse iterator to the end of the string |
const_reverse_iterator rend() const;
Returns: | Constant reverse iterator to the beginning of the string |
size_type copy(pointer s, size_type n, size_type pos = 0) const;
Copies a part of the stored string into external buffer
Parameters: |
|
||||||
Returns: | The number of copied symbols |
basic_slim_string substr(size_type pos = 0, size_type n = npos) const;
Creates another slim string containing a part of the stored string
Parameters: |
|
||||
Returns: | The constructed substring |
void swap(basic_slim_string & that);
Swaps two strings
size_type find(basic_slim_string const & that, size_type pos = 0) const;
Searches the string for a substring
Parameters: |
|
||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type find(string_type const & s, size_type pos = 0) const;
Searches the string for a substring
Parameters: |
|
||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type find(const_pointer s, size_type pos = 0) const;
Searches the string for a substring
Parameters: |
|
||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type find(const_pointer s, size_type pos, size_type n) const;
Searches the string for a substring
Parameters: |
|
||||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type find(char_type c, size_type pos = 0) const;
Searches the string for a character
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type rfind(basic_slim_string const & that, size_type pos = npos) const;
Searches the string for a substring in the reverse direction
Parameters: |
|
||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type rfind(string_type const & s, size_type pos = npos) const;
Searches the string for a substring in the reverse direction
Parameters: |
|
||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type rfind(const_pointer s, size_type pos = npos) const;
Searches the string for a substring in the reverse direction
Parameters: |
|
||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type rfind(const_pointer s, size_type pos, size_type n) const;
Searches the string for a substring in the reverse direction
Parameters: |
|
||||||
Returns: | Starting position of the found substring within the string, if lookup was successful, |
size_type rfind(char_type c, size_type pos = npos) const;
Searches the string for a character in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_of(basic_slim_string const & that, size_type pos = 0) const;
Searches the string for one of the specified characters
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_of(string_type const & s, size_type pos = 0) const;
Searches the string for one of the specified characters
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_of(const_pointer s, size_type pos = 0) const;
Searches the string for one of the specified characters
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_of(const_pointer s, size_type pos, size_type n) const;
Searches the string for one of the specified characters
Parameters: |
|
||||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_of(char_type c, size_type pos = 0) const;
Searches the string for a character
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_of(basic_slim_string const & that, size_type pos = npos) const;
Searches the string for one of the specified characters in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_of(string_type const & s, size_type pos = npos) const;
Searches the string for one of the specified characters in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_of(const_pointer s, size_type pos = npos) const;
Searches the string for one of the specified characters in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_of(const_pointer s, size_type pos, size_type n) const;
Searches the string for one of the specified characters in the reverse direction
Parameters: |
|
||||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_of(char_type c, size_type pos = npos) const;
Searches the string for a character in the reverse direction in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_not_of(basic_slim_string const & that, size_type pos = 0) const;
Searches the string for one of the characters, other than specified in the sequence
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_not_of(string_type const & s, size_type pos = 0) const;
Searches the string for one of the characters, other than specified in the sequence
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_not_of(const_pointer s, size_type pos = 0) const;
Searches the string for one of the characters, other than specified in the sequence
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_not_of(const_pointer s, size_type pos, size_type n) const;
Searches the string for one of the characters, other than specified in the sequence
Parameters: |
|
||||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_first_not_of(char_type c, size_type pos = 0) const;
Searches the string for one of the characters, other than specified
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_not_of(basic_slim_string const & that, size_type pos = npos) const;
Searches the string for one of the characters, other than specified in the sequence, in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_not_of(string_type const & s, size_type pos = npos) const;
Searches the string for one of the characters, other than specified in the sequence, in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_not_of(const_pointer s, size_type pos = npos) const;
Searches the string for one of the characters, other than specified in the sequence, in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_not_of(const_pointer s, size_type pos, size_type n) const;
Searches the string for one of the characters, other than specified in the sequence, in the reverse direction
Parameters: |
|
||||||
Returns: | Position of the found character within the string, if lookup was successful, |
size_type find_last_not_of(char_type c, size_type pos = npos) const;
Searches the string for one of the characters, other than specified, in the reverse direction
Parameters: |
|
||||
Returns: | Position of the found character within the string, if lookup was successful, |
int compare(basic_slim_string const & that) const;
Lexicographically compares the argument string to this string
Parameters: |
|
||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(string_type const & s) const;
Lexicographically compares the argument string to this string
Parameters: |
|
||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(size_type pos1, size_type n1, basic_slim_string const & that) const;
Lexicographically compares the argument string to a part of this string
Throws: An std::exception
-based exception if arguments are out of range.
Parameters: |
|
||||||
Requires: |
|
||||||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(size_type pos1, size_type n1, string_type const & s) const;
Lexicographically compares the argument string to a part of this string
Throws: An std::exception
-based exception if arguments are out of range.
Parameters: |
|
||||||
Requires: |
|
||||||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(size_type pos1, size_type n1, basic_slim_string const & that, size_type pos2, size_type n2) const;
Lexicographically compares substring of the argument string to a part of this string
Throws: An std::exception
-based exception if arguments are out of range.
Parameters: |
|
||||||||||
Requires: |
|
||||||||||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(size_type pos1, size_type n1, string_type const & s, size_type pos2, size_type n2) const;
Lexicographically compares substring of the argument string to a part of this string
Throws: An std::exception
-based exception if arguments are out of range.
Parameters: |
|
||||||||||
Requires: |
|
||||||||||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(const_pointer s) const;
Lexicographically compares the argument string to this string
Parameters: |
|
||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(const_pointer s, size_type n2) const;
Lexicographically compares the argument string to this string
Parameters: |
|
||||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(size_type pos1, size_type n1, const_pointer s) const;
Lexicographically compares the argument string to a part of this string
Throws: An std::exception
-based exception if arguments are out of range.
Parameters: |
|
||||||
Requires: |
|
||||||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |
int compare(size_type pos1, size_type n1, const_pointer s, size_type n2) const;
Lexicographically compares the argument string to a part of this string
Throws: An std::exception
-based exception if arguments are out of range.
Parameters: |
|
||||||||
Requires: |
|
||||||||
Returns: | Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand. |