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
cppcms::string_key::string_key | ( | ) | [inline] |
Default constructor - empty key
Referenced by substr(), unowned(), and unowned_substr().
cppcms::string_key::string_key | ( | char const * | key | ) | [inline] |
Create a new string copying the key
cppcms::string_key::string_key | ( | std::string const & | key | ) | [inline] |
Create a new string copying the key
char const& cppcms::string_key::at | ( | size_t | n | ) | const [inline] |
char const* cppcms::string_key::begin | ( | ) | const [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().
void cppcms::string_key::clear | ( | ) | [inline] |
Clear the string
char const* cppcms::string_key::data | ( | ) | const [inline] |
Get the pointer to the first character in the string. Note it should not be NUL terminated
References begin().
Referenced by cppcms::operator<<().
bool cppcms::string_key::empty | ( | ) | const [inline] |
char const* cppcms::string_key::end | ( | ) | const [inline] |
Get a pointer to the one past last character in the string
Referenced by empty(), operator<(), operator==(), size(), substr(), unowned(), and unowned_substr().
size_t cppcms::string_key::find | ( | char | c, |
size_t | pos = 0 |
||
) | const [inline] |
size_t cppcms::string_key::length | ( | ) | const [inline] |
cppcms::string_key::operator std::string | ( | ) | const [inline] |
Convert the key to the std::string
References str().
bool cppcms::string_key::operator!= | ( | string_key const & | other | ) | const [inline] |
Compare two strings
bool cppcms::string_key::operator< | ( | string_key const & | other | ) | const [inline] |
bool cppcms::string_key::operator<= | ( | string_key const & | other | ) | const [inline] |
Compare two strings
bool cppcms::string_key::operator== | ( | string_key const & | other | ) | const [inline] |
bool cppcms::string_key::operator> | ( | string_key const & | other | ) | const [inline] |
Compare two strings
bool cppcms::string_key::operator>= | ( | string_key const & | other | ) | const [inline] |
Compare two strings
char const& cppcms::string_key::operator[] | ( | size_t | n | ) | const [inline] |
Get a character at position n
References begin().
size_t cppcms::string_key::size | ( | ) | const [inline] |
String size in bytes
References begin(), and end().
Referenced by at(), find(), length(), cppcms::operator<<(), and unowned_substr().
std::string cppcms::string_key::str | ( | ) | const [inline] |
Create std::string from the key
Referenced by operator std::string(), and unowned().
string_key cppcms::string_key::substr | ( | size_t | pos = 0 , |
size_t | n = npos |
||
) | const [inline] |
Create a substring from this string starting from character pos of size at most n
References begin(), end(), string_key(), and unowned_substr().
static string_key cppcms::string_key::unowned | ( | std::string const & | v | ) | [inline, static] |
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>=().
static string_key cppcms::string_key::unowned | ( | char const * | str | ) | [inline, static] |
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().
static string_key cppcms::string_key::unowned | ( | char const * | begin, |
char const * | end | ||
) | [inline, static] |
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().
string_key cppcms::string_key::unowned_substr | ( | size_t | pos = 0 , |
size_t | n = npos |
||
) | const [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().
const size_t cppcms::string_key::npos = -1 [static] |
The last position of the character in the string
Referenced by find().