SenFragmentBase.h

Go to the documentation of this file.
00001 /*
00002 * ==============================================================================
00003 *  Name        : SenFragmentBase.h
00004 *  Part of     : Web Services Fragment
00005 *  Interface   : 
00006 *  Description : Class implements XML base fragment using libxml2 classes
00007 *  Version     : 
00008 *
00009 *  Copyright © 2002-2006 Nokia. All rights reserved.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia. All rights are reserved. Copying, including 
00013 *  reproducing, storing, adapting or translating, any 
00014 *  or all of this material requires the prior written consent of 
00015 *  Nokia. This material also contains confidential 
00016 *  information which may not be disclosed to others without the 
00017 *  prior written consent of Nokia.
00018 * ==============================================================================
00019 */
00020 
00021 
00022 #ifndef SEN_FRAGMENT_BASE_H
00023 #define SEN_FRAGMENT_BASE_H
00024 
00025 // INCLUDES
00026 #include <s32mem.h>
00027 
00028 #include <Xml/ContentHandler.h>
00029 #include <RSenDocument.h>
00030 #include <SenParser.h>
00031 #include <XmlEngElement.h>
00032 
00033 using namespace Xml;
00034 
00035 // CONSTANTS
00036 
00037 // Fragment's internal states.
00038 const TInt KSenStateNotSet      = -1;
00039 const TInt KSenStateIgnore      =  0;
00040 const TInt KSenStateSave        =  1;
00041 const TInt KSenStateResume      =  2;
00042 const TInt KSenStateDelegate    =  3;
00043 
00044 // FORWARD DECLARATIONS
00045 class RWriteStream;
00046 //class CSenParser;
00047 class CSenNamespaceData;
00048 
00049 // CLASS DECLARATION
00050 
00066 class CSenFragmentBase : public CBase, public MContentHandler
00067     {
00068     friend class CSenParserImpl;
00069     
00070     public:  // Constructors and destructor
00071         
00078         IMPORT_C static CSenFragmentBase* NewL(const TXmlEngElement& aElement);
00079 
00085         IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aLocalName);
00086 
00093         IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00094                                                const TDesC8& aLocalName);
00095 
00103         IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00104                                                const TDesC8& aLocalName,
00105                                                const TDesC8& aPrefix);
00106 
00115          IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00116                                                 const TDesC8& aLocalName,
00117                                                 const TDesC8& aPrefix,
00118                                                 const RAttributeArray& apAttrs);
00119 
00130         IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00131                                                const TDesC8& aLocalName,
00132                                                const TDesC8& aPrefix,
00133                                                const RAttributeArray& apAttrs,
00134                                                TXmlEngElement& aParent);
00135 
00148         IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00149                                                const TDesC8& aLocalName,
00150                                                const TDesC8& aPrefix,
00151                                                const RAttributeArray& apAttrs,
00152                                                TXmlEngElement& aParent,
00153                                                RSenDocument& aOwnerDocument);
00154 
00164         IMPORT_C static CSenFragmentBase* NewL(TXmlEngElement& aRootElement,
00165                                                RSenDocument& aOwnerDocument);
00166 
00170         IMPORT_C virtual ~CSenFragmentBase();
00171 
00172         // Functions from base classes
00173         
00174         // From MContentHandler:
00175         
00182         IMPORT_C virtual void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode);
00183 
00190         IMPORT_C virtual void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
00191 
00198         IMPORT_C virtual void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
00199 
00206         IMPORT_C virtual void OnEndDocumentL(TInt aErrorCode);
00207 
00214         IMPORT_C virtual void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
00215 
00222         IMPORT_C virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
00223 
00230         IMPORT_C virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
00231 
00238         IMPORT_C virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt ErrorCode);
00239 
00246         IMPORT_C virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
00247 
00254         IMPORT_C virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
00255 
00262         IMPORT_C virtual void OnError(TInt aErrorCode);
00263 
00270         IMPORT_C virtual TAny* GetExtendedInterface(const TInt32 aUid);
00271 
00272         // New functions
00273     
00279         IMPORT_C virtual TPtrC8 ContentL();
00280         
00288         IMPORT_C virtual TXmlEngNamespace Namespace(const TDesC8& aPrefix);
00289         
00296 //        IMPORT_C virtual void DetachL();
00297         
00302         IMPORT_C virtual void ResetContentL();
00303 
00308         IMPORT_C virtual TPtrC8 LocalName() const;
00309         
00315         IMPORT_C virtual TPtrC8 NsUri() const;
00316 
00322         IMPORT_C virtual TPtrC8 NsPrefix() const;    
00323 
00331         IMPORT_C virtual TXmlEngElement AsElementL();
00332 
00340         IMPORT_C virtual RSenDocument& AsDocumentL();
00341 
00351         IMPORT_C virtual TXmlEngElement ExtractElement();
00352         
00361         IMPORT_C virtual void OnDelegateParsingL(CSenFragmentBase& aDelegate);
00362 
00374         IMPORT_C virtual void OnDelegateParsingL(const RTagInfo& aElement, 
00375                                                  const RAttributeArray& aAttributes, 
00376                                                  TInt aErrorCode);
00377         
00383         IMPORT_C virtual void SetOwner(CSenFragmentBase& aFragment);
00384 
00395         IMPORT_C virtual void OnResumeParsingFromL(const RTagInfo& aElement, TInt aErrorCode);
00396 
00406 //        IMPORT_C virtual void SetAttributesL(const RAttributeArray& aAttrs);
00407         
00416         IMPORT_C void OnWriteStartElementL(const RTagInfo& aElement, 
00417                                            const RAttributeArray& aAttributes);
00418         
00426         IMPORT_C void OnWriteEndElementL(const RTagInfo& aElement);
00427 
00433         IMPORT_C virtual HBufC* AsXmlUnicodeL();
00434 
00440         IMPORT_C virtual HBufC8* AsXmlL();
00441 
00448         IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs);
00449 
00460         IMPORT_C virtual TBool ConsistsOfL(CSenFragmentBase& aCandidate);
00461         
00462         //From SenParserImpl.h
00463         IMPORT_C void SetContentHandler(CSenFragmentBase& aContentHandler);
00464         
00469         IMPORT_C void SetDocument(RSenDocument& aDocument);
00470 
00471     protected:  
00472         
00476         IMPORT_C CSenFragmentBase();        
00477         
00488         IMPORT_C void BaseConstructL(const TXmlEngElement& aSrc);
00489         
00495         IMPORT_C void BaseConstructL(const TDesC8& aLocalName);
00496 
00503         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00504                                      const TDesC8& aLocalName);
00505 
00513         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00514                                      const TDesC8& aLocalName,
00515                                      const TDesC8& aPrefix);
00524         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00525                                      const TDesC8& aLocalName,
00526                                      const TDesC8& aPrefix,
00527                                      const RAttributeArray& aAttrs);
00528 
00538         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00539                                      const TDesC8& aLocalName,
00540                                      const TDesC8& aPrefix,
00541                                      const RAttributeArray& aAttrs,
00542                                      TXmlEngElement& aParent);
00543 
00555         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00556                                      const TDesC8& aLocalName,
00557                                      const TDesC8& aPrefix,
00558                                      const RAttributeArray& aAttrs,
00559                                      TXmlEngElement& aParent,
00560                                      RSenDocument& aOwnerDocument);
00561         
00570         IMPORT_C void BaseConstructL(TXmlEngElement& aRootElement,
00571                                      RSenDocument& aOwnerDocument);
00572         
00573         // New functions
00574 
00580         IMPORT_C virtual void AddAttributesL(const RAttributeArray& apAttrs);
00581 
00587         IMPORT_C virtual void AddAttributesToElementL(TXmlEngElement element,
00588                                          const RAttributeArray& apAttrs);
00589         
00597         void RenameL(const TDesC8& aLocalName, const TDesC8& aPrefix, const TDesC8& aNamespace);
00598 
00605         void RenameL(const TDesC8& aLocalName, const TDesC8& aNamespace);
00606 
00612         void RenameLocalNameL(const TDesC8& aLocalName);
00613 
00619         void RenameNamespaceL(const TDesC8& aNamespace);
00620 
00626         void RenamePrefixL(const TDesC8& aPrefix);
00627 
00634         void RenameNamespaceL(const TDesC8& aPrefix, const TDesC8& aNamespace);
00635          
00648         IMPORT_C TXmlEngElement SetContentOfL(const TDesC8& aLocalName,
00649                                               const TDesC8& aContent);
00657         IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName);        
00658 
00659         IMPORT_C virtual TBool ConsistsOfL(TXmlEngElement& aElement, TXmlEngElement& aCandidate);
00660         
00665         IMPORT_C virtual void AddNamespacesL();
00666         
00673         IMPORT_C virtual void SetContentL(const TDesC8& aContent);
00674         
00680         IMPORT_C virtual void AddContentL(const TDesC8& aContent);        
00681         
00689         IMPORT_C void StartSavingContent();
00690 
00691         
00692     private: // New functions
00693     
00700         IMPORT_C virtual void SetParser(CSenParser& aParser);
00701 
00702     protected: // Data
00703 
00704         // State variable indicating what this fragment
00705         // is currently parsing. Even states (like 0)
00706         // mean that this fragment is ignoring the
00707         // data, and odd states indicate, that fragment
00708         // is storing the data into itself.
00709         TInt                                iState;
00710 
00711         // Owned element containing this XML fragment data.
00712         TXmlEngElement                      iElement;
00713         
00714         // Owned document representing this XML fragment
00715         RSenDocument                        iDocument;
00716         
00717         // Pointer to XML parser. Not owned.
00718         CSenParser*                         ipParser;               // Not owned
00719 
00720         // Possible owner fragment, if such exists. Not owned.
00721         CSenFragmentBase*                   ipOwner;                // Not owned
00722         CSenFragmentBase*                   ipDelegate;             // Owned
00723         
00724         RPointerArray<CSenNamespaceData>*   ipNamespaceArray;       // Owned
00725         
00726         CBufFlat*                           ipContentBuf;           // Owned
00727         RBufWriteStream*                    ipContentWriteStream;   // Owned
00728     };
00729     
00730 class CSenNamespaceData : public CBase
00731     {
00732     public:
00733         virtual ~CSenNamespaceData();
00734     
00735     public:
00736         HBufC8* ipLocalName;
00737         HBufC8* ipNamespaceUri;
00738         HBufC8* ipPrefix;
00739     };
00740 
00741 #endif //SEN_FRAGMENT_BASE_H
00742 
00743 // End of File
00744 
00745 
00746 

Copyright © Nokia Corporation 2001-2007
Back to top