1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef TRANSFRMX_EXPANDEDNAME_H
7 #define TRANSFRMX_EXPANDEDNAME_H
8 
9 #include "nsCOMPtr.h"
10 #include "nsAtom.h"
11 #include "mozilla/dom/NameSpaceConstants.h"
12 
13 class txNamespaceMap;
14 
15 class txExpandedName {
16  public:
txExpandedName()17   txExpandedName() : mNamespaceID(kNameSpaceID_None) {}
18 
txExpandedName(int32_t aNsID,nsAtom * aLocalName)19   txExpandedName(int32_t aNsID, nsAtom* aLocalName)
20       : mNamespaceID(aNsID), mLocalName(aLocalName) {}
21 
22   txExpandedName(const txExpandedName& aOther) = default;
23 
24   nsresult init(const nsAString& aQName, txNamespaceMap* aResolver,
25                 bool aUseDefault);
26 
reset()27   void reset() {
28     mNamespaceID = kNameSpaceID_None;
29     mLocalName = nullptr;
30   }
31 
isNull()32   bool isNull() { return mNamespaceID == kNameSpaceID_None && !mLocalName; }
33 
34   txExpandedName& operator=(const txExpandedName& rhs) = default;
35 
36   bool operator==(const txExpandedName& rhs) const {
37     return ((mLocalName == rhs.mLocalName) &&
38             (mNamespaceID == rhs.mNamespaceID));
39   }
40 
41   bool operator!=(const txExpandedName& rhs) const {
42     return ((mLocalName != rhs.mLocalName) ||
43             (mNamespaceID != rhs.mNamespaceID));
44   }
45 
46   int32_t mNamespaceID;
47   RefPtr<nsAtom> mLocalName;
48 };
49 
50 #endif
51