1 /* 2 * objecttemplateformat.h 3 * Copyright 2017, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> 4 * Copyright 2017, Mohamed Thabet <thabetx@gmail.com> 5 * 6 * This file is part of libtiled. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * 1. Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 * EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #pragma once 31 32 #include "fileformat.h" 33 #include "objecttemplate.h" 34 35 #include <memory> 36 37 namespace Tiled { 38 39 class TILEDSHARED_EXPORT ObjectTemplateFormat : public FileFormat 40 { 41 Q_OBJECT Q_INTERFACES(Tiled::FileFormat)42 Q_INTERFACES(Tiled::FileFormat) 43 44 public: 45 explicit ObjectTemplateFormat(QObject *parent = nullptr) 46 : FileFormat(parent) 47 {} 48 49 virtual std::unique_ptr<ObjectTemplate> read(const QString &fileName) = 0; 50 virtual bool write(const ObjectTemplate *objectTemplate, const QString &fileName) = 0; 51 }; 52 53 TILEDSHARED_EXPORT std::unique_ptr<ObjectTemplate> readObjectTemplate(const QString &fileName, 54 QString *error = nullptr); 55 56 TILEDSHARED_EXPORT ObjectTemplateFormat *findSupportingTemplateFormat(const QString &fileName); 57 58 } // namespace Tiled 59 60 Q_DECLARE_INTERFACE(Tiled::ObjectTemplateFormat, "org.mapeditor.ObjectTemplateFormat") 61