The Pedigree Project 0.1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
StaticString< N > Class Template Reference

#include <StaticString.h>

+ Inheritance diagram for StaticString< N >:
+ Collaboration diagram for StaticString< N >:

Public Member Functions

 StaticString ()
 
 StaticString (const char *pSrc)
 
 StaticString (const char *pSrc, size_t len)
 
 StaticString (const String &str)
 
template<unsigned int N2>
 StaticString (const StaticString< N2 > &src)
 
 operator const char * () const
 
template<unsigned int N2>
StaticString & operator+= (const StaticString< N2 > &str)
 
template<typename T >
StaticString & operator+= (const T &i)
 
void clear ()
 
void assign (const char *str, size_t len=0)
 
void assign (const String &str)
 
template<unsigned int N2>
void assign (const StaticString< N2 > &other)
 
StaticString & operator= (const char *str)
 
StaticString & operator= (const String &str)
 
bool operator== (const char *pStr) const
 
template<unsigned int N2>
bool operator== (const StaticString< N2 > &other) const
 
int last (const char search) const
 
int first (const char search) const
 
void stripLast ()
 
bool contains (const char *other) const
 
template<unsigned int N2>
bool contains (const StaticString< N2 > &other) const
 
int intValue (int nBase=0) const
 
uintptr_t uintptrValue (int nBase=0) const
 
void truncate (size_t len)
 
StaticString left (int n) const
 
StaticString right (int n) const
 
StaticString & stripFirst (size_t n=1)
 
template<typename T >
StaticString & operator<< (const T &t)
 
void append (char Char, size_t nLen=0, char c='0')
 
