VSDXMLHelper.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libvisio
3  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License or as specified alternatively below. You may obtain a copy of
8  * the License at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * Major Contributor(s):
16  * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
17  *
18  *
19  * All Rights Reserved.
20  *
21  * For minor contributions see the git repository.
22  *
23  * Alternatively, the contents of this file may be used under the terms of
24  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
25  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
26  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
27  * instead of those above.
28  */
29 
30 #ifndef __VSDXMLHELPER_H__
31 #define __VSDXMLHELPER_H__
32 
33 #include <map>
34 #include <string>
35 #include <libwpd-stream/libwpd-stream.h>
36 #include <libxml/xmlreader.h>
37 #include "VSDTypes.h"
38 
39 namespace libvisio
40 {
41 
42 // create an xmlTextReader pointer from a WPXInputStream pointer
43 // needs to be freed using xmlTextReaderFree function.
44 
45 xmlTextReaderPtr xmlReaderForStream(WPXInputStream *input,
46  const char *URL,
47  const char *encoding,
48  int options);
49 
50 Colour xmlStringToColour(const xmlChar *s);
51 
52 long xmlStringToLong(const xmlChar *s);
53 
54 double xmlStringToDouble(const xmlChar *s);
55 
56 bool xmlStringToBool(const xmlChar *s);
57 
58 
59 class VSDCollector;
60 
61 // Helper classes to properly handle OPC relationships
62 
64 {
65 public:
66  VSDXRelationship(xmlTextReaderPtr reader);
69 
70  void rebaseTarget(const char *baseDir);
71 
72  const std::string getId() const
73  {
74  return m_id;
75  }
76  const std::string getType() const
77  {
78  return m_type;
79  }
80  const std::string getTarget() const
81  {
82  return m_target;
83  }
84 
85 private:
86  std::string m_id;
87  std::string m_type;
88  std::string m_target;
89 };
90 
92 {
93 public:
94  VSDXRelationships(WPXInputStream *input);
96 
97  void rebaseTargets(const char *baseDir);
98 
99  const VSDXRelationship *getRelationshipByType(const char *type) const;
100  const VSDXRelationship *getRelationshipById(const char *id) const;
101 
102  bool empty() const
103  {
104  return m_relsByType.empty() && m_relsById.empty();
105  }
106 
107 private:
108  std::map<std::string, VSDXRelationship> m_relsByType;
109  std::map<std::string, VSDXRelationship> m_relsById;
110 };
111 
112 } // namespace libvisio
113 
114 #endif // __VSDXMLHELPER_H__
115 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
std::map< std::string, VSDXRelationship > m_relsByType
Definition: VSDXMLHelper.h:108
std::map< std::string, VSDXRelationship > m_relsById
Definition: VSDXMLHelper.h:109
std::string m_id
Definition: VSDXMLHelper.h:86
const std::string getTarget() const
Definition: VSDXMLHelper.h:80
void rebaseTarget(const char *baseDir)
Definition: VSDXMLHelper.cpp:255
VSDXRelationships(WPXInputStream *input)
Definition: VSDXMLHelper.cpp:291
std::string m_type
Definition: VSDXMLHelper.h:87
xmlTextReaderPtr xmlReaderForStream(WPXInputStream *input, const char *URL, const char *encoding, int options)
Definition: VSDXMLHelper.cpp:103
~VSDXRelationships()
Definition: VSDXMLHelper.cpp:336
bool empty() const
Definition: VSDXMLHelper.h:102
const VSDXRelationship * getRelationshipById(const char *id) const
Definition: VSDXMLHelper.cpp:359
const std::string getType() const
Definition: VSDXMLHelper.h:76
std::string m_target
Definition: VSDXMLHelper.h:88
void rebaseTargets(const char *baseDir)
Definition: VSDXMLHelper.cpp:340
Definition: VSDXMLHelper.h:91
const std::string getId() const
Definition: VSDXMLHelper.h:72
Definition: VSDXMLHelper.h:63
double xmlStringToDouble(const xmlChar *s)
Definition: VSDXMLHelper.cpp:164
~VSDXRelationship()
Definition: VSDXMLHelper.cpp:251
Colour xmlStringToColour(const xmlChar *s)
Definition: VSDXMLHelper.cpp:110
bool xmlStringToBool(const xmlChar *s)
Definition: VSDXMLHelper.cpp:204
const VSDXRelationship * getRelationshipByType(const char *type) const
Definition: VSDXMLHelper.cpp:349
long xmlStringToLong(const xmlChar *s)
Definition: VSDXMLHelper.cpp:141
VSDXRelationship()
Definition: VSDXMLHelper.cpp:246

Generated for libvisio by doxygen 1.8.5