2015-04-09 20:25:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-08-16 06:07:37 +04:00
|
|
|
|
|
|
|
/* Classes to manage lookup of static names in a table. */
|
|
|
|
|
|
|
|
#ifndef nsStaticNameTable_h___
|
|
|
|
#define nsStaticNameTable_h___
|
|
|
|
|
2015-09-16 06:49:53 +03:00
|
|
|
#include "PLDHashTable.h"
|
2013-09-02 02:21:01 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
|
2002-10-15 02:39:44 +04:00
|
|
|
/* This class supports case insensitive lookup.
|
2000-08-16 06:07:37 +04:00
|
|
|
*
|
2002-10-15 02:39:44 +04:00
|
|
|
* It differs from atom tables:
|
2000-08-16 06:07:37 +04:00
|
|
|
* - It supports case insensitive lookup.
|
|
|
|
* - It has minimal footprint by not copying the string table.
|
|
|
|
* - It does no locking.
|
2002-10-15 02:39:44 +04:00
|
|
|
* - It returns zero based indexes and const nsCString& as required by its
|
2000-08-16 06:07:37 +04:00
|
|
|
* callers in the parser.
|
|
|
|
* - It is not an xpcom interface - meant for fast lookup in static tables.
|
|
|
|
*
|
|
|
|
* ***REQUIREMENTS***
|
2002-10-15 02:39:44 +04:00
|
|
|
* - It *requires* that all entries in the table be lowercase only.
|
2000-08-16 06:07:37 +04:00
|
|
|
* - It *requires* that the table of strings be in memory that lives at least
|
|
|
|
* as long as this table object - typically a static string array.
|
|
|
|
*/
|
|
|
|
|
2011-08-18 17:46:39 +04:00
|
|
|
class nsStaticCaseInsensitiveNameTable {
|
2000-08-16 06:07:37 +04:00
|
|
|
public:
|
|
|
|
enum { NOT_FOUND = -1 };
|
|
|
|
|
2018-07-13 13:01:53 +03:00
|
|
|
int32_t Lookup(const nsACString& aName) const;
|
|
|
|
int32_t Lookup(const nsAString& aName) const;
|
2017-06-20 12:19:05 +03:00
|
|
|
const nsCString& GetStringValue(int32_t aIndex);
|
2000-08-16 06:07:37 +04:00
|
|
|
|
2015-05-06 07:13:53 +03:00
|
|
|
nsStaticCaseInsensitiveNameTable(const char* const aNames[], int32_t aLength);
|
2000-08-16 06:07:37 +04:00
|
|
|
~nsStaticCaseInsensitiveNameTable();
|
|
|
|
|
|
|
|
private:
|
2001-11-28 00:13:53 +03:00
|
|
|
nsDependentCString* mNameArray;
|
2015-05-20 02:46:17 +03:00
|
|
|
PLDHashTable mNameTable;
|
2001-11-28 00:13:53 +03:00
|
|
|
nsDependentCString mNullStr;
|
2000-08-16 06:07:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsStaticNameTable_h___ */
|