diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-05-12 05:28:28 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-05-12 05:28:28 +0000 |
commit | 59cea3a2c49618ec7351028334d468a9204f4027 (patch) | |
tree | ed25306797b7549e14498eb2c1ee421d0d1e2e89 /src/staticstring.h | |
parent | 45b0d6d941c95ab28a143b6a78ac5c2d99b6bc4f (diff) | |
download | libbu++-59cea3a2c49618ec7351028334d468a9204f4027.tar.gz libbu++-59cea3a2c49618ec7351028334d468a9204f4027.tar.bz2 libbu++-59cea3a2c49618ec7351028334d468a9204f4027.tar.xz libbu++-59cea3a2c49618ec7351028334d468a9204f4027.zip |
Added the StaticString class, which is a slightly modified version of the old
sstring class, who's name is nonsense and now contains code specific to
squirrelmud. Anyway, StaticString is more lightweight than the std::string
class, but much less versitile. It really is just like a static string, but
all nice and classey. Great for use with the HashTable.
Diffstat (limited to 'src/staticstring.h')
-rw-r--r-- | src/staticstring.h | 48 |
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 | */ | ||
13 | class StaticString | ||
14 | { | ||
15 | public: | ||
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 | |||
43 | private: | ||
44 | char *lpStr; | ||
45 | int nLen; | ||
46 | }; | ||
47 | |||
48 | #endif | ||