blob: 61501bfb73ff37c5ff14a54a8847985c7f028681 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#ifndef STATIC_STRING_H
#define STATIC_STRING_H
#include <string>
#include "serializable.h"
//#include "hashable.h"
/**
* Simple string managing class. Allows for dynamically allocated string data
* along with some minor caching to speed things up when accessing your
* string data. Really designed for making copies of strings easy and safe,
* and making accessing meta-info like length fast and reliable as well.
*@author Mike Buland
*/
class StaticString : public Serializable//, public Hashable
{
public:
StaticString();
StaticString( const char *lpNewStr, int nNewLen );
StaticString( const char *lpNewStr );
StaticString( StaticString &xSrcStr, int nNewLen );
StaticString( StaticString &xSrcStr );
StaticString( int nLength );
virtual ~StaticString();
char *getString();
int getLength();
int setLength( int nNewLength );
void setString( const char *lpNewStr, int nNewLen=-1 );
void setString( StaticString &sNewStr, int nNewLen=-1 );
char getAt( int nIndex );
void setAt( int nIndex, char cVal );
class StaticString &operator=( class StaticString &lpOtherStr );
class StaticString &operator=( std::string &lpOtherStr );
class StaticString &operator=( const char *lpNewStr );
operator const char *();
char &operator[]( int nIndex );
operator int();
char *operator+( int nAmnt );
char *operator-( int nAmnt );
bool operator==( const char *str );
bool operator==( StaticString &str );
bool operator!=( const char *str );
bool operator!=( StaticString &str );
void clear();
virtual void serialize( class Serializer &ar );
virtual unsigned long int getHashCode();
private:
char *lpStr;
uint32_t nLen;
};
#endif
|