FastString is very good!

zhaozj2021-02-08  461

The FastString class is very successful, 30% faster than String, more than 3 times the small data processing, provides a rich string processing method.

Mainly used for applications with higher performance requirements, most of which are intervals of data processing, such as server protocol processing, email protocol processing, and mail resolution processing.

/ ** * @class FastString * * @brief This class provides a wrapper facade for C strings. * * This class uses an included engine to allocate memory, * that stored one line string buffer in chars arrary and bigger * string in malloc buffer . * NOTE:. if an instance of this class is constructed from or * assigned an empty string (with first element of '/ 0'), then it * is not allocated new space Instead, its internal * representation is set equal to a . global empty string * CAUTION: in cases when FastString is constructed from a * provided buffer with the release parameter set to 0, * FastString is not guaranteed to be '/ 0' terminated * * @author Naven * /.

Template class faststring_base {protected: char m_psbuffline [bufsize]; char * m_psbuf; char * m_psrep; size_t m_nlen; size_t m_nbuflen;

Private: void init (); void allocate (const size_t size, int realock = 0);

public: FastString_Base (); FastString_Base (const FastString_Base & s); FastString_Base (const CHAR * str); FastString_Base (const CHAR * Str, const size_t len; faststring_base (const size_t len, const char c); ~ faststring_base ();

void set (const CHAR * str, size_t len); FastString_Base substring (const size_t offset, size_t length = -1) const; void substring (FastString_Base & s, const size_t offset, size_t length = -1) Const; fastString_base & append (const char * str, size_t len); int StartSwith (const char * prefix, size_t g= 0, size_t offset = 0, int ignorecase = 0) const; int equals (const CHAR * str, size_t len ​​= 0, int ignorecase = 0) const; FastString_Base & toLowerCase (); FastString_Base & toUpperCase (); FastString_Base & replace (const FastString_Base & name, const FastString_Base & value, const int ignorecase = 0); FastString_Base & replaces (FastString_Base * pNames, FastString_Base * pValues , int count, const int ignorecase = 0); char * narach (); char * clone (); void resize (size_t len, char c); Void Resize E_T LEN); void Release (); void clear ();

SIZE_T longth () const; size_t capacity () const; limited char * c_str () const; char * rep () const; // char Operator [] (size_t i) const; char charat (const size_t) i) const; operator CHAR * () const; operator const CHAR * () const; operator void * () const; operator const void * () const; FastString_Base & replaceIgnoreCase (const FastString_Base & name, const FastString_Base & value); FastString_Base & replacesIgnoreCase (FastString_Base * pNames, FastString_Base * pValues, int count); FastString_Base substr (const size_t offset, size_t length = -1) const; FastString_Base & operator = (const FastString_Base & s); FastString_Base & operator = (const CHAR * str); FastString_Base & append (const faststring_base & s); faststring_base & appen d (const CHAR * str); FastString_Base & append (const CHAR c); FastString_Base & append (const int n); FastString_Base & append (const unsigned int n) ; FastString_Base & append (const float f); int endsWith (const CHAR * suffix, size_t len ​​= 0) const; int endsWithIgnoreCase (const CHAR * suffix, size_t len ​​= 0) const; int startsWithIgnoreCase (const CHAR * prefix, size_t len ​​= 0, size_t offset = 0) const; int equalsignorecase (const char * str, size_t len ​​= 0) Const;

int equals (const FastString_Base & s) const; int equalsIgnoreCase (const FastString_Base & s) const; int getline (int pos, FastString_Base & s, const CHAR * sep = NULL); INT EMPTY () Const;

FastString_Base & trimRight (size_t offset); FastString_Base & trimLeft (size_t offset); FastString_Base & removeChar (const CHAR c); FastString_Base & removeChars (const CHAR * chrs); FastString_Base & replaceChars (const CHAR * chrs, const CHAR chr); FastString_Base & rtrimChars (const CHAR * chrs); FastString_Base & ltrimChars (const CHAR * chrs); FastString_Base & trimChars (const CHAR * chrs); FastString_Base & trimRight (); FastString_Base & trimLeft (); FastString_Base & rtrim ( ); FastString_Base & ltrim (); FastString_Base & trim (); size_t extractValueByName (const CHAR * substr, const CHAR * div1, const CHAR * div2, FastString_Base & value, Const char * VDIV, const int count = 1); size_t extractIntegerByName (const CHAR * substr, long * value, const long defval = 0); size_t extractValueByName (const CHAR * substr, FastString_Base & value, const int count = 1); size_t ExtractValuebyndex (faststring_base & value, const char tag, const INDEX);

int indexOf (CHAR target [], size_t targetCount, size_t fromIndex, const int ignorecase = 0); int indexOf (CHAR target [], size_t fromIndex = 0); int indexOfIgnoreCase (CHAR target [], size_t targetCount, size_t fromIndex); int indexOfIgnoreCase (CHAR target [], size_t fromIndex = 0); int lastIndexOf (CHAR target [], size_t targetCount, size_t fromIndex, const int ignorecase = 0); int lastIndexOf (CHAR target [], size_t fromIndex = 0); int LastIndexofignorecase (char target [], size_t margetcount, size_t fromNDEX); int LastIndexofignorecase (char target [], size_t fromNDEX = 0);

Public: Static Char * Removechars (Char * S, Const Char * Chrs); Static Char * Replacechars (Char * S, Const Char * Chrs, Const Char CHR); Static Char * RTRIMCHARS (Char * S, Const Char * CHRS) Static char * LTRIMCHARS (Char * S, Const Char * Chrs); Static Char * Trimchars (CHAR * S, Const Char * Chrs); Static Char * RTRIM (Char * S); Static Char * Ltrim (Char * S) Static char * TRIM (Char * S); Static Char * NextLine (Char * SBUF, Const Int Size, Char ** PPTR, Char ** PPCHR, Char * CHR); Static Size_t extractvalueName (const char * str, const char * substr, const CHAR * div1, const CHAR * div2, CHAR * buf, const size_t size, const CHAR * vdiv, const int count = 1); static size_t extractIntegerByName (const CHAR * str, const CHAR * substr, long * value Const long defval = 0); static size_t extractValueby Name (const CHAR * str, const CHAR * substr, CHAR * value, const size_t size, const int count = 1); static size_t extractValueByIndex (const CHAR * pstr, const size_t len, CHAR * value, const size_t valsize, const CHAR tag, const int index); static int findIndexOf (CHAR source [], size_t sourceCount, CHAR target [], size_t targetCount, size_t fromIndex = 0, const int ignorecase = 0); static int findIndexOf (CHAR source [], CHAR target [], Size_t fromNDEX = 0);

static int findIndexOfIgnoreCase (CHAR source [], size_t sourceCount, CHAR target [], size_t targetCount, size_t fromIndex = 0); static int findIndexOfIgnoreCase (CHAR source [], CHAR target [], size_t fromIndex = 0); static int findLastIndexOf ( CHAR source [], size_t sourceCount, CHAR target [], size_t targetCount, size_t fromIndex = 0, const int ignorecase = 0); static int findLastIndexOf (CHAR source [], CHAR target [], size_t fromIndex = 0); static int findLastIndexOfIgnoreCase (CHAR source [], size_t sourceCount, CHAR target [], size_t targetCount, size_t fromIndex = 0); static int findLastIndexOfIgnoreCase (CHAR source [], CHAR target [], size_t fromIndex = 0);}; typ EdEf class faststring_base faststring; type shortstring;

TypedEf class fastaray_base faststringArray; type shortstringArray;

Typedef class fastaRray_iterator FastStringArrayITOR; TYPEDEF CLASS FASTARRAY_ITERATOR ShortstringArrayITOR;

转载请注明原文地址:https://www.9cbs.com/read-135.html

New Post(0)