File indexing completed on 2024-05-05 03:50:48

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Shashan Singh <shashank.personal@gmail.com>
0004 //
0005 
0006 #ifndef PANORAMIOPARSER_H
0007 #define PANORAMIOPARSER_H
0008 
0009 #include <QScriptEngine>
0010 #include <QList>
0011 
0012 /**
0013 This is a generic class built up for parsing Json that is JavaScript Object Notification
0014 FIXME: the class presently has no sanity checking mechanism, it just can't check whether the input given to it is only JSON or Javascript ; a point of potential breach for the software.
0015 sanity checking would include :
0016 (1)regex matching for following characters "" {} , [a-zA-Z] everything else should be discarded (but some unicode names could pose problem)
0017 (2)checking for javascript constructs and eliminating them.
0018 (3)some other plan that i have yet not thought upon :)
0019     @author Shashank Singh
0020 */
0021 struct panoramioDataStructure
0022 {
0023     long int count;// Total number of photographs will be stored in this int
0024     long int photo_id ; // Id of each photograph
0025     QString photo_title; // Title of each photograph
0026     QString photo_url; // Url of each photograph
0027     QString photo_file_url;
0028     qreal longitude;
0029     qreal latitude;
0030     int width;
0031     int height;
0032     QDate upload_date;
0033     long int owner_id;
0034     QString owner_name;
0035     QString owner_url; // Url of the User Uplaoded
0036 };
0037 
0038 class PanoramioParser
0039 {
0040 public:
0041     PanoramioParser();
0042 
0043     ~PanoramioParser();
0044 
0045     panoramioDataStructure parseObjectOnPosition(const QString &content, int requiredObjectPosition);   //for parsing single object
0046 
0047     QList<panoramioDataStructure> parseAllObjects(const QString &content, int number);   //for parsing a list objects
0048 
0049 private:
0050     QList <panoramioDataStructure> parsedJsonOutput;
0051 
0052     panoramioDataStructure dataStorage;
0053 
0054     QScriptEngine myEngine;
0055 };
0056 
0057 
0058 #endif