blob: 354bf0b70a5e76048d06872f2e4d0aa60d906a03 [file] [log] [blame]
henrike@webrtc.org48a7b2e2014-09-02 15:41:121/*
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 _xmlbuilder_h_
12#define _xmlbuilder_h_
13
14#include <string>
15#include <vector>
16#include "webrtc/libjingle/xmllite/xmlparser.h"
17#include "webrtc/base/scoped_ptr.h"
18
19#ifdef EXPAT_RELATIVE_PATH
20#include "expat.h"
21#else
22#include "third_party/expat/v2_0_1/Source/lib/expat.h"
23#endif // EXPAT_RELATIVE_PATH
24
25namespace buzz {
26
27class XmlElement;
28class XmlParseContext;
29
30
31class XmlBuilder : public XmlParseHandler {
32public:
33 XmlBuilder();
34
35 static XmlElement * BuildElement(XmlParseContext * pctx,
36 const char * name, const char ** atts);
37 virtual void StartElement(XmlParseContext * pctx,
38 const char * name, const char ** atts);
39 virtual void EndElement(XmlParseContext * pctx, const char * name);
40 virtual void CharacterData(XmlParseContext * pctx,
41 const char * text, int len);
42 virtual void Error(XmlParseContext * pctx, XML_Error);
43 virtual ~XmlBuilder();
44
45 void Reset();
46
47 // Take ownership of the built element; second call returns NULL
48 XmlElement * CreateElement();
49
50 // Peek at the built element without taking ownership
51 XmlElement * BuiltElement();
52
53private:
54 XmlElement * pelCurrent_;
55 rtc::scoped_ptr<XmlElement> pelRoot_;
56 rtc::scoped_ptr<std::vector<XmlElement*> > pvParents_;
57};
58
59}
60
61#endif