no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / xpcom / ds / nsStaticNameTable.h
blob302d82c1e4ad213783ffa9dcdd7b4fafb185e811
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Classes to manage lookup of static names in a table. */
9 #ifndef nsStaticNameTable_h___
10 #define nsStaticNameTable_h___
12 #include "PLDHashTable.h"
13 #include "nsString.h"
15 /* This class supports case insensitive lookup.
17 * It differs from atom tables:
18 * - It supports case insensitive lookup.
19 * - It has minimal footprint by not copying the string table.
20 * - It does no locking.
21 * - It returns zero based indexes and const nsCString& as required by its
22 * callers in the parser.
23 * - It is not an xpcom interface - meant for fast lookup in static tables.
25 * ***REQUIREMENTS***
26 * - It *requires* that all entries in the table be lowercase only.
27 * - It *requires* that the table of strings be in memory that lives at least
28 * as long as this table object - typically a static string array.
31 class nsStaticCaseInsensitiveNameTable {
32 public:
33 enum { NOT_FOUND = -1 };
35 int32_t Lookup(const nsACString& aName) const;
36 int32_t Lookup(const nsAString& aName) const;
37 const nsCString& GetStringValue(int32_t aIndex);
39 nsStaticCaseInsensitiveNameTable(const char* const aNames[], int32_t aLength);
40 ~nsStaticCaseInsensitiveNameTable();
42 private:
43 nsDependentCString* mNameArray;
44 PLDHashTable mNameTable;
45 nsDependentCString mNullStr;
48 #endif /* nsStaticNameTable_h___ */