tagDictionary.h
Engine/source/core/tagDictionary.h
Classes:
class
Public Variables
Detailed Description
Public Variables
TagDictionary tagDictionary
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _TAGDICTIONARY_H_ 25#define _TAGDICTIONARY_H_ 26 27#ifndef _STRINGTABLE_H_ 28#include "core/stringTable.h" 29#endif 30#ifndef _TVECTOR_H_ 31#include "core/util/tVector.h" 32#endif 33 34class Stream; 35 36class TagDictionary 37{ 38 struct TagEntry 39 { 40 S32 id; 41 StringTableEntry define; 42 StringTableEntry string; 43 TagEntry *chain; // for linear traversal 44 TagEntry *defineHashLink; 45 TagEntry *idHashLink; 46 }; 47 48 TagEntry **defineHashBuckets; 49 TagEntry **idHashBuckets; 50 51 TagEntry *entryChain; 52 DataChunker mempool; 53 S32 numBuckets; 54 S32 numEntries; 55 56 bool match(const char* pattern, const char* str); 57 void sortIdVector(Vector<S32>& out_v); 58public: 59 TagDictionary(); 60 ~TagDictionary(); 61 62 //IO functions 63 // 64 bool writeHeader(Stream &); 65 66 // String/Define retrieval and search functions... 67 // 68 69 bool addEntry(S32 value, StringTableEntry define, StringTableEntry string); 70 71 StringTableEntry defineToString(StringTableEntry tag); 72 StringTableEntry idToString(S32 tag); 73 StringTableEntry idToDefine(S32 tag); 74 S32 defineToId(StringTableEntry tag); 75 76 // get IDs such that minID < IDs < maxID 77 void findIDs( Vector<S32> &v, const S32 minID, const S32 maxID ); 78 void findStrings( Vector<S32> &v, const char *pattern); 79 void findDefines( Vector<S32> &v, const char *pattern); 80}; 81 82extern TagDictionary tagDictionary; 83 84#endif //_TAGDICTIONARY_H_ 85