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