example/LinkedInAuthApp/inc/xmlParser.h
changeset 26 83d6a149c755
equal deleted inserted replaced
25:a180113055cb 26:83d6a149c755
       
     1 /**
       
     2 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "{License}"
       
     6 * which accompanies  this distribution, and is available
       
     7 * at the URL "{LicenseUrl}".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Narasimhulu Kavadapu, Sasken Communication Technologies Ltd - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Siddhartha Chandra, Satish Kanteti Sasken Communication Technologies Ltd
       
    14 * Description:
       
    15 * XML Parser class
       
    16 */
       
    17 
       
    18 #ifndef FB_XML_HANDLER_H
       
    19 #define FB_XML_HANDLER_H
       
    20 
       
    21 #include <QObject>
       
    22 #include <QString>
       
    23 #include <QXmlDefaultHandler>
       
    24 #include <QVariantList>
       
    25 
       
    26 #include "authAppConstants.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class FBRequest;
       
    30 
       
    31 ///////////////////////////////////////////////////////////////////////////////////////////////////
       
    32 class FBXMLHandler : public QObject, public QXmlDefaultHandler
       
    33 {
       
    34     Q_OBJECT
       
    35 
       
    36 private:
       
    37     QVariantList        iStack;
       
    38     QList<QString>      iNameStack;
       
    39     QVariant            iRootObject;
       
    40     QString             iRootName;
       
    41     QString             iChars;
       
    42 
       
    43     QString         iParseErrorMessage;
       
    44     bool            iError;
       
    45 
       
    46 public: /* class functions */
       
    47 
       
    48     FBXMLHandler();
       
    49     ~FBXMLHandler();
       
    50 
       
    51     inline const QString& rootName() const { return iRootName; }
       
    52     inline QVariant rootObject() const { return iRootObject; }
       
    53 
       
    54     inline bool parseError() const { return iError; }
       
    55 
       
    56 private:
       
    57     /* methods from QXmlDefaultHandler */
       
    58     bool startElement( const QString & namespaceURI,
       
    59                        const QString & localName,
       
    60                        const QString & qName,
       
    61                        const QXmlAttributes & atts);
       
    62     bool characters(const QString& text);
       
    63     bool endElement( const QString & namespaceURI,
       
    64                      const QString & localName,
       
    65                      const QString & qName );
       
    66 
       
    67     /* methods from QXmlErrorHandler */
       
    68     bool error(const QXmlParseException& exception);
       
    69     bool fatalError(const QXmlParseException& exception);
       
    70 
       
    71     /* private functions*/
       
    72     const QString& topName() const;
       
    73     void flushCharacters();
       
    74     QVariant topObject(bool aCreate);
       
    75 
       
    76     QVariant topContainer();
       
    77 
       
    78 
       
    79     void initWhiteSpaceHash();
       
    80     QHash<QChar, bool> iWhiteSpaceAndNewLineCharSet;
       
    81 
       
    82 };
       
    83 
       
    84 #endif // FB_XML_HANDLER_H