cppcore
A small, portable C++ core library
Loading...
Searching...
No Matches
cppcore::TStringBase< T > Class Template Reference

This class is used to describe the inner data of a string. More...

#include <TStringBase.h>

Public Member Functions

 TStringBase () noexcept=default
 The default class constructor.
 TStringBase (const T *ptr, size_t size)
 The class constructor with a pointer showing to the data buffer.
 ~TStringBase ()
 The class destructor.
void set (const T *ptr, size_t size)
 Will set a new string.
void clear ()
 Will clear the string buffer.
void reset ()
 Will reset the string buffer, not internal storage will be released.
size_t size () const
 Returns the size of the string buffer.
bool isEmpty () const
 Will return true, if the string is empty.
size_t capacity () const
 Will return the whole capacity of the string.
const T * c_str () const
 Will return the string pointer.
bool operator== (const TStringBase< T > &rhs) const
 Compare operator.
bool operator!= (const TStringBase< T > &rhs) const
 Not equal operator.
TStringBase< T > & operator+= (const TStringBase< T > &rhs)
TStringBase< T > & operator+= (char c)
T operator[] (size_t index) const

Static Public Member Functions

static void copyFrom (TStringBase< T > &base, const T *pPtr, size_t size)
 Helper method to copy data into the string.

Detailed Description

template<class T>
class cppcore::TStringBase< T >

This class is used to describe the inner data of a string.

Definition at line 38 of file TStringBase.h.

Constructor & Destructor Documentation

◆ TStringBase() [1/2]

template<class T>
cppcore::TStringBase< T >::TStringBase ( )
defaultnoexcept

The default class constructor.

Referenced by copyFrom(), operator!=(), operator+=(), operator+=(), and operator==().

◆ TStringBase() [2/2]

template<class T>
cppcore::TStringBase< T >::TStringBase ( const T * ptr,
size_t size )
inline

The class constructor with a pointer showing to the data buffer.

Parameters
[in]ptrThe data buffer.
[in]sizeThe buffer size.

Definition at line 103 of file TStringBase.h.

References c_str(), copyFrom(), size(), and cppcore::THash< T >::toHash().

◆ ~TStringBase()

template<class T>
cppcore::TStringBase< T >::~TStringBase ( )
inline

The class destructor.

Definition at line 109 of file TStringBase.h.

References clear().

Member Function Documentation

◆ c_str()

template<class T>
const T * cppcore::TStringBase< T >::c_str ( ) const
inline

Will return the string pointer.

Returns
The string pointer.

Definition at line 143 of file TStringBase.h.

Referenced by operator+=(), operator==(), and TStringBase().

◆ capacity()

template<class T>
size_t cppcore::TStringBase< T >::capacity ( ) const
inline

Will return the whole capacity of the string.

Returns
The capacity of the string

Definition at line 138 of file TStringBase.h.

◆ clear()

template<class T>
void cppcore::TStringBase< T >::clear ( )
inline

Will clear the string buffer.

Definition at line 152 of file TStringBase.h.

References reset().

Referenced by ~TStringBase().

◆ copyFrom()

template<class T>
void cppcore::TStringBase< T >::copyFrom ( TStringBase< T > & base,
const T * pPtr,
size_t size )
inlinestatic

Helper method to copy data into the string.

Parameters
base[inout] The string data to copy in.
pPtr[in] The data source.

Definition at line 162 of file TStringBase.h.

References size(), and TStringBase().

Referenced by operator+=(), operator+=(), set(), and TStringBase().

◆ isEmpty()

template<class T>
bool cppcore::TStringBase< T >::isEmpty ( ) const
inline

Will return true, if the string is empty.

Returns
true for empty.

Definition at line 133 of file TStringBase.h.

Referenced by operator+=(), and cppcore::Logger::print().

◆ operator!=()

template<class T>
bool cppcore::TStringBase< T >::operator!= ( const TStringBase< T > & rhs) const
inline

Not equal operator.

Definition at line 200 of file TStringBase.h.

References TStringBase().

◆ operator+=() [1/2]

template<class T>
TStringBase< T > & cppcore::TStringBase< T >::operator+= ( char c)
inline

Definition at line 216 of file TStringBase.h.

References copyFrom(), and TStringBase().

◆ operator+=() [2/2]

template<class T>
TStringBase< T > & cppcore::TStringBase< T >::operator+= ( const TStringBase< T > & rhs)
inline

Definition at line 205 of file TStringBase.h.

References c_str(), copyFrom(), isEmpty(), size(), and TStringBase().

◆ operator==()

template<class T>
bool cppcore::TStringBase< T >::operator== ( const TStringBase< T > & rhs) const
inline

Compare operator.

Definition at line 186 of file TStringBase.h.

References c_str(), and TStringBase().

◆ operator[]()

template<class T>
T cppcore::TStringBase< T >::operator[] ( size_t index) const
inline

Definition at line 222 of file TStringBase.h.

◆ reset()

template<class T>
void cppcore::TStringBase< T >::reset ( )
inline

Will reset the string buffer, not internal storage will be released.

Definition at line 122 of file TStringBase.h.

Referenced by clear(), and set().

◆ set()

template<class T>
void cppcore::TStringBase< T >::set ( const T * ptr,
size_t size )
inline

Will set a new string.

Parameters
ptrPointer to the buffer.
sizeSize of the buffer.

Definition at line 114 of file TStringBase.h.

References copyFrom(), reset(), and size().

◆ size()

template<class T>
size_t cppcore::TStringBase< T >::size ( ) const
inline

Returns the size of the string buffer.

Returns
The size of the string buffer.

Definition at line 128 of file TStringBase.h.

Referenced by copyFrom(), operator+=(), cppcore::Logger::print(), set(), and TStringBase().


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