NCBI C++ ToolKit
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CTempString Class Reference

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>

+ Inheritance diagram for CTempString:
+ Collaboration diagram for CTempString:

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
CTempStringassign (const char *src_str, size_type len)
 Assign new values to the content of the a string. More...
 
CTempStringassign (const CTempString src_str)
 
CTempStringassign (const CTempString src_str, size_type pos, size_type len)
 
CTempStringoperator= (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>(-1L)
 

Detailed Description

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.

Examples
/home/coremake/doxygen/cxx/include/corelib/ncbistr.hpp, and /home/coremake/doxygen/cxx/include/util/row_reader_base.hpp.

Definition at line 64 of file tempstr.hpp.


The documentation for this class was generated from the following files:
Modified on Mon Jul 22 05:08:26 2024 by modify_doxy.py rev. 669887