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 "nsIAtom.h"
11 #include "mozilla/dom/NameSpaceConstants.h"
12 
13 class txNamespaceMap;
14 
15 class txExpandedName {
16 public:
txExpandedName()17     txExpandedName() : mNamespaceID(kNameSpaceID_None)
18     {
19     }
20 
txExpandedName(int32_t aNsID,nsIAtom * aLocalName)21     txExpandedName(int32_t aNsID,
22                    nsIAtom* aLocalName) : mNamespaceID(aNsID),
23                                           mLocalName(aLocalName)
24     {
25     }
26 
txExpandedName(const txExpandedName & aOther)27     txExpandedName(const txExpandedName& aOther) :
28         mNamespaceID(aOther.mNamespaceID),
29         mLocalName(aOther.mLocalName)
30     {
31     }
32 
33     nsresult init(const nsAString& aQName, txNamespaceMap* aResolver,
34                   bool aUseDefault);
35 
reset()36     void reset()
37     {
38         mNamespaceID = kNameSpaceID_None;
39         mLocalName = nullptr;
40     }
41 
isNull()42     bool isNull()
43     {
44         return mNamespaceID == kNameSpaceID_None && !mLocalName;
45     }
46 
47     txExpandedName& operator = (const txExpandedName& rhs)
48     {
49         mNamespaceID = rhs.mNamespaceID;
50         mLocalName = rhs.mLocalName;
51         return *this;
52     }
53 
54     bool operator == (const txExpandedName& rhs) const
55     {
56         return ((mLocalName == rhs.mLocalName) &&
57                 (mNamespaceID == rhs.mNamespaceID));
58     }
59 
60     bool operator != (const txExpandedName& rhs) const
61     {
62         return ((mLocalName != rhs.mLocalName) ||
63                 (mNamespaceID != rhs.mNamespaceID));
64     }
65 
66     int32_t mNamespaceID;
67     nsCOMPtr<nsIAtom> mLocalName;
68 };
69 
70 #endif
71