no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / xpcom / ds / nsStaticAtomUtils.h
blob8c766f63e173487074bf3f81b4a1d2d0eb578c24
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 #ifndef nsStaticAtomUtils_h
8 #define nsStaticAtomUtils_h
10 #include <stdint.h>
11 #include "nsAtom.h"
12 #include "mozilla/ArrayUtils.h"
13 #include "mozilla/Maybe.h"
15 // This class holds basic operations on arrays of static atoms.
16 class nsStaticAtomUtils {
17 public:
18 static mozilla::Maybe<uint32_t> Lookup(nsAtom* aAtom,
19 const nsStaticAtom* aAtoms,
20 uint32_t aCount) {
21 if (aAtom->IsStatic()) {
22 ptrdiff_t index = aAtom->AsStatic() - aAtoms;
23 if (index >= 0 && index < static_cast<ptrdiff_t>(aCount)) {
24 return mozilla::Some(static_cast<uint32_t>(index));
27 return mozilla::Nothing();
30 static bool IsMember(nsAtom* aAtom, const nsStaticAtom* aAtoms,
31 uint32_t aCount) {
32 return Lookup(aAtom, aAtoms, aCount).isSome();
36 #endif // nsStaticAtomUtils_h