diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-07-14 07:55:57 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-07-14 07:55:57 +0000 |
commit | 5b650d2d0c96545c5a276a1b819d0f5baebf8204 (patch) | |
tree | e3e4a43ea242d1d1f771c7ba251f47ac7f0db296 /src | |
parent | f0f38e0f164b7e8b9132665407445d93f33be7ad (diff) | |
download | libbu++-5b650d2d0c96545c5a276a1b819d0f5baebf8204.tar.gz libbu++-5b650d2d0c96545c5a276a1b819d0f5baebf8204.tar.bz2 libbu++-5b650d2d0c96545c5a276a1b819d0f5baebf8204.tar.xz libbu++-5b650d2d0c96545c5a276a1b819d0f5baebf8204.zip |
Changed some stuff, not sure what all, minor stuff.
Diffstat (limited to 'src')
-rw-r--r-- | src/hashfunctionstring.cpp | 6 | ||||
-rw-r--r-- | src/serializer.h | 6 | ||||
-rw-r--r-- | src/serializerbinary.cpp | 2 | ||||
-rw-r--r-- | src/serializerbinary.h | 2 | ||||
-rw-r--r-- | src/staticstring.cpp | 27 | ||||
-rw-r--r-- | src/staticstring.h | 4 |
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 | ||
11 | unsigned long int HashFunctionString::hash( const void *id ) | 11 | unsigned 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; |
13 | public: | 13 | public: |
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 | ||
11 | SerializerBinary::SerializerBinary(char *sFileName, bool bLoading): | 11 | SerializerBinary::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 | { |
9 | public: | 9 | public: |
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 | ||
201 | bool 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 | |||
208 | bool 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 | |||
215 | bool 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 | |||
222 | bool 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 | ||