ADTF  3.18.2
cStringPiece

Class that represents string pieces. More...

Classes

class  cStringPiecePrivate
 

Public Member Functions

 cStringPiece ()
 Default constructor.
 
 cStringPiece (const cStringPiece &i_oOther)
 Copy constructor. More...
 
cStringPieceoperator= (const cStringPiece &i_oOther)
 Copy assignment. More...
 
 cStringPiece (const tChar *str)
 Constructor. More...
 
 cStringPiece (const cString &str)
 Constructor. More...
 
 cStringPiece (const tChar *offset, tInt len)
 Constructor. More...
 
const tCharGetPtr () const
 Retrieve character pointer. More...
 
tInt GetSize () const
 Retrieve the size of the string piece. More...
 
tBool IsEmpty () const
 Check if string piece is empty. More...
 
tVoid Clear ()
 Clears the string piece.
 
tVoid Set (const tChar *buffer, tInt len)
 Assigns the buffer to the string piece. More...
 
tVoid Set (const tChar *str)
 Assigns the string to the string piece. More...
 
tVoid Set (const tVoid *buffer, tInt len)
 Assigns the buffer to the string piece. More...
 
tChar operator[] (tInt i) const
 Retrieve character at the given position. More...
 
tVoid RemovePrefix (tInt n)
 Remove prefix of given length. More...
 
tVoid RemoveSuffix (tInt n)
 Remove suffix of given length. More...
 
tBool operator== (const cStringPiece &x) const
 Compare two string pieces for equality. More...
 
tBool operator!= (const cStringPiece &x) const
 Compare two string pieces for inequality. More...
 
 STRINGPIECE_BINARY_PREDICATE (<,<)
 Compare two string pieces. More...
 
 STRINGPIECE_BINARY_PREDICATE (<=,<)
 Compare two string pieces. More...
 
 STRINGPIECE_BINARY_PREDICATE (>=, >)
 Compare two string pieces. More...
 
 STRINGPIECE_BINARY_PREDICATE (>, >)
 Compare two string pieces. More...
 
tInt Compare (const cStringPiece &x) const
 Compare two string pieces. More...
 
cString AsString () const
 Return string piece as standard string. More...
 
tVoid CopyToString (cString *target) const
 Return string piece as standard string. More...
 
tBool StartsWith (const cStringPiece &x) const
 Check if this string piece starts with the given string piece. More...
 

Private Attributes

const tCharptr_
 Character pointer.
 
tInt length_
 Length of string.
 

Detailed Description

Class that represents string pieces.

Definition at line 18 of file regularexpression_helper.h.

Constructor & Destructor Documentation

◆ cStringPiece() [1/4]

cStringPiece ( const cStringPiece i_oOther)
inline

Copy constructor.

Parameters
i_oOtherOther string piece object to copy from

Definition at line 51 of file regularexpression_helper.h.

◆ cStringPiece() [2/4]

cStringPiece ( const tChar str)
inline

Constructor.

Parameters
str[in] Character pointer.

Definition at line 79 of file regularexpression_helper.h.

◆ cStringPiece() [3/4]

cStringPiece ( const cString str)
inline

Constructor.

Parameters
str[in] String.

Definition at line 90 of file regularexpression_helper.h.

◆ cStringPiece() [4/4]

cStringPiece ( const tChar offset,
tInt  len 
)
inline

Constructor.

Parameters
offset[in] Character pointer.
len[in] Length of string.

Definition at line 102 of file regularexpression_helper.h.

Member Function Documentation

◆ AsString()

cString AsString ( ) const
inline

Return string piece as standard string.

Returns
String piece as standard string.

Definition at line 332 of file regularexpression_helper.h.

References string_base< cStackString >::Empty.

◆ Compare()

tInt Compare ( const cStringPiece x) const
inline

Compare two string pieces.

Parameters
x[in] String piece to compare with.
Returns
Zero if both string pieces are equal.

Definition at line 310 of file regularexpression_helper.h.

References cStringPiece::length_, cMemoryBlock::MemCmp(), and cStringPiece::ptr_.

◆ CopyToString()

tVoid CopyToString ( cString target) const
inline

Return string piece as standard string.

Parameters
target[out] Resulting standard string.
Returns
tVoid

Definition at line 350 of file regularexpression_helper.h.

References string_base< storageT >::Set().

◆ GetPtr()

const tChar* GetPtr ( ) const
inline

Retrieve character pointer.

data() may return a pointer to a buffer with embedded NULs, and the returned buffer may or may not be null terminated. Therefore it is typically a mistake to pass data() to a routine that expects a NUL terminated string. Use "as_string().c_str()" if you really need to do this. Or better yet, change your routine so it does not rely on NUL termination.

