ASPiK SDK
xmlparser.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __xmlparser__
6 #define __xmlparser__
7 
8 #include "../lib/vstguibase.h"
9 #include "cstream.h"
10 #include <memory>
11 
12 namespace VSTGUI {
13 namespace Xml {
14 
15 class Parser;
16 
17 //-----------------------------------------------------------------------------
19 {
20 public:
21  virtual uint32_t readRawXmlData (int8_t* buffer, uint32_t size) = 0;
22  virtual void rewind () = 0;
23 };
24 
25 //-----------------------------------------------------------------------------
26 class IHandler
27 {
28 public:
29  virtual void startXmlElement (Parser* parser, IdStringPtr elementName, UTF8StringPtr* elementAttributes) = 0;
30  virtual void endXmlElement (Parser* parser, IdStringPtr name) = 0;
31  virtual void xmlCharData (Parser* parser, const int8_t* data, int32_t length) = 0;
32  virtual void xmlComment (Parser* parser, IdStringPtr comment) = 0;
33 };
34 
35 //-----------------------------------------------------------------------------
36 class Parser
37 {
38 public:
39  Parser ();
40  virtual ~Parser () noexcept;
41 
42  bool parse (IContentProvider* provider, IHandler* handler);
43 
44  bool stop ();
45 
46  IHandler* getHandler () const;
47 protected:
48  struct Impl;
49  std::unique_ptr<Impl> pImpl;
50 };
51 
52 //-----------------------------------------------------------------------------
54 {
55 public:
56  MemoryContentProvider (const void* data, uint32_t dataSize); // data must be valid the whole lifetime of this object
57  uint32_t readRawXmlData (int8_t* buffer, uint32_t size) override;
58  void rewind () override;
59 };
60 
61 //-----------------------------------------------------------------------------
63 {
64 public:
65  explicit InputStreamContentProvider (InputStream& stream);
66 
67  uint32_t readRawXmlData (int8_t* buffer, uint32_t size) override;
68  void rewind () override;
69 protected:
70  InputStream& stream;
71  int64_t startPos;
72 };
73 
74 }} // namespaces
75 
76 #endif
Definition: xmlparser.h:26
Definition: cstream.h:50
Definition: xmlparser.h:18
Definition: xmlparser.h:62
Definition: customcontrols.cpp:8
Definition: xmlparser.h:53
Definition: cstream.h:97
Definition: xmlparser.h:36