void append (short nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (int nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (long nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (long long nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (unsigned char nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (unsigned short nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (unsigned int nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (unsigned long nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
void append (unsigned long long nInt, size_t nRadix=10, size_t nLen=0, char c='0')
 
template<unsigned int size, typename T >
void appendInteger (T nInt, size_t nRadix, size_t nLen, char c)
 
void append (const char *str, size_t nLen=0, char c=' ')
 
void append (const String &str)
 
void appendBytes (const char *bytes, size_t numBytes)
 
template<unsigned int N2>
void append (const StaticString< N2 > &str, size_t nLen=0, char c=' ')
 
void pad (size_t nLen, char c=' ')
 
size_t length () const
 
uint64_t hash () const
 
void allowHashing (bool computeNow=false)
 
void disableHashing ()
 

Private Member Functions

void updateHash ()
 
void check ()
 
bool canAppend () const
 

Static Private Member Functions

static bool contains (const char *a, const char *b, size_t alen, size_t blen)
 

Private Attributes

char m_pData [N]
 
size_t m_Length
 
uint64_t m_Hash
 
bool m_AllowHashes
 

Detailed Description

template<unsigned int N>
class StaticString< N >

Derivative of StringBase that uses a statically allocated chunk of memory.

Definition at line 49 of file StaticString.h.

Constructor & Destructor Documentation

◆ StaticString() [1/5]

template<unsigned int N>
StaticString< N >::StaticString ( )
inline

Default constructor.

Definition at line 54 of file StaticString.h.

◆ StaticString() [2/5]

template<unsigned int N>
StaticString< N >::StaticString ( const char *  pSrc)
inlineexplicit

Creates a StaticString from a const char *. This creates a new copy of pSrc - pSrc can be safely deallocated afterwards.

Definition at line 65 of file StaticString.h.

◆ StaticString() [3/5]

template<unsigned int N>
StaticString< N >::StaticString ( const char *  pSrc,
size_t  len 
)
inline

Creates a StaticString from a const char * of a specific length. This creates a new copy of pSrc - pSrc can be safely deallocated afterwards.

Definition at line 74 of file StaticString.h.

◆ StaticString() [4/5]

template<unsigned int N>
StaticString< N >::StaticString ( const String &  str)
inline

Creates a StaticString from a String object.

Definition at line 79 of file StaticString.h.

◆ StaticString() [5/5]

template<unsigned int N>
template<unsigned int N2>
StaticString< N >::StaticString ( const StaticString< N2 > &  src)
inlineexplicit

Copy constructor - creates a StaticString from another StaticString. Copies the memory associated with src.

Definition at line 88 of file StaticString.h.

Member Function Documentation

◆ allowHashing()

template<unsigned int N>
void StaticString< N >::allowHashing ( bool  computeNow = false)
inline

Allow computing hashes for this StaticString object. Can immediately compute the hash of the string, which can be used to disable hashing when performing numerous operations on a StaticString and then enable at the end when modifications cease. This reduces the number of pointless hashes.

Definition at line 470 of file StaticString.h.

◆ append() [1/13]

template<unsigned int N>
void StaticString< N >::append ( char  Char,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 268 of file StaticString.h.

◆ append() [2/13]

template<unsigned int N>
void StaticString< N >::append ( const char *  str,
size_t  nLen = 0,
char  c = ' ' 
)
inline

Definition at line 362 of file StaticString.h.

◆ append() [3/13]

template<unsigned int N>
template<unsigned int N2>
void StaticString< N >::append ( const StaticString< N2 > &  str,
size_t  nLen = 0,
char  c = ' ' 
)
inline

Definition at line 412 of file StaticString.h.

◆ append() [4/13]

template<unsigned int N>
void StaticString< N >::append ( const String &  str)
inline

Definition at line 388 of file StaticString.h.

◆ append() [5/13]

template<unsigned int N>
void StaticString< N >::append ( int  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 283 of file StaticString.h.

◆ append() [6/13]

template<unsigned int N>
void StaticString< N >::append ( long long  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 303 of file StaticString.h.

◆ append() [7/13]

template<unsigned int N>
void StaticString< N >::append ( long  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 293 of file StaticString.h.

◆ append() [8/13]

template<unsigned int N>
void StaticString< N >::append ( short  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 273 of file StaticString.h.

◆ append() [9/13]

template<unsigned int N>
void StaticString< N >::append ( unsigned char  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 313 of file StaticString.h.

◆ append() [10/13]

template<unsigned int N>
void StaticString< N >::append ( unsigned int  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 321 of file StaticString.h.

◆ append() [11/13]

template<unsigned int N>
void StaticString< N >::append ( unsigned long long  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 329 of file StaticString.h.

◆ append() [12/13]

template<unsigned int N>
void StaticString< N >::append ( unsigned long  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 325 of file StaticString.h.

◆ append() [13/13]

template<unsigned int N>
void StaticString< N >::append ( unsigned short  nInt,
size_t  nRadix = 10,
size_t  nLen = 0,
char  c = '0' 
)
inline

Definition at line 317 of file StaticString.h.

◆ appendBytes()

template<unsigned int N>
void StaticString< N >::appendBytes ( const char *  bytes,
size_t  numBytes 
)
inline

Definition at line 392 of file StaticString.h.

◆ appendInteger()

template<unsigned int N>
template<unsigned int size, typename T >
void StaticString< N >::appendInteger ( T  nInt,
size_t  nRadix,
size_t  nLen,
char  c 
)
inline

Definition at line 334 of file StaticString.h.

◆ assign() [1/3]

template<unsigned int N>
void StaticString< N >::assign ( const char *  str,
size_t  len = 0 
)
inline

Definition at line 119 of file StaticString.h.

◆ assign() [2/3]

template<unsigned int N>
template<unsigned int N2>
void StaticString< N >::assign ( const StaticString< N2 > &  other)
inline

Definition at line 145 of file StaticString.h.

◆ assign() [3/3]

template<unsigned int N>
void StaticString< N >::assign ( const String &  str)
inline

Definition at line 140 of file StaticString.h.

◆ canAppend()

template<unsigned int N>
bool StaticString< N >::canAppend ( ) const
inlineprivate

Definition at line 503 of file StaticString.h.

◆ check()

template<unsigned int N>
void StaticString< N >::check ( )
inlineprivate

Definition at line 496 of file StaticString.h.

◆ clear()

template<unsigned int N>
void StaticString< N >::clear ( )
inline

Definition at line 112 of file StaticString.h.

◆ contains() [1/3]

template<unsigned int N>
static bool StaticString< N >::contains ( const char *  a,
const char *  b,
size_t  alen,
size_t  blen 
)
inlinestaticprivate

Definition at line 483 of file StaticString.h.

◆ contains() [2/3]

template<unsigned int N>
bool StaticString< N >::contains ( const char *  other) const
inline

Definition at line 199 of file StaticString.h.

◆ contains() [3/3]

template<unsigned int N>
template<unsigned int N2>
bool StaticString< N >::contains ( const StaticString< N2 > &  other) const
inline

Definition at line 204 of file StaticString.h.

◆ disableHashing()

template<unsigned int N>
void StaticString< N >::disableHashing ( )
inline

Stop computing hashes for this StaticString object.

Definition at line 478 of file StaticString.h.

Referenced by Log::LogEntry::LogEntry().

+ Here is the caller graph for this function:

◆ first()

template<unsigned int N>
int StaticString< N >::first ( const char  search) const
inline

Definition at line 185 of file StaticString.h.

◆ hash()

template<unsigned int N>
uint64_t StaticString< N >::hash ( ) const
inline

Definition at line 459 of file StaticString.h.

◆ intValue()

template<unsigned int N>
int StaticString< N >::intValue ( int  nBase = 0) const
inline

Definition at line 208 of file StaticString.h.

◆ last()

template<unsigned int N>
int StaticString< N >::last ( const char  search) const
inline

Definition at line 178 of file StaticString.h.

◆ left()

template<unsigned int N>
StaticString StaticString< N >::left ( int  n) const
inline

Definition at line 235 of file StaticString.h.

◆ length()

template<unsigned int N>
size_t StaticString< N >::length ( ) const
inline

Definition at line 455 of file StaticString.h.

◆ operator const char *()

template<unsigned int N>
StaticString< N >::operator const char * ( ) const
inline

Definition at line 91 of file StaticString.h.

◆ operator+=() [1/2]

template<unsigned int N>
template<unsigned int N2>
StaticString & StaticString< N >::operator+= ( const StaticString< N2 > &  str)
inline

Definition at line 96 of file StaticString.h.

◆ operator+=() [2/2]

template<unsigned int N>
template<typename T >
StaticString & StaticString< N >::operator+= ( const T &  i)
inline

Definition at line 107 of file StaticString.h.

◆ operator<<()

template<unsigned int N>
template<typename T >
StaticString & StaticString< N >::operator<< ( const T &  t)
inline

Definition at line 263 of file StaticString.h.

◆ operator=() [1/2]

template<unsigned int N>
StaticString & StaticString< N >::operator= ( const char *  str)
inline

Definition at line 149 of file StaticString.h.

◆ operator=() [2/2]

template<unsigned int N>
StaticString & StaticString< N >::operator= ( const String &  str)
inline

Definition at line 154 of file StaticString.h.

◆ operator==() [1/2]

template<unsigned int N>
bool StaticString< N >::operator== ( const char *  pStr) const
inline

Definition at line 159 of file StaticString.h.

◆ operator==() [2/2]

template<unsigned int N>
template<unsigned int N2>
bool StaticString< N >::operator== ( const StaticString< N2 > &  other) const
inline

Definition at line 168 of file StaticString.h.

◆ pad()

template<unsigned int N>
void StaticString< N >::pad ( size_t  nLen,
char  c = ' ' 
)
inline

Definition at line 438 of file StaticString.h.

◆ right()

template<unsigned int N>
StaticString StaticString< N >::right ( int  n) const
inline
Todo:
this is technically off-by-one, but I don't feel comfortable changing the behavior -Matt

Definition at line 239 of file StaticString.h.

◆ stripFirst()

template<unsigned int N>
StaticString & StaticString< N >::stripFirst ( size_t  n = 1)
inline

Definition at line 245 of file StaticString.h.

◆ stripLast()

template<unsigned int N>
void StaticString< N >::stripLast ( )
inline

Definition at line 192 of file StaticString.h.

◆ truncate()

template<unsigned int N>
void StaticString< N >::truncate ( size_t  len)
inline

Definition at line 226 of file StaticString.h.

◆ uintptrValue()

template<unsigned int N>
uintptr_t StaticString< N >::uintptrValue ( int  nBase = 0) const
inline

Definition at line 217 of file StaticString.h.

◆ updateHash()

template<unsigned int N>
void StaticString< N >::updateHash ( )
inlineprivate

Definition at line 487 of file StaticString.h.

Member Data Documentation

◆ m_AllowHashes

template<unsigned int N>
bool StaticString< N >::m_AllowHashes
private

Definition at line 515 of file StaticString.h.

◆ m_Hash

template<unsigned int N>
uint64_t StaticString< N >::m_Hash
private

Definition at line 513 of file StaticString.h.

◆ m_Length

template<unsigned int N>
size_t StaticString< N >::m_Length
private

Definition at line 512 of file StaticString.h.

◆ m_pData

template<unsigned int N>
char StaticString< N >::m_pData[N]
private

Our actual static data.

Definition at line 510 of file StaticString.h.


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