VSDXMLHelper.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libvisio project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef __VSDXMLHELPER_H__
11 #define __VSDXMLHELPER_H__
12 
13 #include <map>
14 #include <string>
15 #include <librevenge-stream/librevenge-stream.h>
16 #include <libxml/xmlreader.h>
17 #include "VSDTypes.h"
18 
19 namespace libvisio
20 {
21 
22 // create an xmlTextReader pointer from a librevenge::RVNGInputStream pointer
23 // needs to be freed using xmlTextReaderFree function.
24 
25 xmlTextReaderPtr xmlReaderForStream(librevenge::RVNGInputStream *input,
26  const char *URL,
27  const char *encoding,
28  int options);
29 
30 Colour xmlStringToColour(const xmlChar *s);
31 
32 long xmlStringToLong(const xmlChar *s);
33 
34 double xmlStringToDouble(const xmlChar *s);
35 
36 bool xmlStringToBool(const xmlChar *s);
37 
38 
39 class VSDCollector;
40 
41 // Helper classes to properly handle OPC relationships
42 
44 {
45 public:
46  VSDXRelationship(xmlTextReaderPtr reader);
49 
50  void rebaseTarget(const char *baseDir);
51 
52  const std::string getId() const
53  {
54  return m_id;
55  }
56  const std::string getType() const
57  {
58  return m_type;
59  }
60  const std::string getTarget() const
61  {
62  return m_target;
63  }
64 
65 private:
66  std::string m_id;
67  std::string m_type;
68  std::string m_target;
69 };
70 
72 {
73 public:
74  VSDXRelationships(librevenge::RVNGInputStream *input);
76 
77  void rebaseTargets(const char *baseDir);
78 
79  const VSDXRelationship *getRelationshipByType(const char *type) const;
80  const VSDXRelationship *getRelationshipById(const char *id) const;
81 
82  bool empty() const
83  {
84  return m_relsByType.empty() && m_relsById.empty();
85  }
86 
87 private:
88  std::map<std::string, VSDXRelationship> m_relsByType;
89  std::map<std::string, VSDXRelationship> m_relsById;
90 };
91 
92 } // namespace libvisio
93 
94 #endif // __VSDXMLHELPER_H__
95 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
std::map< std::string, VSDXRelationship > m_relsByType
Definition: VSDXMLHelper.h:88
std::map< std::string, VSDXRelationship > m_relsById
Definition: VSDXMLHelper.h:89
std::string m_id
Definition: VSDXMLHelper.h:66
const std::string getTarget() const
Definition: VSDXMLHelper.h:60
void rebaseTarget(const char *baseDir)
Definition: VSDXMLHelper.cpp:210
std::string m_type
Definition: VSDXMLHelper.h:67
~VSDXRelationships()
Definition: VSDXMLHelper.cpp:291
bool empty() const
Definition: VSDXMLHelper.h:82
const VSDXRelationship * getRelationshipById(const char *id) const
Definition: VSDXMLHelper.cpp:314
const std::string getType() const
Definition: VSDXMLHelper.h:56
std::string m_target
Definition: VSDXMLHelper.h:68
void rebaseTargets(const char *baseDir)
Definition: VSDXMLHelper.cpp:295
Definition: VSDXMLHelper.h:71
const std::string getId() const
Definition: VSDXMLHelper.h:52
Definition: VSDXMLHelper.h:43
double xmlStringToDouble(const xmlChar *s)
Definition: VSDXMLHelper.cpp:142
VSDXRelationships(librevenge::RVNGInputStream *input)
Definition: VSDXMLHelper.cpp:246
~VSDXRelationship()
Definition: VSDXMLHelper.cpp:206
Colour xmlStringToColour(const xmlChar *s)
Definition: VSDXMLHelper.cpp:92
bool xmlStringToBool(const xmlChar *s)
Definition: VSDXMLHelper.cpp:159
xmlTextReaderPtr xmlReaderForStream(librevenge::RVNGInputStream *input, const char *URL, const char *encoding, int options)
Definition: VSDXMLHelper.cpp:85
const VSDXRelationship * getRelationshipByType(const char *type) const
Definition: VSDXMLHelper.cpp:304
long xmlStringToLong(const xmlChar *s)
Definition: VSDXMLHelper.cpp:123
VSDXRelationship()
Definition: VSDXMLHelper.cpp:201

Generated for libvisio by doxygen 1.8.6