vpnengine/utlxml/inc/XppImpl.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Element attribute name and value storage class.
       
    16 * A simple XML parser that implements
       
    17 * the XML pull parsing interface.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef __XPP_IMPL__
       
    23 #define __XPP_IMPL__
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <badesca.h>
       
    27 #include "XppApi.h"
       
    28 
       
    29 /**
       
    30  * Element attribute name and value storage class
       
    31  */
       
    32 class TAttrData
       
    33     {
       
    34 public:
       
    35     TPtrC8 iName;
       
    36     TPtrC8 iValue;
       
    37     };
       
    38 
       
    39 /**
       
    40  * A simple XML parser that implements
       
    41  * the XML pull parsing interface.
       
    42  */
       
    43 class CXmlPullParser : public CBase, public MXmlPullParser
       
    44     {
       
    45 public: // Construction and destruction
       
    46     IMPORT_C static CXmlPullParser* NewL(CDesC8ArrayFlat& aStringValueArray);
       
    47     IMPORT_C static CXmlPullParser* NewLC(CDesC8ArrayFlat& aStringValueArray);
       
    48     IMPORT_C virtual ~CXmlPullParser();
       
    49 
       
    50 private: // Construction
       
    51     CXmlPullParser();
       
    52     void ConstructL(CDesC8ArrayFlat& aStringValueArray);
       
    53 
       
    54 public: // MXmlPullParser methods
       
    55     IMPORT_C void SetInput(const TDesC8& aInput);
       
    56     IMPORT_C TInt NextL();
       
    57     IMPORT_C CXmlPullParser::TParserState State();
       
    58     IMPORT_C TInt Name(TPtrC8& aName);
       
    59     IMPORT_C TInt PathL(TPtrC8& aPath);
       
    60     IMPORT_C TInt Depth(TInt& aDepth);
       
    61     IMPORT_C TInt AttributeCount(TInt& aCount);
       
    62     IMPORT_C TInt AttributeName(TInt aIndex, TPtrC8& aName);
       
    63     IMPORT_C TInt AttributeValuePredefEntitiesNotEscaped(TInt aIndex, TPtrC8& aValue);
       
    64     IMPORT_C TInt AttributeValuePredefEntitiesNotEscaped(const TDesC8& aName, TPtrC8& aValue);
       
    65     IMPORT_C TInt AttributeValueL(TInt aIndex, TPtrC8& aValue);
       
    66     IMPORT_C TInt AttributeValueL(const TDesC8& aName, TPtrC8& aValue);
       
    67     IMPORT_C TInt IsEmptyElement(TBool& aIsEmptyElement);
       
    68     IMPORT_C TInt TextPredefEntitiesNotEscaped(TPtrC8& aText);
       
    69     IMPORT_C TInt TextL(TPtrC8& aText);
       
    70     IMPORT_C TInt Pos();
       
    71     IMPORT_C TInt CurrentElementPos();
       
    72     IMPORT_C TInt Length();
       
    73     IMPORT_C TPtrC8 DocPart(TInt aStartPos, TInt aEndPos);
       
    74 
       
    75 private:  // private methods
       
    76     void CheckSpaceL(const TDesC8& aText);
       
    77     TInt SkipLeadingNonRelevantElements();
       
    78     TInt SkipNonRelevantElements();
       
    79     TInt GetElementStartTagL();
       
    80     TInt GetElementText();
       
    81     TBool CheckIfNextEndTag();
       
    82     TBool CheckIfNextStartTag();
       
    83     TInt GetElementEndTag();
       
    84     TBool CheckIfEndOfFile();
       
    85     void CheckStringValueBufferSpaceL(const TDesC8& aValue);
       
    86     TInt EscapeCharRefAndPreDefEntities();
       
    87     TInt PredefinedEntitiesEscaped();
       
    88     TInt CharacterReferencesEscaped();
       
    89 
       
    90 private:
       
    91     TParserState iState;
       
    92     //const TDesC8* iInput;
       
    93     TPtrC8 iText;  // element text
       
    94 
       
    95     CArrayFixFlat<TAttrData> *iCAttrDataArray;
       
    96 
       
    97     TPtrC8 iDocument;  // pointer to whole document to parse
       
    98     TLexMark8 iMarkPosition;
       
    99     TPtrC8 iDocPart;
       
   100     TLex8 iLexer;
       
   101     TInt iCurrentElementPos;
       
   102 
       
   103     HBufC8* iPathBuf;
       
   104     TPtr8 iPathBufPtr;
       
   105     
       
   106     TPtrC8 iElement;  // element name
       
   107     TInt iDepth;
       
   108     TBool iIsEmptyElement;
       
   109 
       
   110     TBool iCdataStartFound;
       
   111     TBool iCdataSectionText;
       
   112 
       
   113     HBufC8* iStringValue;  // used when entities are escaped
       
   114     TPtr8 iStringValuePtr;
       
   115 
       
   116     CDesC8ArrayFlat* iStringValueArray;
       
   117 
       
   118     };
       
   119 
       
   120 
       
   121 #endif // __XPP_IMPL__