Returns
Character pointer.

Definition at line 119 of file regularexpression_helper.h.

Referenced by cStringPiece::operator=(), and cStringPiece::StartsWith().

◆ GetSize()

tInt GetSize ( ) const
inline

Retrieve the size of the string piece.

Returns
String piece size.

Definition at line 129 of file regularexpression_helper.h.

Referenced by cStringPiece::operator=().

◆ IsEmpty()

tBool IsEmpty ( ) const
inline

Check if string piece is empty.

Returns
True, if string piece is empty.

Definition at line 139 of file regularexpression_helper.h.

◆ operator!=()

tBool operator!= ( const cStringPiece x) const
inline

Compare two string pieces for inequality.

Parameters
x[in] String piece to compare with.
Returns
True, if both string pieces are unequal.

Definition at line 263 of file regularexpression_helper.h.

◆ operator=()

cStringPiece& operator= ( const cStringPiece i_oOther)
inline

Copy assignment.

Parameters
i_oOtherOther string piece object to copy from
Returns
Reference to *this

Definition at line 63 of file regularexpression_helper.h.

References cStringPiece::GetPtr(), and cStringPiece::GetSize().

◆ operator==()

tBool operator== ( const cStringPiece x) const
inline

Compare two string pieces for equality.

Parameters
x[in] String piece to compare with.
Returns
True, if both string pieces are equal.

Definition at line 251 of file regularexpression_helper.h.

References cStringPiece::length_, cMemoryBlock::MemCmp(), and cStringPiece::ptr_.

◆ operator[]()

tChar operator[] ( tInt  i) const
inline

Retrieve character at the given position.

Parameters
i[in] Position to retrieve.
Returns
Character at the given position.

Definition at line 205 of file regularexpression_helper.h.

◆ RemovePrefix()

tVoid RemovePrefix ( tInt  n)
inline

Remove prefix of given length.

Parameters
n[in] Length of prefix to remove.
Returns
tVoid

Definition at line 221 of file regularexpression_helper.h.

◆ RemoveSuffix()

tVoid RemoveSuffix ( tInt  n)
inline

Remove suffix of given length.

Parameters
n[in] Length of suffix to remove.
Returns
tVoid

Definition at line 236 of file regularexpression_helper.h.

◆ Set() [1/3]

tVoid Set ( const tChar buffer,
tInt  len 
)
inline

Assigns the buffer to the string piece.

Parameters
buffer[in] Buffer.
len[in] Length of buffer.
Returns
tVoid

Definition at line 160 of file regularexpression_helper.h.

◆ Set() [2/3]

tVoid Set ( const tChar str)
inline

Assigns the string to the string piece.

Parameters
str[in] Null terminated string.
Returns
tVoid

Definition at line 172 of file regularexpression_helper.h.

References cStringUtil::GetLength().

◆ Set() [3/3]

tVoid Set ( const tVoid buffer,
tInt  len 
)
inline

Assigns the buffer to the string piece.

Parameters
buffer[in] Buffer.
len[in] Length of buffer.
Returns
tVoid

Definition at line 188 of file regularexpression_helper.h.

◆ StartsWith()

tBool StartsWith ( const cStringPiece x) const
inline

Check if this string piece starts with the given string piece.

Parameters
x[in] String piece to compare with.
Returns
True, if this starts with the given string piece.

Definition at line 367 of file regularexpression_helper.h.

References cStringPiece::GetPtr(), cStringPiece::length_, cMemoryBlock::MemCmp(), cStringPiece::ptr_, and tFalse.

◆ STRINGPIECE_BINARY_PREDICATE() [1/4]

STRINGPIECE_BINARY_PREDICATE ( )

Compare two string pieces.

Returns
True, if this is smaller than the given string piece based on cMemoryBlock::MemCmp.

◆ STRINGPIECE_BINARY_PREDICATE() [2/4]

STRINGPIECE_BINARY_PREDICATE ( <=  )

Compare two string pieces.

Returns
True, if this is smaller or equal than the given string piece based on cMemoryBlock::MemCmp.

◆ STRINGPIECE_BINARY_PREDICATE() [3/4]

STRINGPIECE_BINARY_PREDICATE ( )

Compare two string pieces.

Returns
True, if this is greater or equal than the given string piece based on cMemoryBlock::MemCmp.

◆ STRINGPIECE_BINARY_PREDICATE() [4/4]

STRINGPIECE_BINARY_PREDICATE ( >=  )

Compare two string pieces.

Returns
True, if this is greater than the given string piece based on cMemoryBlock::MemCmp.