blob: 88cae707d1fa344ad5769ea95c5dc69b00ce9471 (
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
|
#ifndef STATIC_STRING_H
#define STATIC_STRING_H
#include <string>
/**
* 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:
StaticString();
StaticString( const char *lpNewStr, int nNewLen=-1 );
StaticString( StaticString &xSrcStr, int nNewLen=-1 );
StaticString( int nLength );
~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 );
void clear();
private:
char *lpStr;
int nLen;
};
#endif
|