SenBaseFragment.h

Go to the documentation of this file.
00001 /*
00002 * ==============================================================================
00003 *  Name        : SenBaseFragment.h
00004 *  Part of     : Web Services Xml
00005 *  Interface   : 
00006 *  Description : Class implements basic functionality of an XML fragment
00007 *  Version     : 
00008 *
00009 *  Copyright © 2002-2005 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 #ifndef SEN_BASE_FRAGMENT_H
00022 #define SEN_BASE_FRAGMENT_H
00023 
00024 //  INCLUDES
00025 #include <MSenContentHandlerClient.h>
00026 #include <SenElement.h>
00027 #include <SenFragment.h>
00028 
00029 // CONSTANTS
00030 
00031 // Fragment's internal states.
00032 const TInt KStateNotSet = -1;
00033 const TInt KStateIgnore =  0;
00034 const TInt KStateSave   =  1;
00035 const TInt KStateResume =  2;
00036 
00037 // FORWARD DECLARATIONS
00038 class CSenXmlReader;
00039 
00040 // CLASS DECLARATION
00041 
00057 class CSenBaseFragment : public CSenFragment, public MSenContentHandlerClient 
00058     {
00059     public:  // Constructors and destructor
00060         
00067         IMPORT_C static CSenBaseFragment* NewL(const CSenElement& aElement);
00068 
00078         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aLocalName);
00079 
00090         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
00091                                                const TDesC8& aLocalName);
00092 
00104         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
00105                                                const TDesC8& aLocalName,
00106                                                const TDesC8& aQName);
00107 
00120          IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
00121                                                 const TDesC8& aLocalName,
00122                                                 const TDesC8& aQName,
00123                                                 const RAttributeArray& apAttrs);
00124 
00140         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
00141                                                const TDesC8& aLocalName,
00142                                                const TDesC8& aQName,
00143                                                const RAttributeArray& apAttrs,
00144                                                CSenElement& aParent);
00145 
00149         IMPORT_C virtual ~CSenBaseFragment();
00150 
00151 
00152         // New functions
00153     
00159         IMPORT_C virtual TPtrC8 Content();
00167         IMPORT_C virtual CSenNamespace* Namespace(const TDesC8& aPrefix);
00168         
00173         IMPORT_C virtual void EnsureNamespace(const TDesC8& aPrefix);
00174         
00181         IMPORT_C virtual void DetachL();
00182         
00191         IMPORT_C virtual void SaveNamespacesL(const RAttributeArray& aAttrs,
00192                                               TBool aEnsure);
00193 
00198         IMPORT_C virtual void ResetContentL();
00199 
00200         // Functions from base classes
00201 
00202         // From CSenFragment 
00203         
00208         IMPORT_C virtual const TDesC8& LocalName() const;
00209         
00215         IMPORT_C virtual const TDesC8& NsUri() const;
00216 
00222         IMPORT_C virtual const TDesC8& NsPrefix() const;    
00223 
00230         IMPORT_C virtual CSenElement& AsElement();
00231 
00241         IMPORT_C virtual CSenElement* ExtractElement();
00242         
00249         IMPORT_C virtual CSenXmlReader* Reader();
00250 
00257         IMPORT_C virtual void SetReader(CSenXmlReader& aReader);
00258 
00271         IMPORT_C virtual void ParseL(const TDesC8& aXml);
00272 
00281         IMPORT_C virtual TInt BuildFrom(const TDesC8& aXml);
00282 
00293         IMPORT_C virtual void DelegateParsingL(MSenFragment& aDelegate);
00294 
00308         IMPORT_C virtual void DelegateParsingL(const TDesC8& aNsUri,
00309                                                const TDesC8& aLocalName,
00310                                                const TDesC8& aQName,
00311                                                const RAttributeArray& aAttrs);
00312         
00319         IMPORT_C virtual void ParseWithL(CSenXmlReader& aReader);
00320 
00326         IMPORT_C virtual void SetOwner(MSenFragment& aFragment);
00327 
00339         IMPORT_C virtual void ResumeParsingFromL(const TDesC8& aNsUri,
00340                                                  const TDesC8& aLocalName,
00341                                                  const TDesC8& aQName);
00342 
00352         IMPORT_C virtual void SetAttributesL(const RAttributeArray& aAttrs);
00353         
00363         IMPORT_C void WriteStartElementL(const TDesC8& aNsUri,
00364                                          const TDesC8& aLocalName,
00365                                          const TDesC8& aQName,
00366                                          const RAttributeArray& aAttrs);
00367         
00376         IMPORT_C void WriteEndElementL(const TDesC8& aNsUri,
00377                                        const TDesC8& aLocalName,
00378                                        const TDesC8& aQName);
00379 
00385         IMPORT_C virtual HBufC* AsXmlUnicodeL();
00386 
00392         IMPORT_C virtual HBufC8* AsXmlL();
00393 
00400         IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs);
00401 
00412         IMPORT_C virtual TBool ConsistsOfL(MSenFragment& aCandidate);
00413 
00414     protected:  
00415         
00419         IMPORT_C CSenBaseFragment();        
00420         
00431         IMPORT_C void BaseConstructL(const CSenElement& aElement);
00432         
00438         IMPORT_C void BaseConstructL(const TDesC8& aLocalName);
00439 
00446         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00447                                      const TDesC8& aLocalName);
00448 
00456         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00457                                      const TDesC8& aLocalName,
00458                                      const TDesC8& aQName);
00467         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00468                                      const TDesC8& aLocalName,
00469                                      const TDesC8& aQName,
00470                                      const RAttributeArray& aAttrs);
00471 
00481         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00482                                      const TDesC8& aLocalName,
00483                                      const TDesC8& aQName,
00484                                      const RAttributeArray& aAttrs,
00485                                      CSenElement& aParent);
00486 
00492         IMPORT_C void BaseConstructL(CSenXmlReader& aReader);
00493         
00494         // New functions
00495          
00500         IMPORT_C virtual void AllocContentSaverL();     
00501 
00511         IMPORT_C virtual void StartElementL(const TDesC8& aNsUri,
00512                                             const TDesC8& aLocalName,
00513                                             const TDesC8& aQName,
00514                                             const RAttributeArray& aAttrs);
00515 
00524         IMPORT_C virtual void EndElementL(const TDesC8& aNsUri,
00525                                           const TDesC8& aLocalName,
00526                                           const TDesC8& aQName);
00527 
00537         IMPORT_C virtual void CharactersL(const TDesC8& aChars,
00538                                           TInt aStart,
00539                                           TInt aLength);
00540 
00550         IMPORT_C TInt StartEntity(TDesC8& aName);
00551 
00564         IMPORT_C MSenElement& SetContentOfL(const TDesC8& aLocalName,
00565                                             const TDesC8& aContent);
00573         IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName);        
00574 
00575     private: // New functions
00576         
00580         TPtrC8 ContentL();
00581     
00582         // Functions from base classes
00583 
00584         // From MSenContentHandlerClient
00585         
00586         IMPORT_C virtual TInt StartDocument();
00587         IMPORT_C virtual TInt EndDocument();
00588         IMPORT_C virtual TInt StartElement(const TDesC8& aNsUri,
00589                                            const TDesC8& aLocalName,
00590                                            const TDesC8& aQName,
00591                                            const RAttributeArray& aAttrs);
00592         
00593         IMPORT_C virtual TInt EndElement(const TDesC8& aNsUri,
00594                                          const TDesC8& aLocalName,
00595                                          const TDesC8& aQName);
00596 
00597         IMPORT_C virtual TInt Characters(const TDesC8& aChars,
00598                                          const TInt aStart,
00599                                          const TInt aLength);
00600 
00601         IMPORT_C virtual TInt Error(TInt aErrorCode);
00602 
00603         //IMPORT_C TInt StartEntityL(const TDesC8& aName);
00604 
00605 
00606     protected: // Data
00607 
00608         // State variable indicating what this fragment
00609         // is currently parsing. Even states (like 0)
00610         // mean that this fragment is ignoring the
00611         // data, and odd states indicate, that fragment
00612         // is storing the data into itself.
00613         TInt iState;
00614         // Owned element containing this XML fragment data.
00615         CSenElement* ipElement;
00616         // Pointer to XML parser. Not owned.
00617         CSenXmlReader* iXmlReader;      
00618         // Possible owner fragment, if such exists. Not owned.
00619         MSenFragment* ipOwner;
00620         // Internal write stream, into which UTF-8 form XML is stored
00621         RWriteStream iWs;
00622 
00623     private: // Data
00624          
00625         // Owned pointer to delegate fragment
00626         CSenFragment* ipDelegate;
00627         // Not owned. Holds namespaces that are referred to from 
00628         // within the content but were not declared within this 
00629         // BaseFragment.
00630         RPointerArray<CSenNamespace> iNamespaces;
00631         // Owned. Holds prefixes that have been declared within the 
00632         // scope of this BaseFragment
00633         RPointerArray<HBufC8> iPrefixes;
00634         // Actual flat buffer to content which includes namespaces.
00635         CBufFlat* ipContentWithNamespaces;
00636         // Indicating that content writing stream is initialized.
00637         TBool hasContentWriteStream;
00638         // Indicates whether or not ipElement member is an owned
00639         TBool iElementOwned;
00640     };
00641 
00642 #endif //SEN_BASE_FRAGMENT_H
00643 
00644 // End of File
00645 
00646 
00647 

Copyright © Nokia Corporation 2001-2007
Back to top