Boost C++ Libraries

PrevUpHomeNext

Class template basic_slim_string

boost::log::basic_slim_string — A slim string class with shared data and read-only access.

Synopsis

// 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;
};

Description

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/destruct

  1. basic_slim_string();

    Default constructor

    Postconditions:

    empty() == true

  2. basic_slim_string(basic_slim_string const & that);

    Copy constructor

    Parameters:
    that

    Source string to copy from

    Postconditions:

    *this == that

  3. explicit basic_slim_string(string_type const & that);

    Constructs a slim string from an STL string.

    Parameters:
    that

    Source string to copy from

    Postconditions:

    *this == that

  4. basic_slim_string(string_type const & s, size_type pos, size_type n = npos);

    Constructs a slim string from an STL string part.

    Parameters:
    n

    Number of symbols to copy

    pos

    Starting position to begin copying from

    s

    Source string to copy from

    Postconditions:

    *this == that.substr(pos, n)

  5. 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:
    n

    Number of symbols to copy

    pos

    Starting position to begin copying from

    that

    Source string to copy from

    Postconditions:

    *this == that.substr(pos, n)

  6. basic_slim_string(const_pointer s);

    Constructs a slim string from a C-style string

    Parameters:
    s

    Source string. Must be a zero-terminated sequence of characters, must not be NULL.

    Postconditions:

    *this == string_type(s)

  7. basic_slim_string(const_pointer s, size_type n);

    Constructs a slim string from a C-style string

    Parameters:
    n

    Number of characters in sequence s

    s

    Source string. Must be a sequence of characters, must not be NULL.

    Postconditions:

    *this == string_type(s, n)

  8. basic_slim_string(size_type n, char_type c);

    Constructs a slim string from a number of characters

    Parameters:
    c

    Filler character

    n

    Number of characters

    Postconditions:

    *this == string_type(n, c)

  9. basic_slim_string& operator=(basic_slim_string const & that);

    Assignment operator

    Parameters:
    that

    Source string to copy from

    Postconditions:

    *this == that

  10. template<typename T> basic_slim_string& operator=(T const & that);

    Assignment operator

    Parameters:
    that

    Source string to copy from

    Postconditions:

    *this == basic_slim_string(that)

  11. ~basic_slim_string();

    Destructor

