File indexing completed on 2025-02-16 06:59:04
0001 /*************************************************************************** 0002 * Copyright 2007 Francesco Rossi <redsh@email.it> * 0003 * Copyright 2006 Mick Kappenburg <ksudoku@kappendburg.net> * 0004 * Copyright 2006-2007 Johannes Bergmeier <johannes.bergmeier@gmx.net> * 0005 * Copyright 2015 Ian Wadham <iandw.au@gmail.com> * 0006 * * 0007 * This program is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0021 ***************************************************************************/ 0022 0023 #ifndef _KSUDOKUSERIALIZER_H_ 0024 #define _KSUDOKUSERIALIZER_H_ 0025 0026 #include <QList> 0027 #include <QString> 0028 #include <QUrl> 0029 0030 class SKGraph; 0031 class QDomElement; 0032 class QWidget; 0033 0034 namespace ksudoku { 0035 0036 class Game; 0037 class Puzzle; 0038 class HistoryEvent; 0039 class Serializer { 0040 public: 0041 static SKGraph* loadCustomShape 0042 (const QUrl& url, QWidget* window, QString& errorMsg); 0043 static bool store 0044 (const Game& game, const QUrl& url, QWidget* window, QString& errorMsg); 0045 static Game load 0046 (const QUrl& url, QWidget* window, QString& errorMsg); 0047 0048 private: 0049 // TODO - IDW. Maybe there should be shared methods for file handling. 0050 // And do all these methods need to be static? 0051 static Game deserializeGame(const QDomElement &element); 0052 static Puzzle* deserializePuzzle(const QDomElement &element) ; 0053 static SKGraph* deserializeGraph(const QDomElement &element); 0054 static bool deserializeClique(SKGraph * graph, const QString & size, 0055 const QString & text); 0056 static bool deserializeCage(SKGraph * graph, const QDomElement & e); 0057 static QList<HistoryEvent> deserializeHistory(const QDomElement &element); 0058 static HistoryEvent deserializeSimpleHistoryEvent(const QDomElement &element); 0059 static HistoryEvent deserializeComplexHistoryEvent(const QDomElement &element); 0060 0061 0062 0063 static bool serializeGame(QDomElement& parent, const Game& game); 0064 static bool serializePuzzle(QDomElement& parent, const Puzzle* puzzle); 0065 static bool serializeGraph(QDomElement& parent, const SKGraph* graph); 0066 static bool serializeHistory(QDomElement& parent, const Game& game); 0067 static bool serializeHistoryEvent(QDomElement& parent, const HistoryEvent& event); 0068 0069 }; 0070 0071 } 0072 0073 #endif