txNamespaceMap.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef TRANSFRMX_TXNAMESPACEMAP_H
  6. #define TRANSFRMX_TXNAMESPACEMAP_H
  7. #include "nsIAtom.h"
  8. #include "nsCOMArray.h"
  9. #include "nsTArray.h"
  10. class txNamespaceMap
  11. {
  12. public:
  13. txNamespaceMap();
  14. txNamespaceMap(const txNamespaceMap& aOther);
  15. nsrefcnt AddRef()
  16. {
  17. return ++mRefCnt;
  18. }
  19. nsrefcnt Release()
  20. {
  21. if (--mRefCnt == 0) {
  22. mRefCnt = 1; //stabilize
  23. delete this;
  24. return 0;
  25. }
  26. return mRefCnt;
  27. }
  28. nsresult mapNamespace(nsIAtom* aPrefix, const nsAString& aNamespaceURI);
  29. int32_t lookupNamespace(nsIAtom* aPrefix);
  30. int32_t lookupNamespaceWithDefault(const nsAString& aPrefix);
  31. private:
  32. nsAutoRefCnt mRefCnt;
  33. nsCOMArray<nsIAtom> mPrefixes;
  34. nsTArray<int32_t> mNamespaces;
  35. };
  36. #endif //TRANSFRMX_TXNAMESPACEMAP_H