blob: 732e860b15e13dd8522e3f35e6ee753edf89fcaa (
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
|
#ifndef STATIC_STRING_H
#define STATIC_STRING_H
#include <string>
#include "serializable.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:
StaticString();
StaticString( const char *lpNewStr, int nNewLen=-1 );
StaticString( StaticString &xSrcStr, int nNewLen=-1 );
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 );
private:
char *lpStr;
int nLen;
};
#endif
|