michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* Classes to manage lookup of static names in a table. */ michael@0: michael@0: #ifndef nsStaticNameTable_h___ michael@0: #define nsStaticNameTable_h___ michael@0: michael@0: #include "pldhash.h" michael@0: #include "nsString.h" michael@0: michael@0: /* This class supports case insensitive lookup. michael@0: * michael@0: * It differs from atom tables: michael@0: * - It supports case insensitive lookup. michael@0: * - It has minimal footprint by not copying the string table. michael@0: * - It does no locking. michael@0: * - It returns zero based indexes and const nsCString& as required by its michael@0: * callers in the parser. michael@0: * - It is not an xpcom interface - meant for fast lookup in static tables. michael@0: * michael@0: * ***REQUIREMENTS*** michael@0: * - It *requires* that all entries in the table be lowercase only. michael@0: * - It *requires* that the table of strings be in memory that lives at least michael@0: * as long as this table object - typically a static string array. michael@0: */ michael@0: michael@0: class nsStaticCaseInsensitiveNameTable michael@0: { michael@0: public: michael@0: enum { NOT_FOUND = -1 }; michael@0: michael@0: bool Init(const char* const aNames[], int32_t Count); michael@0: int32_t Lookup(const nsACString& aName); michael@0: int32_t Lookup(const nsAString& aName); michael@0: const nsAFlatCString& GetStringValue(int32_t index); michael@0: michael@0: nsStaticCaseInsensitiveNameTable(); michael@0: ~nsStaticCaseInsensitiveNameTable(); michael@0: michael@0: private: michael@0: nsDependentCString* mNameArray; michael@0: PLDHashTable mNameTable; michael@0: nsDependentCString mNullStr; michael@0: }; michael@0: michael@0: #endif /* nsStaticNameTable_h___ */