|
|
| version 1.19, 2001/03/07 11:14:11 | version 1.26, 2001/03/18 12:10:55 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| $Id$ | Parser |
| */ | Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | |
| /* | |
| $Id$ | |
| */ | */ |
| #ifndef PA_HASH_H | #ifndef PA_HASH_H |
| Line 16 | Line 15 |
| #include "pa_types.h" | #include "pa_types.h" |
| #include "pa_string.h" | #include "pa_string.h" |
| class Hash : virtual public Pooled { | class Hash : public Pooled { |
| public: | public: |
| typedef String Key; | typedef String Key; |
| typedef void Value; | typedef void Value; |
| typedef void (*Foreach_func)(const Key& key, Value *value, void *info); | |
| public: | public: |
| Hash(Pool& apool,bool) : Pooled(apool) { construct(apool, true); } | Hash(Pool& apool,bool athread_safe=false) : Pooled(apool) { |
| Hash(Pool& apool) : Pooled(apool) { construct(apool, false); } | construct(apool, athread_safe); |
| } | |
| // useful generic hash function | // useful generic hash function |
| static uint generic_code(uint aresult, const char *start, uint allocated); | static uint generic_code(uint aresult, const char *start, uint allocated); |
| Line 49 public: | Line 51 public: |
| void put(const Key& key, String *value) { put(key, static_cast<Value *>(value)); } | void put(const Key& key, String *value) { put(key, static_cast<Value *>(value)); } |
| int get_int(const Key& key) { return reinterpret_cast<int>(get(key)); } | int get_int(const Key& key) { return reinterpret_cast<int>(get(key)); } |
| String *get_string(const Key& key) { return static_cast<String *>(get(key)); } | const String *get_string(const Key& key) { return static_cast<String *>(get(key)); } |
| int size() { return used; } | int size() { return used; } |
| void foreach(Foreach_func func, void *info=0); | |
| protected: | protected: |
| void construct(Pool& apool, bool athread_safe); | void construct(Pool& apool, bool athread_safe); |