TRF Language Model
wb::String Class Reference

a dynamic string class More...

#include <wb-string.h>

Public Member Functions

 String (int p_nLen=cn_default_str_len)
 store the top pointer. used in More...
 
 String (const char *p_str)
 
 String (const char *p_str, int nLen)
 
 String (char c)
 
 String (const String &p_str)
 
 ~String ()
 
char * Reset (int nLen)
 Reset the string leng. More...
 
char * GetBuffer () const
 get buffer More...
 
char * End () const
 get the pointer to the last position More...
 
int GetSize () const
 get buffer size More...
 
int GetLength () const
 get string length More...
 
void Clean ()
 set the string = "", but donot release the buffer More...
 
const char * Format (const char *p_pMessage,...)
 format print to string More...
 
void operator= (const String &p_str)
 operator = More...
 
void operator= (const char *pStr)
 operator = More...
 
 operator char * () const
 operator (char*) More...
 
char & operator[] (int i) const
 operator [] More...
 
String operator+= (const String &str)
 operator += More...
 
String operator+= (const char *p)
 operator += More...
 
char * Toupper ()
 to upper More...
 
char * Tolower ()
 to lower More...
 
void DeleteSub (int nLocal, int nLen)
 delete a sub-string More...
 
int Find (const char *sub)
 Find. More...
 
String Replace (const char *src, const char *rpl)
 replace More...
 
char * TokBegin (const char *p)
 split begin More...
 
char * TokSub (const char *p)
 split next More...
 
void Split (Array< String > &aStrs, const char *delimiter)
 split to string array. Using strtok(). More...
 
String FileName ()
 if the string is a path, this function return the file name. More...
 
bool operator> (const String &p_str)
 compare function More...
 
bool operator< (const String &p_str)
 
bool operator>= (const String &p_str)
 
bool operator<= (const String &p_str)
 
bool operator== (const String &p_str)
 
bool operator!= (const String &p_str)
 
bool operator> (const char *p)
 compare function More...
 
bool operator< (const char *p)
 
bool operator>= (const char *p)
 
bool operator<= (const char *p)
 
bool operator== (const char *p)
 
bool operator!= (const char *p)
 

Friends

String operator+ (const String &str, const char *p)
 
String operator+ (const char *p, const String &str)
 
String operator+ (const String &str1, const String &str2)
 

Detailed Description

a dynamic string class

A lot of function for string operation, including:

  • operation "=";
  • compare operation >/</== and so on
  • other operations.

Definition at line 53 of file wb-string.h.

Constructor & Destructor Documentation

§ String() [1/5]

wb::String::String ( int  p_nLen = cn_default_str_len)

store the top pointer. used in

Definition at line 22 of file wb-string.cpp.

§ String() [2/5]

wb::String::String ( const char *  p_str)

Definition at line 27 of file wb-string.cpp.

§ String() [3/5]

wb::String::String ( const char *  p_str,
int  nLen 
)

Definition at line 33 of file wb-string.cpp.

§ String() [4/5]

wb::String::String ( char  c)

Definition at line 40 of file wb-string.cpp.

§ String() [5/5]

wb::String::String ( const String p_str)

Definition at line 46 of file wb-string.cpp.

§ ~String()

wb::String::~String ( )

Definition at line 51 of file wb-string.cpp.

Member Function Documentation

§ Clean()

void wb::String::Clean ( )
inline

set the string = "", but donot release the buffer

Definition at line 82 of file wb-string.h.

§ DeleteSub()

void wb::String::DeleteSub ( int  nLocal,
int  nLen 
)

delete a sub-string

Definition at line 95 of file wb-string.cpp.

§ End()

char* wb::String::End ( ) const
inline

get the pointer to the last position

Definition at line 76 of file wb-string.h.

§ FileName()

String wb::String::FileName ( )

if the string is a path, this function return the file name.

Definition at line 162 of file wb-string.cpp.

§ Find()

int wb::String::Find ( const char *  sub)

Find.

Definition at line 100 of file wb-string.cpp.

§ Format()

const char * wb::String::Format ( const char *  p_pMessage,
  ... 
)

format print to string

Definition at line 69 of file wb-string.cpp.

§ GetBuffer()

char* wb::String::GetBuffer ( ) const
inline

