File indexing completed on 2024-05-12 04:35:06
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2013-2014 Dominik Haumann <dhaumann@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU Library General Public License as published 0007 * by the Free Software Foundation, either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, see 0017 * <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef TIKZ_DESERIALIZE_VISITOR_H 0021 #define TIKZ_DESERIALIZE_VISITOR_H 0022 0023 #include "Visitor.h" 0024 #include <QJsonObject> 0025 0026 namespace tikz { 0027 namespace core { 0028 0029 class Document; 0030 class Style; 0031 class Node; 0032 class Path; 0033 0034 /** 0035 * Deserializes a tikz::core::Document from a json file. 0036 */ 0037 class DeserializeVisitor : public Visitor 0038 { 0039 public: 0040 /** 0041 * Default constructor. 0042 */ 0043 DeserializeVisitor(); 0044 0045 /** 0046 * Destructor 0047 */ 0048 virtual ~DeserializeVisitor(); 0049 0050 // 0051 // extra functions 0052 // 0053 public: 0054 /** 0055 * Load the tikz::Document from the file @p filename. 0056 * @return true on success, otherwise false 0057 */ 0058 bool load(const QString & filename); 0059 0060 // 0061 // Visitor pattern 0062 // 0063 public: 0064 /** 0065 * Serializes document @p doc document. 0066 */ 0067 void visit(Document * doc) override; 0068 0069 /** 0070 * Serializes @p node. 0071 */ 0072 void visit(Node * node) override; 0073 0074 /** 0075 * Serializes @p path. 0076 */ 0077 void visit(Path * path) override; 0078 0079 /** 0080 * Serializes @p style. 0081 */ 0082 void visit(Style * style) override; 0083 0084 // 0085 // private data 0086 // 0087 private: 0088 QJsonObject m_root; 0089 QJsonObject m_nodes; 0090 QJsonObject m_paths; 0091 QJsonObject m_styles; 0092 }; 0093 0094 } 0095 } 0096 0097 #endif // TIKZ_DESERIALIZE_VISITOR_H 0098 0099 // kate: indent-width 4; replace-tabs on;