• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #ifndef WEBRTC_LIBJINGLE_XMLLITE_XMLNSSTACK_H_
12 #define WEBRTC_LIBJINGLE_XMLLITE_XMLNSSTACK_H_
13 
14 #include <string>
15 #include <vector>
16 #include "webrtc/libjingle/xmllite/qname.h"
17 #include "webrtc/base/scoped_ptr.h"
18 
19 namespace buzz {
20 
21 class XmlnsStack {
22 public:
23   XmlnsStack();
24   ~XmlnsStack();
25 
26   void AddXmlns(const std::string& prefix, const std::string& ns);
27   void RemoveXmlns();
28   void PushFrame();
29   void PopFrame();
30   void Reset();
31 
32   std::pair<std::string, bool> NsForPrefix(const std::string& prefix);
33   bool PrefixMatchesNs(const std::string & prefix, const std::string & ns);
34   std::pair<std::string, bool> PrefixForNs(const std::string& ns, bool isAttr);
35   std::pair<std::string, bool> AddNewPrefix(const std::string& ns, bool isAttr);
36   std::string FormatQName(const QName & name, bool isAttr);
37 
38 private:
39 
40   rtc::scoped_ptr<std::vector<std::string> > pxmlnsStack_;
41   rtc::scoped_ptr<std::vector<size_t> > pxmlnsDepthStack_;
42 };
43 }
44 
45 #endif  // WEBRTC_LIBJINGLE_XMLLITE_XMLNSSTACK_H_
46