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)
 
template<unsigned int N2>
 StaticString (const StaticString< N2 > &src)
 
 operator const char * () const
 
template<unsigned int N2>
StaticStringoperator+= (const StaticString< N2 > &str)
 
template<typename T >
StaticStringoperator+= (T i)
 
void clear ()
 
void assign (const char *str, size_t len=0)
 
template<unsigned int N2>
void assign (const StaticString< N2 > &other)
 
StaticStringoperator= (const char *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
 
StaticStringstripFirst (size_t n=1)
 
template<typename T >
StaticStringoperator<< (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 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 47 of file StaticString.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 53 of file StaticString.h.

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.

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 75 of file StaticString.h.

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 85 of file StaticString.h.

Member Function Documentation

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 563 of file StaticString.h.

Referenced by Log::flushEntry().

+ Here is the caller graph for this function:

template<unsigned int N>
void StaticString< N >::append ( const char *  str,
size_t  nLen = 0,
char  c = ' ' 
)
inline
Todo:
this is unsafe - StringLength is unconstrained.

Definition at line 393 of file StaticString.h.

template<unsigned int N>
void StaticString< N >::assign ( const char *  str,
size_t  len = 0 
)
inline
Note
not using memmove - don't assign() a StaticString to itself

Definition at line 120 of file StaticString.h.

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

Stop computing hashes for this StaticString object.

Definition at line 573 of file StaticString.h.

Referenced by Log::flushEntry(), and Log::LogEntry::LogEntry().

+ Here is the caller graph for this function:

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 249 of file StaticString.h.

Referenced by MemoryInspector::execute().

+ Here is the caller graph for this function:

Member Data Documentation

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

Our actual static data.

Definition at line 612 of file StaticString.h.

Referenced by StaticString< LOG_LENGTH >::assign().


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