VSDXMLHelper.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libvisio project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef __VSDXMLHELPER_H__
00011 #define __VSDXMLHELPER_H__
00012 
00013 #include <map>
00014 #include <string>
00015 #include <boost/shared_ptr.hpp>
00016 #include <librevenge-stream/librevenge-stream.h>
00017 #include <libxml/xmlreader.h>
00018 #include "VSDTypes.h"
00019 
00020 namespace libvisio
00021 {
00022 
00023 class VSDCollector;
00024 
00025 // Helper classes to properly handle OPC relationships
00026 
00027 class VSDXRelationship
00028 {
00029 public:
00030   VSDXRelationship(xmlTextReaderPtr reader);
00031   VSDXRelationship();
00032   ~VSDXRelationship();
00033 
00034   void rebaseTarget(const char *baseDir);
00035 
00036   const std::string getId() const
00037   {
00038     return m_id;
00039   }
00040   const std::string getType() const
00041   {
00042     return m_type;
00043   }
00044   const std::string getTarget() const
00045   {
00046     return m_target;
00047   }
00048 
00049 private:
00050   std::string m_id;
00051   std::string m_type;
00052   std::string m_target;
00053 };
00054 
00055 class VSDXRelationships
00056 {
00057 public:
00058   VSDXRelationships(librevenge::RVNGInputStream *input);
00059   ~VSDXRelationships();
00060 
00061   void rebaseTargets(const char *baseDir);
00062 
00063   const VSDXRelationship *getRelationshipByType(const char *type) const;
00064   const VSDXRelationship *getRelationshipById(const char *id) const;
00065 
00066   bool empty() const
00067   {
00068     return m_relsByType.empty() && m_relsById.empty();
00069   }
00070 
00071 private:
00072   std::map<std::string, VSDXRelationship> m_relsByType;
00073   std::map<std::string, VSDXRelationship> m_relsById;
00074 };
00075 
00076 } // namespace libvisio
00077 
00078 #endif // __VSDXMLHELPER_H__
00079 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */