CppCMS
|
This is a special object that may hold an std::string or alternatively reference to external (unowned) chunk of text. More...
#include <cppcms/string_key.h>
Public Types | |
typedef char const * | const_iterator |
Public Member Functions | |
string_key () | |
string_key (char const *key) | |
string_key (std::string const &key) | |
size_t | size () const |
size_t | length () const |
void | clear () |
bool | empty () const |
size_t | find (char c, size_t pos=0) const |
string_key | substr (size_t pos=0, size_t n=npos) const |
string_key | unowned_substr (size_t pos=0, size_t n=npos) const |
char const & | operator[] (size_t n) const |
char const & | at (size_t n) const |
char const * | begin () const |
char const * | end () const |
bool | operator< (string_key const &other) const |
bool | operator> (string_key const &other) const |
bool | operator>= (string_key const &other) const |
bool | operator<= (string_key const &other) const |
bool | operator== (string_key const &other) const |
bool | operator!= (string_key const &other) const |
char const * | data () const |
std::string | str () const |
operator std::string () const | |
Static Public Member Functions | |
static string_key | unowned (std::string const &v) |
static string_key | unowned (char const *str) |
static string_key | unowned (char const *begin, char const *end) |
Static Public Attributes | |
static const size_t | npos = -1 |
This is a special object that may hold an std::string or alternatively reference to external (unowned) chunk of text.
It is designed to be used for efficiency and reduce amount of memory allocations and copies.
It has interface that is roughly similar to the interface of std::string, but it does not provide a members that can mutate it or provide a NUL terminated string c_str().
typedef char const* cppcms::string_key::const_iterator |
Iterator type
|
inline |
Default constructor - empty key
Referenced by operator std::string(), substr(), unowned(), and unowned_substr().
|
inline |
Create a new string copying the key
|
inline |
Create a new string copying the key
|
inline |
|
inline |
Get a pointer to the first character in the string
Referenced by at(), data(), empty(), find(), operator<(), operator==(), operator[](), size(), substr(), and unowned_substr().
|
inline |
Clear the string
|
inline |
Get the pointer to the first character in the string. Note it should not be NUL terminated
References begin().
Referenced by cppcms::operator<<().
|
inline |
|
inline |
Get a pointer to the one past last character in the string
Referenced by empty(), operator<(), operator==(), size(), substr(), unowned(), and unowned_substr().
|
inline |
|
inline |
Convert the key to the std::string
References str(), and string_key().
|
inline |
Compare two strings
|
inline |
|
inline |
Compare two strings
|
inline |
|
inline |
Compare two strings
|
inline |
Compare two strings
|
inline |
Get a character at position n
References begin().
|
inline |
String size in bytes
References begin(), and end().
Referenced by at(), find(), length(), cppcms::operator<<(), and unowned_substr().
|
inline |
Create std::string from the key
Referenced by operator std::string(), and unowned().
|
inline |
Create a substring from this string starting from character pos of size at most n
References begin(), end(), string_key(), and unowned_substr().
|
inlinestatic |
Create a string from v without copying the memory. v should remain valid as long as this object is used
References string_key().
Referenced by cppcms::operator!=(), cppcms::operator<(), cppcms::operator<=(), cppcms::operator==(), cppcms::operator>(), and cppcms::operator>=().
|
inlinestatic |
Create a string from str without copying the memory. str should remain valid as long as this object is used
References end(), str(), and string_key().
|
inlinestatic |
Create a string from characters at rang [begin,end) without copying the memory. The range should remain valid as long as this object is used
References string_key().
|
inline |
Create a substring from this string starting from character pos of size at most n such that the memory is not copied but only reference by the created substring
References begin(), end(), size(), and string_key().
Referenced by substr().
|
static |
The last position of the character in the string
Referenced by find().