1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 
txExpandedName(const txExpandedName & aOther)22   txExpandedName(const txExpandedName& aOther)
23       : mNamespaceID(aOther.mNamespaceID), mLocalName(aOther.mLocalName) {}
24 
25   nsresult init(const nsAString& aQName, txNamespaceMap* aResolver,
26                 bool aUseDefault);
27 
reset()28   void reset() {
29     mNamespaceID = kNameSpaceID_None;
30     mLocalName = nullptr;
31   }
32 
isNull()33   bool isNull() { return mNamespaceID == kNameSpaceID_None && !mLocalName; }
34 
35   txExpandedName& operator=(const txExpandedName& rhs) {
36     mNamespaceID = rhs.mNamespaceID;
37     mLocalName = rhs.mLocalName;
38     return *this;
39   }
40 
41   bool operator==(const txExpandedName& rhs) const {
42     return ((mLocalName == rhs.mLocalName) &&
43             (mNamespaceID == rhs.mNamespaceID));
44   }
45 
46   bool operator!=(const txExpandedName& rhs) const {
47     return ((mLocalName != rhs.mLocalName) ||
48             (mNamespaceID != rhs.mNamespaceID));
49   }
50 
51   int32_t mNamespaceID;
52   RefPtr<nsAtom> mLocalName;
53 };
54 
55 #endif
56