aboutsummaryrefslogtreecommitdiff
path: root/src/staticstring.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/staticstring.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/staticstring.h b/src/staticstring.h
new file mode 100644
index 0000000..88cae70
--- /dev/null
+++ b/src/staticstring.h
@@ -0,0 +1,48 @@
1#ifndef STATIC_STRING_H
2#define STATIC_STRING_H
3
4#include <string>
5
6/**
7 * Simple string managing class. Allows for dynamically allocated string data
8 * along with some minor caching to speed things up when accessing your
9 * string data. Really designed for making copies of strings easy and safe,
10 * and making accessing meta-info like length fast and reliable as well.
11 *@author Mike Buland
12 */
13class StaticString
14{
15public:
16 StaticString();
17 StaticString( const char *lpNewStr, int nNewLen=-1 );
18 StaticString( StaticString &xSrcStr, int nNewLen=-1 );
19 StaticString( int nLength );
20 ~StaticString();
21
22 char *getString();
23 int getLength();
24 int setLength( int nNewLength );
25
26 void setString( const char *lpNewStr, int nNewLen=-1 );
27 void setString( StaticString &sNewStr, int nNewLen=-1 );
28
29 char getAt( int nIndex );
30 void setAt( int nIndex, char cVal );
31
32 class StaticString &operator=( class StaticString &lpOtherStr );
33 class StaticString &operator=( std::string &lpOtherStr );
34 class StaticString &operator=( const char *lpNewStr );
35 operator const char *();
36 char &operator[]( int nIndex );
37 operator int();
38 char *operator+( int nAmnt );
39 char *operator-( int nAmnt );
40
41 void clear();
42
43private:
44 char *lpStr;
45 int nLen;
46};
47
48#endif