[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfdatautil.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfdatautil.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfdatautil.h 969 2016-12-29 07:44:24Z phfaist $ */
23 
24 #ifndef KLFDATAUTIL_H
25 #define KLFDATAUTIL_H
26 
27 #include <QString>
28 #include <QStringList>
29 #include <QDomElement>
30 
31 #include <klffactory.h>
32 
38 KLF_EXPORT QByteArray klfDataToEscaped(const QByteArray& data, char escapechar = '\\');
39 
46 KLF_EXPORT QByteArray klfEscapedToData(const QByteArray& escaped, char escapechar = '\\');
47 
48 
74 KLF_EXPORT QByteArray klfSaveVariantToText(const QVariant& value, bool saveListAndMapsAsXML = false,
75  QByteArray * savedType = NULL,
76  QByteArray * savedListOrMapType = NULL);
77 
97 KLF_EXPORT QVariant klfLoadVariantFromText(const QByteArray& string, const char * dataTypeName,
98  const char *listOrMapTypeName = NULL);
99 
100 
102 KLF_EXPORT QDomElement klfSaveVariantMapToXML(const QVariantMap& vmap, QDomElement xmlNode);
104 KLF_EXPORT QVariantMap klfLoadVariantMapFromXML(const QDomElement& xmlNode);
105 
107 KLF_EXPORT QDomElement klfSaveVariantListToXML(const QVariantList& vlist, QDomElement xmlNode);
109 KLF_EXPORT QVariantList klfLoadVariantListFromXML(const QDomElement& xmlNode);
110 
111 
112 
113 
114 
115 
117 
124 {
125 public:
128 
129  virtual QStringList supportedTypes() const = 0;
130 
131  virtual QString recognizeDataFormat(const QByteArray& data) const = 0;
132 
133  virtual QByteArray save(const KLFAbstractPropertizedObject * obj, const QString& format) = 0;
134  virtual bool load(const QByteArray& data, KLFAbstractPropertizedObject * obj, const QString& format) = 0;
135 
136  static KLFAbstractPropertizedObjectSaver * findRecognizedFormat(const QByteArray& data, QString * format = NULL);
138 private:
139  static KLFFactoryManager pFactoryManager;
140 };
141 
142 
143 
145 
150  const QString& format = QString());
151 
152 
153 
154 
155 
156 #endif
static KLFAbstractPropertizedObjectSaver * findRecognizedFormat(const QByteArray &data, QString *format=NULL)
KLF_EXPORT QVariantList klfLoadVariantListFromXML(const QDomElement &xmlNode)
Load a list saved with klfSaveVariantListToXML()
KLF_EXPORT QDomElement klfSaveVariantMapToXML(const QVariantMap &vmap, QDomElement xmlNode)
Lossless save of full map to XML with type information.
virtual QString recognizeDataFormat(const QByteArray &data) const =0
virtual QStringList supportedTypes() const =0
KLF_EXPORT QVariantMap klfLoadVariantMapFromXML(const QDomElement &xmlNode)
Load a map saved with klfSaveVariantMapToXML()
KLF_EXPORT QDomElement klfSaveVariantListToXML(const QVariantList &vlist, QDomElement xmlNode)
Lossless save of full list to XML with type information.
KLF_EXPORT QByteArray klfSave(const KLFAbstractPropertizedObject *obj, const QString &="XML")
static KLFAbstractPropertizedObjectSaver * findSaverFor(const QString &format)
Base class for factories.
Definition: klffactory.h:40
An abstract object characterized by properties.
Definition: klfpobj.h:58
#define KLF_EXPORT
Definition: klfdefs.h:41
KLF_EXPORT QByteArray klfSaveVariantToText(const QVariant &value, bool saveListAndMapsAsXML=false, QByteArray *savedType=NULL, QByteArray *savedListOrMapType=NULL)
KLF_EXPORT QByteArray klfEscapedToData(const QByteArray &escaped, char escapechar='\\')
KLF_EXPORT QVariant klfLoadVariantFromText(const QByteArray &string, const char *dataTypeName, const char *listOrMapTypeName=NULL)
A base abstract factory manager class.
Definition: klffactory.h:91
const char * format
Definition: klfdatautil.cpp:81
KLF_EXPORT QByteArray klfDataToEscaped(const QByteArray &data, char escapechar='\\')
virtual bool load(const QByteArray &data, KLFAbstractPropertizedObject *obj, const QString &format)=0
virtual QByteArray save(const KLFAbstractPropertizedObject *obj, const QString &format)=0
KLF_EXPORT bool klfLoad(const QByteArray &data, KLFAbstractPropertizedObject *obj, const QString &format=QString())
Inherit this class to implement a custom saver for KLFAbstractPropertizedObjects. ...
Definition: klfdatautil.h:123

Generated by doxygen 1.8.13