basic_slim_string public member functions

  1. const_reference operator[](size_type n) const;

    Indexing operator

    Parameters:
    n

    Index of the character requested

    Requires:

    n < size()

    Returns:

    Constant reference to the requested character

  2. template<typename T> bool operator==(T const & that) const;

    Lexicographical comparison operator (equality).

    Parameters:
    that

    Comparand

  3. template<typename T> bool operator!=(T const & that) const;

    Lexicographical comparison operator (inequality).

    Parameters:
    that

    Comparand

  4. template<typename T> bool operator<(T const & that) const;

    Lexicographical comparison operator (less).

    Parameters:
    that

    Comparand

  5. template<typename T> bool operator>(T const & that) const;

    Lexicographical comparison operator (greater).

    Parameters:
    that

    Comparand

  6. template<typename T> bool operator<=(T const & that) const;

    Lexicographical comparison operator (less or equal).

    Parameters:
    that

    Comparand

  7. template<typename T> bool operator>=(T const & that) const;

    Lexicographical comparison operator (greater or equal).

    Parameters:
    that

    Comparand

  8. 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:
    n

    Character index

    Returns:

    Constant reference to the requested character

  9. const_pointer data() const;

    Returns:

    A constant pointer to the beginning of the string

  10. const_pointer c_str() const;

    Returns:

    A constant pointer to the beginning of the string

  11. size_type size() const;

    Returns:

    The stored string length

  12. size_type length() const;

    Returns:

    The stored string length

  13. bool empty() const;

    Returns:

    true if the stored string is empty, false otherwise

  14. size_type capacity() const;

    Returns:

    size()

  15. size_type max_size() const;

    Returns:

    size()

  16. const_iterator begin() const;

    Returns:

    Constant iterator to the beginning of the string

  17. const_iterator end() const;

    Returns:

    Constant iterator to the end of the string

  18. const_reverse_iterator rbegin() const;

    Returns:

    Constant reverse iterator to the end of the string

  19. const_reverse_iterator rend() const;

    Returns:

    Constant reverse iterator to the beginning of the string

  20. size_type copy(pointer s, size_type n, size_type pos = 0) const;

    Copies a part of the stored string into external buffer

    Parameters:
    n

    Maximum number of characters to copy

    pos

    Starting position in the string to begin copying from

    s

    Pointer to the beginning of external buffer. Must not be NULL. The buffer must have enough capacity to accommodate up to n characters.

    Returns:

    The number of copied symbols

  21. 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:
    n

    Length of the substring

    pos

    Starting position of the substring

    Returns:

    The constructed substring

  22. void swap(basic_slim_string & that);

    Swaps two strings

  23. size_type find(basic_slim_string const & that, size_type pos = 0) const;

    Searches the string for a substring

    Parameters:
    pos

    Search starting position

    that

    The sought substring

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  24. size_type find(string_type const & s, size_type pos = 0) const;

    Searches the string for a substring

    Parameters:
    pos

    Search starting position

    s

    The sought substring

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  25. size_type find(const_pointer s, size_type pos = 0) const;

    Searches the string for a substring

    Parameters:
    pos

    Search starting position

    s

    The sought substring. Must point to a zero-terminated sequence of characters, must not be NULL.

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  26. size_type find(const_pointer s, size_type pos, size_type n) const;

    Searches the string for a substring

    Parameters:
    n

    Number of characters in the substring s

    pos

    Search starting position

    s

    The sought substring. Must point to a sequence of characters, must not be NULL.

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  27. size_type find(char_type c, size_type pos = 0) const;

    Searches the string for a character

    Parameters:
    c

    The sought character

    pos

    Search starting position

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  28. size_type rfind(basic_slim_string const & that, size_type pos = npos) const;

    Searches the string for a substring in the reverse direction

    Parameters:
    pos

    Search starting position

    that

    The sought substring

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  29. size_type rfind(string_type const & s, size_type pos = npos) const;

    Searches the string for a substring in the reverse direction

    Parameters:
    pos

    Search starting position

    s

    The sought substring

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  30. size_type rfind(const_pointer s, size_type pos = npos) const;

    Searches the string for a substring in the reverse direction

    Parameters:
    pos

    Search starting position

    s

    The sought substring. Must point to a zero-terminated sequence of characters, must not be NULL.

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  31. size_type rfind(const_pointer s, size_type pos, size_type n) const;

    Searches the string for a substring in the reverse direction

    Parameters:
    n

    Number of characters in the substring s

    pos

    Search starting position

    s

    The sought substring. Must point to a sequence of characters, must not be NULL.

    Returns:

    Starting position of the found substring within the string, if lookup was successful, npos otherwise

  32. size_type rfind(char_type c, size_type pos = npos) const;

    Searches the string for a character in the reverse direction

    Parameters:
    c

    The sought character

    pos

    Search starting position

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  33. 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:
    pos

    Search starting position

    that

    The set of characters being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  34. size_type find_first_of(string_type const & s, size_type pos = 0) const;

    Searches the string for one of the specified characters

    Parameters:
    pos

    Search starting position

    s

    The set of characters being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  35. size_type find_first_of(const_pointer s, size_type pos = 0) const;

    Searches the string for one of the specified characters

    Parameters:
    pos

    Search starting position

    s

    The set of characters being sought. Must point to a zero-terminated sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  36. 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:
    n

    Number of characters in the sequence s

    pos

    Search starting position

    s

    The set of characters being sought. Must point to a sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  37. size_type find_first_of(char_type c, size_type pos = 0) const;

    Searches the string for a character

    Parameters:
    c

    The sought character

    pos

    Search starting position

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  38. 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:
    pos

    Search starting position

    that

    The set of characters being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  39. 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:
    pos

    Search starting position

    s

    The set of characters being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  40. 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:
    pos

    Search starting position

    s

    The set of characters being sought. Must point to a zero-terminated sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  41. 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:
    n

    Number of characters in the sequence s

    pos

    Search starting position

    s

    The set of characters being sought. Must point to a sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  42. 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:
    c

    The sought character

    pos

    Search starting position

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  43. 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:
    pos

    Search starting position

    that

    The set of characters, that are not being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  44. 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:
    pos

    Search starting position

    s

    The set of characters, that are not being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  45. 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:
    pos

    Search starting position

    s

    The set of characters, that are not being sought. Must point to a zero-terminated sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  46. 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:
    n

    Number of characters in the sequence s

    pos

    Search starting position

    s

    The set of characters, that are not being sought. Must point to a sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  47. 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:
    c

    The character, that is not being sought

    pos

    Search starting position

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  48. 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:
    pos

    Search starting position

    that

    The set of characters, that are not being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  49. 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:
    pos

    Search starting position

    s

    The set of characters, that are not being sought

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  50. 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:
    pos

    Search starting position

    s

    The set of characters, that are not being sought. Must point to a zero-terminated sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  51. 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:
    n

    Number of characters in the sequence s

    pos

    Search starting position

    s

    The set of characters, that are not being sought. Must point to a sequence of characters, must not be NULL.

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  52. 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:
    c

    The character, that is not being sought

    pos

    Search starting position

    Returns:

    Position of the found character within the string, if lookup was successful, npos otherwise

  53. int compare(basic_slim_string const & that) const;

    Lexicographically compares the argument string to this string

    Parameters:
    that

    Comparand

    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.

  54. int compare(string_type const & s) const;

    Lexicographically compares the argument string to this string

    Parameters:
    s

    Comparand

    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.

  55. 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:
    n1

    Length of the substring of this string to perform comparison to

    pos1

    Starting position within this string to perform comparison to

    that

    Comparand

    Requires:

    pos1 + n1 < size()

    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.

  56. 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:
    n1

    Length of the substring of this string to perform comparison to

    pos1

    Starting position within this string to perform comparison to

    s

    Comparand

    Requires:

    pos1 + n1 < size()

    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.

  57. 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:
    n1

    Length of the substring of this string to perform comparison to

    n2

    Length of the substring of the comparand to perform comparison to

    pos1

    Starting position within this string to perform comparison to

    pos2

    Starting position within the comparand to perform comparison to

    that

    Comparand full string

    Requires:

    pos1 + n1 < size() && pos2 + n2 < that.size()

    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.

  58. 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:
    n1

    Length of the substring of this string to perform comparison to

    n2

    Length of the substring of the comparand to perform comparison to

    pos1

    Starting position within this string to perform comparison to

    pos2

    Starting position within the comparand to perform comparison to

    s

    Comparand full string

    Requires:

    pos1 + n1 < size() && pos2 + n2 < that.size()

    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.

  59. int compare(const_pointer s) const;

    Lexicographically compares the argument string to this string

    Parameters:
    s

    Comparand. Must point to a zero-terminated sequence of characters, must not be NULL.

    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.

  60. int compare(const_pointer s, size_type n2) const;

    Lexicographically compares the argument string to this string

    Parameters:
    n2

    Number of characters in the sequence s.

    s

    Comparand. Must point to a sequence of characters, must not be NULL.

    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.

  61. 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:
    n1

    Length of the substring of this string to perform comparison to

    pos1

    Starting position within this string to perform comparison to

    s

    Comparand. Must point to a sequence of characters, must not be NULL.

    Requires:

    pos1 + n1 < size()

    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.

  62. 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:
    n1

    Length of the substring of this string to perform comparison to

    n2

    Number of characters in the sequence s.

    pos1

    Starting position within this string to perform comparison to

    s

    Comparand. Must point to a sequence of characters, must not be NULL.

    Requires:

    pos1 + n1 < size()

    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.


PrevUpHomeNext