Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
strhash.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2002 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_STRHASH_H__ 00020 #define __CS_STRHASH_H__ 00021 00022 #include "csextern.h" 00023 #include "hash.h" 00024 #include "hashhandlers.h" 00025 00035 typedef uint32 csStringID; 00037 csStringID const csInvalidStringID = (csStringID) ~0; 00038 00039 class csStringHashIterator; 00040 00048 class CS_CSUTIL_EXPORT csStringHash 00049 { 00050 private: 00051 friend class csStringHashIterator; 00052 00053 struct csRegisteredString 00054 { 00055 typedef csStringID IDtype; 00056 IDtype ID; 00057 //char String[]; 00058 00059 static csRegisteredString* Alloc (const char* str); 00060 static void Free (csRegisteredString* regStr); 00061 const char* GetString() const { return ((char*)this) + sizeof (IDtype); } 00062 }; 00063 00064 csHash<csRegisteredString*, const char*, csConstCharHashKeyHandler> Registry; 00065 00066 public: 00068 csStringHash (int size = 23); 00070 ~csStringHash (); 00071 00082 const char* Register (const char* s, csStringID id); 00083 00089 csStringID Request (const char* s) const; 00090 00099 const char* Request (csStringID id) const; 00100 00104 void Clear (); 00105 }; 00106 00112 class CS_CSUTIL_EXPORT csStringHashIterator 00113 { 00114 friend class csStringHash; 00115 00116 private: 00117 //csGlobalHashIterator* hashIt; 00118 csHash<csStringHash::csRegisteredString*, const char*, 00119 csConstCharHashKeyHandler>::GlobalIterator hashIt; 00120 00121 public: 00122 00128 csStringHashIterator (csStringHash*); 00130 virtual ~csStringHashIterator (); 00131 00133 bool HasNext (); 00135 csStringID Next (); 00136 }; 00137 00138 #endif // __CS_STRHASH_H__
Generated for Crystal Space by doxygen 1.3.9.1