xmlnsstack.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2004 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef THIRD_PARTY_LIBJINGLE_XMPP_XMLLITE_XMLNSSTACK_H_
  11. #define THIRD_PARTY_LIBJINGLE_XMPP_XMLLITE_XMLNSSTACK_H_
  12. #include <memory>
  13. #include <string>
  14. #include <vector>
  15. #include "third_party/libjingle_xmpp/xmllite/qname.h"
  16. namespace jingle_xmpp {
  17. class XmlnsStack {
  18. public:
  19. XmlnsStack();
  20. ~XmlnsStack();
  21. void AddXmlns(const std::string& prefix, const std::string& ns);
  22. void RemoveXmlns();
  23. void PushFrame();
  24. void PopFrame();
  25. void Reset();
  26. std::pair<std::string, bool> NsForPrefix(const std::string& prefix);
  27. bool PrefixMatchesNs(const std::string & prefix, const std::string & ns);
  28. std::pair<std::string, bool> PrefixForNs(const std::string& ns, bool isAttr);
  29. std::pair<std::string, bool> AddNewPrefix(const std::string& ns, bool isAttr);
  30. std::string FormatQName(const QName & name, bool isAttr);
  31. private:
  32. std::unique_ptr<std::vector<std::string> > pxmlnsStack_;
  33. std::unique_ptr<std::vector<size_t> > pxmlnsDepthStack_;
  34. };
  35. }
  36. #endif // THIRD_PARTY_LIBJINGLE_XMPP_XMLLITE_XMLNSSTACK_H_