xmlbuilder.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_XMLBUILDER_H_
  11. #define THIRD_PARTY_LIBJINGLE_XMPP_XMLLITE_XMLBUILDER_H_
  12. #include <memory>
  13. #include <string>
  14. #include <vector>
  15. #include "third_party/libjingle_xmpp/xmllite/xmlparser.h"
  16. #ifdef EXPAT_RELATIVE_PATH
  17. #include "expat.h"
  18. #else
  19. #include "third_party/expat/v2_0_1/Source/lib/expat.h"
  20. #endif // EXPAT_RELATIVE_PATH
  21. namespace jingle_xmpp {
  22. class XmlElement;
  23. class XmlParseContext;
  24. class XmlBuilder : public XmlParseHandler {
  25. public:
  26. XmlBuilder();
  27. static XmlElement * BuildElement(XmlParseContext * pctx,
  28. const char * name, const char ** atts);
  29. virtual void StartElement(XmlParseContext * pctx,
  30. const char * name, const char ** atts);
  31. virtual void EndElement(XmlParseContext * pctx, const char * name);
  32. virtual void CharacterData(XmlParseContext * pctx,
  33. const char * text, int len);
  34. virtual void Error(XmlParseContext * pctx, XML_Error);
  35. virtual ~XmlBuilder();
  36. void Reset();
  37. // Take ownership of the built element; second call returns NULL
  38. XmlElement * CreateElement();
  39. // Peek at the built element without taking ownership
  40. XmlElement * BuiltElement();
  41. private:
  42. XmlElement * pelCurrent_;
  43. std::unique_ptr<XmlElement> pelRoot_;
  44. std::unique_ptr<std::vector<XmlElement*> > pvParents_;
  45. };
  46. }
  47. #endif // THIRD_PARTY_LIBJINGLE_XMPP_XMLLITE_XMLBUILDER_H_