Bumping manifests a=b2g-bump
[gecko.git] / xpcom / ds / nsStaticNameTable.h
blob9414bcf27f2313b5f8fc31b9d12e4e2accfe63cf
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___
12 #include "pldhash.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
33 public:
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();
44 private:
45 nsDependentCString* mNameArray;
46 PLDHashTable mNameTable;
47 nsDependentCString mNullStr;
50 #endif /* nsStaticNameTable_h___ */