gecko-dev/xpcom/ds/nsStaticNameTable.h

51 строка
1.6 KiB
C
Исходник Обычный вид История

2000-08-16 06:07:37 +04:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
2012-05-21 15:12:37 +04:00
* This Source Code Form is subject to the terms of the Mozilla Public
* 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___
#include "pldhash.h"
2013-09-02 02:21:01 +04:00
#include "nsString.h"
/* This class supports case insensitive lookup.
2000-08-16 06:07:37 +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.
* - 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***
* - 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.
*/
class nsStaticCaseInsensitiveNameTable
2000-08-16 06:07:37 +04:00
{
public:
enum { NOT_FOUND = -1 };
bool Init(const char* const aNames[], int32_t Count);
int32_t Lookup(const nsACString& aName);
int32_t Lookup(const nsAString& aName);
const nsAFlatCString& GetStringValue(int32_t index);
2000-08-16 06:07:37 +04:00
nsStaticCaseInsensitiveNameTable();
~nsStaticCaseInsensitiveNameTable();
private:
nsDependentCString* mNameArray;
PLDHashTable mNameTable;
nsDependentCString mNullStr;
2000-08-16 06:07:37 +04:00
};
#endif /* nsStaticNameTable_h___ */