NCBI C++ ToolKit
|
Search Toolkit Book for CTempString
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is known and controlled. More...
#include <corelib/tempstr.hpp>
Public Member Functions | |
CTempString (void) | |
CTempString (const char *str) | |
CTempString (const char *str, size_type len) | |
CTempString (const char *str, size_type pos, size_type len) | |
Use CTempString(const char* str + pos, size_type len - pos) instead. More... | |
CTempString (const string &str) | |
CTempString (const string &str, size_type len) | |
Use CTempString(const string& str, 0, size_type len) instead. More... | |
CTempString (const string &str, size_type pos, size_type len) | |
CTempString (const CTempString &str) | |
CTempString (const CTempString &str, size_type pos) | |
CTempString (const CTempString &str, size_type pos, size_type len) | |
void | Copy (string &dst, size_type pos, size_type len) const |
Copy a substring into a string Somewhat similar to basic_string::assign() More... | |
operator string (void) const | |
std::basic_string<> compatibility interface | |
CTempString & | assign (const char *src_str, size_type len) |
Assign new values to the content of the a string. More... | |
CTempString & | assign (const CTempString src_str) |
CTempString & | assign (const CTempString src_str, size_type pos, size_type len) |
CTempString & | operator= (const CTempString str) |
const_iterator | begin () const |
Return an iterator to the string's starting position. More... | |
const_iterator | end () const |
Return an iterator to the string's ending position (one past the end of the represented sequence) More... | |
const char * | data (void) const |
Return a pointer to the array represented. More... | |
size_type | length (void) const |
Return the length of the represented array. More... | |
size_type | size (void) const |
Return the length of the represented array. More... | |
bool | empty (void) const |
Return true if the represented string is empty (i.e., the length is zero) More... | |
void | clear (void) |
Clears the string. More... | |
void | erase (size_type pos=0) |
Truncate the string at some specified position Note: basic_string<> supports additional erase() options that we do not provide here. More... | |
size_type | find (const CTempString match, size_type pos=0) const |
Find the first instance of the entire matching string within the current string, beginning at an optional offset. More... | |
size_type | find (char match, size_type pos=0) const |
Find the first instance of a given character string within the current string in a forward direction, beginning at an optional offset. More... | |
size_type | rfind (const CTempString match, size_type pos=npos) const |
Find the first instance of the entire matching string within the current string in a backward direction, beginning at an optional offset. More... | |
size_type | rfind (char match, size_type pos=npos) const |
Find the last instance of a given character string within the current string, beginning at an optional offset. More... | |
size_type | find_first_of (const CTempString match, size_type pos=0) const |
Find the first occurrence of any character in the matching string within the current string, beginning at an optional offset. More... | |
size_type | find_first_not_of (const CTempString match, size_type pos=0) const |
Find the first occurrence of any character not in the matching string within the current string, beginning at an optional offset. More... | |
size_type | find_last_of (const CTempString match, size_type pos=npos) const |
Find the last occurrence of any character in the matching string within the current string, beginning at an optional offset. More... | |
size_type | find_last_not_of (const CTempString match, size_type pos=npos) const |
Find the last occurrence of any character not in the matching string within the current string, beginning at an optional offset. More... | |
CTempString | substr (size_type pos) const |
Obtain a substring from this string, beginning at a given offset. More... | |
CTempString | substr (size_type pos, size_type len) const |
Obtain a substring from this string, beginning at a given offset and extending a specified length. More... | |
char | operator[] (size_type pos) const |
Index into the current string and provide its character in a read- only fashion. More... | |
int | compare (const CTempString str) const |
Compare the current string with a given string. More... | |
bool | operator== (const CTempString str) const |
bool | operator!= (const CTempString str) const |
bool | operator< (const CTempString str) const |
bool | operator> (const CTempString str) const |
Private Member Functions | |
void | x_Init (const char *str, size_type str_len, size_type pos, size_type len) |
void | x_Init (const char *str, size_type str_len, size_type pos) |
Private Attributes | |
const char * | m_String |
Stored pointer to string. More... | |
size_type | m_Length |
Length of string. More... | |
std::basic_string<> compatibility typedefs and enums | |
typedef char | value_type |
typedef size_t | size_type |
typedef const char * | const_iterator |
static const size_type | npos = static_cast<size_type>(-1) |
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is known and controlled.
CTempString is designed to perform no memory allocation but provide a string interaction interface congruent with std::basic_string<char>. As such, CTempString provides a const-only access interface to its underlying storage. Care has been taken to avoid allocations and other expensive operations wherever possible.
Definition at line 64 of file tempstr.hpp.