blob: 354bf0b70a5e76048d06872f2e4d0aa60d906a03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef _xmlbuilder_h_
#define _xmlbuilder_h_
#include <string>
#include <vector>
#include "webrtc/libjingle/xmllite/xmlparser.h"
#include "webrtc/base/scoped_ptr.h"
#ifdef EXPAT_RELATIVE_PATH
#include "expat.h"
#else
#include "third_party/expat/v2_0_1/Source/lib/expat.h"
#endif // EXPAT_RELATIVE_PATH
namespace buzz {
class XmlElement;
class XmlParseContext;
class XmlBuilder : public XmlParseHandler {
public:
XmlBuilder();
static XmlElement * BuildElement(XmlParseContext * pctx,
const char * name, const char ** atts);
virtual void StartElement(XmlParseContext * pctx,
const char * name, const char ** atts);
virtual void EndElement(XmlParseContext * pctx, const char * name);
virtual void CharacterData(XmlParseContext * pctx,
const char * text, int len);
virtual void Error(XmlParseContext * pctx, XML_Error);
virtual ~XmlBuilder();
void Reset();
// Take ownership of the built element; second call returns NULL
XmlElement * CreateElement();
// Peek at the built element without taking ownership
XmlElement * BuiltElement();
private:
XmlElement * pelCurrent_;
rtc::scoped_ptr<XmlElement> pelRoot_;
rtc::scoped_ptr<std::vector<XmlElement*> > pvParents_;
};
}
#endif
|