Stellarium 0.11.4
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/StelJsonParser.hpp

00001 /*
00002  * Copyright (C) 2008 Fabien Chereau
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00017  */
00018 
00019 #ifndef _STELJSONPARSER_HPP_
00020 #define _STELJSONPARSER_HPP_
00021 
00022 #include <QIODevice>
00023 #include <QVariant>
00024 #include <QByteArray>
00025 
00026 
00033 class JsonListIterator
00034 {
00035 public:
00039     JsonListIterator(QIODevice* input);
00040     ~JsonListIterator();
00041 
00045     QVariant next();
00046 
00048     bool hasNext() const {return ahasNext;}
00049 
00050 private:
00051     bool ahasNext;
00052     class StelJsonParserInstance* parser;
00053 };
00054 
00058 
00069 class StelJsonParser
00070 {
00071 public:
00073     static JsonListIterator initListIterator(QIODevice* in) {return JsonListIterator(in);}
00074 
00076     static QVariant parse(QIODevice* input);
00077     static QVariant parse(const QByteArray& input);
00078 
00080     static void write(const QVariant& jsonObject, QIODevice* output, int indentLevel=0);
00081 
00083     static QByteArray write(const QVariant& jsonObject, int indentLevel=0);
00084     
00085     static void registerSerializerForType(int t, void (*func)(const QVariant&, QIODevice*, int)) {otherSerializer.insert(t, func);}
00086     
00087 private:
00088     static QHash<int, void (*)(const QVariant&, QIODevice*, int)> otherSerializer;
00089 };
00090 
00091 #endif // _STELJSONPARSER_HPP_
Generated on Sat Aug 25 22:13:29 2012 for Stellarium by  doxygen 1.6.3