diff -r cfd5c2994f10 -r 113b91e0a2ad brandingserver/tools/bsimport/inc/cbsimportxmlparser.h --- a/brandingserver/tools/bsimport/inc/cbsimportxmlparser.h Tue Aug 31 15:31:29 2010 +0300 +++ b/brandingserver/tools/bsimport/inc/cbsimportxmlparser.h Wed Sep 01 12:27:45 2010 +0100 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available -* under the terms of the License "Eclipse Public License v1.0" +* under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,157 +11,307 @@ * * Contributors: * -* Description: Parses XML content and stores data to storage +* Description: Parses XML content and stores data to storage + * */ #ifndef CBSIMPORTXMLPARSER_H + #define CBSIMPORTXMLPARSER_H + + // INCLUDE FILES + #include + #include + #include + #include + #include + + class CMDXMLNode; + class CBSImportStorageManager; + + // CLASS DEFINITION + class CBSImportXMLParser : public CBase + { + private: // Definitions + + struct TImportBitmap + { + TInt iBitmapId; + TInt iBitmapMaskId; + TInt iSkinId; + TInt iSkinMaskId; + }; + + enum TXMLBaseTagTypes + { + EBrandUnknown, + EBrandAppID, + EBrandID, + EBrandLanguage, + EBrandVersion, + EBrandElement + }; + + public: + + static CBSImportXMLParser* NewL( CBSImportStorageManager* aStorage ); + + static CBSImportXMLParser* NewLC( CBSImportStorageManager* aStorage ); + + ~CBSImportXMLParser(); + + /** + * Parse XML document and store data to storage + * + * @since S60 3.2 + * @param aDocument XML document to parse + * @return none + */ + void ParseDocumentL( CMDXMLDocument& aDocument ); + + private: + + CBSImportXMLParser( CBSImportStorageManager* aStorage ); + + void ConstructL(); + + /** + * Parses full the base element and it's child elements. + * + * @since S60 v3.2 + * @param aElement to parse + */ + void ParseDocumentBaseL( CMDXMLNode* aElement ); + + /** + * Analyzes a child node of and stores the value to storage. + * Ignores undetected XML nodes. + * + * @since S60 v3.2 + * @param aElement to parse + */ + void AnalyzeNodeL( CMDXMLNode* aNode ); + + /** + * Converts a given node to TXMLBaseTagTypes. This can handle all + * child nodes of + * + * @since S60 v3.2 + * @param aNode node to check + * @return corresponding TXMLBaseTagTypes value (or EBrandUnknown). + */ + TXMLBaseTagTypes SolveTagTypeL( CMDXMLNode* aNode ); + + + /** + + * Parses full node. Returns a newly constructed MBSElement + + * from the content of teh node. + + * Ownership is transferred! + + * + + * @since S60 v3.2 + + * @param aNode node + + * @return Concrete element constructed from node. + + */ + + MBSElement* ParseBrandElementL( CMDXMLNode* aNode ); + + + /** - * Parses full node. Returns a newly constructed MBSElement - * from the content of teh node. - * Ownership is transferred! + + * Converts elements type attribute value to TBSElementType + + * (see MBSElement). + * + * @since S60 v3.2 - * @param aNode node - * @return Concrete element constructed from node. + + * @param aType value of type attribute + + * @return corresponding TBrandingElementType value or KErrNotFound. + */ - MBSElement* ParseBrandElementL( CMDXMLNode* aNode ); - - /** - * Converts elements type attribute value to TBSElementType - * (see MBSElement). - * - * @since S60 v3.2 - * @param aType value of type attribute - * @return corresponding TBrandingElementType value or KErrNotFound. - */ + TInt SolveElementType( const TDesC& aType ); + + /** + * Search a child node with name inside another node. Returns the first match + * + * @since S60 v3.2 + * @param aNode parent node to search + * @param aTagName Child nodes name + * @return found node or NULL if not found; + */ + CMDXMLNode* SearchChild( CMDXMLNode* aNode, const TDesC& aChildName ); + + /** + * Parse value from tag. Leaves if parse fails. + * Ownership is transferred to caller (NodeTextLC) + * + * @since S60 3.2 + * @param aNode XML node to parse. should be . + * @return value from + */ + HBufC* NodeTextLC( CMDXMLNode* elNode ); + TInt NodeIntL ( CMDXMLNode* elNode ); + + /** + * Parse tag for given value type. Leaves if parsing fails. + * + * @since S60 3.2 + * @param aNode XML node to parse + * @param aValue Parsed value + * @return none + */ + void DoParseIntegerL( CMDXMLNode* aNode, TInt& aValue ); + void DoParseTextL ( CMDXMLNode* aNode, HBufC*& aText ); + void DoParseFileL ( CMDXMLNode* aNode, HBufC*& aText ); + void DoParseListL ( CMDXMLNode* aNode, RBSObjOwningPtrArray& aElementArray ); + void DoParseBitmapL ( CMDXMLNode* aNode, CBSBitmap*& aBitmap ); + + private: // Data + + // Not owned. Storage where to put parsed elements + CBSImportStorageManager* iStorage; + }; + + #endif //CBSIMPORTXMLPARSER_H +