get buffer

Definition at line 74 of file wb-string.h.

§ GetLength()

int wb::String::GetLength ( ) const
inline

get string length

Definition at line 80 of file wb-string.h.

§ GetSize()

int wb::String::GetSize ( ) const
inline

get buffer size

Definition at line 78 of file wb-string.h.

§ operator char *()

wb::String::operator char * ( ) const
inline

operator (char*)

Definition at line 90 of file wb-string.h.

§ operator!=() [1/2]

bool wb::String::operator!= ( const String p_str)
inline

Definition at line 100 of file wb-string.h.

§ operator!=() [2/2]

bool wb::String::operator!= ( const char *  p)
inline

Definition at line 111 of file wb-string.h.

§ operator+=() [1/2]

String wb::String::operator+= ( const String str)
inline

operator +=

Definition at line 103 of file wb-string.h.

§ operator+=() [2/2]

String wb::String::operator+= ( const char *  p)
inline

operator +=

Definition at line 114 of file wb-string.h.

§ operator<() [1/2]

bool wb::String::operator< ( const String p_str)
inline

Definition at line 96 of file wb-string.h.

§ operator<() [2/2]

bool wb::String::operator< ( const char *  p)
inline

Definition at line 107 of file wb-string.h.

§ operator<=() [1/2]

bool wb::String::operator<= ( const String p_str)
inline

Definition at line 98 of file wb-string.h.

§ operator<=() [2/2]

bool wb::String::operator<= ( const char *  p)
inline

Definition at line 109 of file wb-string.h.

§ operator=() [1/2]

void wb::String::operator= ( const String p_str)

operator =

Definition at line 83 of file wb-string.cpp.

§ operator=() [2/2]

void wb::String::operator= ( const char *  pStr)

operator =

Definition at line 89 of file wb-string.cpp.

§ operator==() [1/2]

bool wb::String::operator== ( const String p_str)
inline

Definition at line 99 of file wb-string.h.

§ operator==() [2/2]

bool wb::String::operator== ( const char *  p)
inline

Definition at line 110 of file wb-string.h.

§ operator>() [1/2]

bool wb::String::operator> ( const String p_str)
inline

compare function

Definition at line 95 of file wb-string.h.

§ operator>() [2/2]

bool wb::String::operator> ( const char *  p)
inline

compare function

Definition at line 106 of file wb-string.h.

§ operator>=() [1/2]

bool wb::String::operator>= ( const String p_str)
inline

Definition at line 97 of file wb-string.h.

§ operator>=() [2/2]

bool wb::String::operator>= ( const char *  p)
inline

Definition at line 108 of file wb-string.h.

§ operator[]()

char& wb::String::operator[] ( int  i) const
inline

operator []

Definition at line 92 of file wb-string.h.

§ Replace()

String wb::String::Replace ( const char *  src,
const char *  rpl 
)

replace

Definition at line 108 of file wb-string.cpp.

§ Reset()

char * wb::String::Reset ( int  nLen)

Reset the string leng.

Definition at line 56 of file wb-string.cpp.

§ Split()

void wb::String::Split ( Array< String > &  aStrs,
const char *  delimiter 
)

split to string array. Using strtok().

Definition at line 149 of file wb-string.cpp.

§ TokBegin()

char * wb::String::TokBegin ( const char *  p)
inline

split begin

Definition at line 118 of file wb-string.cpp.

§ TokSub()

char * wb::String::TokSub ( const char *  p)
inline

split next

Definition at line 123 of file wb-string.cpp.

§ Tolower()

char * wb::String::Tolower ( )

to lower

Definition at line 177 of file wb-string.cpp.

§ Toupper()

char * wb::String::Toupper ( )

to upper

Definition at line 170 of file wb-string.cpp.

Friends And Related Function Documentation

§ operator+ [1/3]

String operator+ ( const String str,
const char *  p 
)
friend

Definition at line 116 of file wb-string.h.

§ operator+ [2/3]

String operator+ ( const char *  p,
const String str 
)
friend

Definition at line 119 of file wb-string.h.

§ operator+ [3/3]

String operator+ ( const String str1,
const String str2 
)
friend

Definition at line 122 of file wb-string.h.


The documentation for this class was generated from the following files: