aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hashfunctionstring.cpp6
-rw-r--r--src/serializer.h6
-rw-r--r--src/serializerbinary.cpp2
-rw-r--r--src/serializerbinary.h2
-rw-r--r--src/staticstring.cpp27
-rw-r--r--src/staticstring.h4
6 files changed, 41 insertions, 6 deletions
diff --git a/src/hashfunctionstring.cpp b/src/hashfunctionstring.cpp
index 8ea9f57..6ce7bb3 100644
--- a/src/hashfunctionstring.cpp
+++ b/src/hashfunctionstring.cpp
@@ -10,12 +10,10 @@ HashFunctionString::~HashFunctionString()
10 10
11unsigned long int HashFunctionString::hash( const void *id ) 11unsigned long int HashFunctionString::hash( const void *id )
12{ 12{
13 const char *str = (const char *)id;
14 unsigned long int nPos = 0; 13 unsigned long int nPos = 0;
15 for( int j = 0; str[j] != '\0'; j++ ) 14 for( const char *s = (const char *)id; *s; s++ )
16 { 15 {
17 nPos = str[j] + (nPos << 6) + (nPos << 16) - nPos; 16 nPos = *s + (nPos << 6) + (nPos << 16) - nPos;
18// nPos += nPos<<16|(((unsigned long int)str[j])<<((j*7)%24));
19 } 17 }
20 return nPos; 18 return nPos;
21} 19}
diff --git a/src/serializer.h b/src/serializer.h
index 274d8de..334c3c7 100644
--- a/src/serializer.h
+++ b/src/serializer.h
@@ -12,6 +12,12 @@ private:
12 bool bLoading; 12 bool bLoading;
13public: 13public:
14 bool isLoading(); 14 bool isLoading();
15
16 enum
17 {
18 load = true,
19 save = false
20 };
15 21
16 Serializer(bool bLoading); 22 Serializer(bool bLoading);
17 virtual ~Serializer(); 23 virtual ~Serializer();
diff --git a/src/serializerbinary.cpp b/src/serializerbinary.cpp
index f2d8371..d7143ab 100644
--- a/src/serializerbinary.cpp
+++ b/src/serializerbinary.cpp
@@ -8,7 +8,7 @@ SerializerBinary::SerializerBinary(FILE *fhFile, bool bLoading):
8{ 8{
9} 9}
10 10
11SerializerBinary::SerializerBinary(char *sFileName, bool bLoading): 11SerializerBinary::SerializerBinary(const char *sFileName, bool bLoading):
12 Serializer(bLoading), 12 Serializer(bLoading),
13 bCloseFile(true) 13 bCloseFile(true)
14{ 14{
diff --git a/src/serializerbinary.h b/src/serializerbinary.h
index fe83ad5..2930077 100644
--- a/src/serializerbinary.h
+++ b/src/serializerbinary.h
@@ -8,7 +8,7 @@ class SerializerBinary : public Serializer
8{ 8{
9public: 9public:
10 SerializerBinary(FILE *fhFile, bool bLoading); 10 SerializerBinary(FILE *fhFile, bool bLoading);
11 SerializerBinary(char *sFileName, bool bLoading); 11 SerializerBinary(const char *sFileName, bool bLoading);
12 virtual ~SerializerBinary(); 12 virtual ~SerializerBinary();
13 13
14 virtual void close(); 14 virtual void close();
diff --git a/src/staticstring.cpp b/src/staticstring.cpp
index 24b9ecb..fa61e62 100644
--- a/src/staticstring.cpp
+++ b/src/staticstring.cpp
@@ -198,3 +198,30 @@ void StaticString::serialize( Serializer &ar )
198 } 198 }
199} 199}
200 200
201bool StaticString::operator==( const char *str )
202{
203 const char *a = str, *b = lpStr;
204 for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return true;
205 return false;
206}
207
208bool StaticString::operator==( StaticString &str )
209{
210 const char *a = str.lpStr, *b = lpStr;
211 for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return true;
212 return false;
213}
214
215bool StaticString::operator!=( const char *str )
216{
217 const char *a = str, *b = lpStr;
218 for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return false;
219 return true;
220}
221
222bool StaticString::operator!=( StaticString &str )
223{
224 const char *a = str.lpStr, *b = lpStr;
225 for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return false;
226 return true;
227}
diff --git a/src/staticstring.h b/src/staticstring.h
index 7ffa21f..732e860 100644
--- a/src/staticstring.h
+++ b/src/staticstring.h
@@ -38,6 +38,10 @@ public:
38 operator int(); 38 operator int();
39 char *operator+( int nAmnt ); 39 char *operator+( int nAmnt );
40 char *operator-( int nAmnt ); 40 char *operator-( int nAmnt );
41 bool operator==( const char *str );
42 bool operator==( StaticString &str );
43 bool operator!=( const char *str );
44 bool operator!=( StaticString &str );
41 45
42 void clear(); 46 void clear();
43 47