xpcom/ds/nsStaticNameTable.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial