1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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___
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.
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
34 enum { NOT_FOUND
= -1 };
36 bool Init(const char* const aNames
[], int32_t aLength
);
37 int32_t Lookup(const nsACString
& aName
);
38 int32_t Lookup(const nsAString
& aName
);
39 const nsAFlatCString
& GetStringValue(int32_t aIndex
);
41 nsStaticCaseInsensitiveNameTable();
42 ~nsStaticCaseInsensitiveNameTable();
45 nsDependentCString
* mNameArray
;
46 PLDHashTable mNameTable
;
47 nsDependentCString mNullStr
;
50 #endif /* nsStaticNameTable_h___ */