epoc32/include/mw/sendomfragmentbase.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002-2006 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:        Class implements XML DOM fragment using libxml2 classes
    15 *
    16 */
    17 
    18 
    19 
    20 
    21 
    22 
    23 
    24 
    25 
    26 #ifndef SEN_DOM_FRAGMENT_BASE_H
    27 #define SEN_DOM_FRAGMENT_BASE_H
    28 
    29 //  INCLUDES
    30 #include <SenFragmentBase.h>
    31 
    32 // FORWARD DECLARATIONS
    33 class RFileLogger;
    34 
    35 // CLASS DECLARATION
    36 
    37 /**
    38 * Class implements DOM fragment functionality
    39 * The implementation further extends CSenBaseFragment
    40 * functionality. In DOM fragment, all child elements
    41 * are parsed into separate element objects. This makes
    42 * it possible to reference any child which offer methods
    43 * declared in XML element interface. Any such element
    44 * can also be easily extracted (detached) from this
    45 * root DOM fragment.
    46 * @lib SenFragment.dll
    47 * @since Series60 4.0
    48 */
    49 class CSenDomFragmentBase : public CSenFragmentBase
    50     {
    51     public:  // Constructors and destructor
    52         
    53         /**
    54         * Basic contructor. Should be used only for parsing new fragments etc. 
    55         * Constructing DomFragments for other use should be done with at least 
    56         * localname parameter.
    57         * @since Series60 4.0
    58         */
    59         IMPORT_C static CSenDomFragmentBase* NewL();
    60 
    61         /**
    62         * Basic constructor.
    63         * @since Series60 4.0
    64         * @param aElement Element to copy construction data from.
    65         */
    66         IMPORT_C static CSenDomFragmentBase* NewL(
    67             const TXmlEngElement& aElement);
    68 
    69         /**
    70         * Basic constructor.
    71         * @since Series60 4.0
    72         * @param aLocalName is the XML localname of this fragment
    73         */
    74         IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aLocalName);
    75 
    76         /**
    77         * Basic constructor.
    78         * @since Series60 4.0
    79         * @param aNsUri     is the XML namespace user of this fragment
    80         * @param aLocalName is the XML localname of this fragment
    81         */
    82         IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
    83                                               const TDesC8& aLocalName);
    84 
    85         /**
    86         * Basic constructor.
    87         * @since Series60 4.0
    88         * @param aNsUri     is the XML namespace user of this fragment
    89         * @param aLocalName is the XML localname of this fragment
    90         * @param aPrefix    is the XML prefix of this fragment
    91         */
    92         IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
    93                                               const TDesC8& aLocalName,
    94                                               const TDesC8& aPrefix);
    95 
    96         /**
    97         * Basic constructor.
    98         * @since Series60 4.0
    99         * @param aNsUri     is the XML namespace of this fragment
   100         * @param aLocalName is the XML localname of this fragment
   101         * @param aPrefix    is the prefix of this fragment
   102         * @param aAttrs     are the XML attributes of this fragment
   103         */
   104         IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
   105                                               const TDesC8& aLocalName,
   106                                               const TDesC8& aPrefix,
   107                                               const RAttributeArray& aAttrs);
   108 
   109         /**
   110         * Basic constructor.
   111         * @since Series60 4.0
   112         * @param aNsUri     is the XML namespace of this fragment
   113         * @param aLocalName is the XML localname of this fragment
   114         * @param aPrefix    is the prefix of this fragment
   115         * @param aAttrs     are the XML attributes of this fragment
   116         * @param aParent    is the parent XML element of this fragment
   117         */
   118         IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
   119                                               const TDesC8& aLocalName,
   120                                               const TDesC8& aPrefix,
   121                                               const RAttributeArray& aAttrs,
   122                                               TXmlEngElement& aParent);
   123 
   124         /**
   125         * Basic constructor.
   126         * @since Series60 4.0
   127         * @param aNsUri         is the XML namespace of this fragment
   128         * @param aLocalName     is the XML localname of this fragment
   129         * @param aPrefix        is the prefix of this fragment
   130         * @param aAttrs         are the XML attributes of this fragment
   131         * @param aParent        is the parent XML element of this fragment
   132         * @param aOwnerDocument is the document which will be the owner of
   133         *                       the elements of this fragment
   134         */
   135         IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
   136                                               const TDesC8& aLocalName,
   137                                               const TDesC8& aPrefix,
   138                                               const RAttributeArray& aAttrs,
   139                                               TXmlEngElement& aParent,
   140                                               RSenDocument& aOwnerDocument);
   141         /**
   142         * Destructor.
   143         */
   144         IMPORT_C virtual ~CSenDomFragmentBase();
   145 
   146         // New functions
   147     
   148         /**
   149         * Initiates the parsing chain where new delegate will be created with
   150         * given parameters and parsing will be delegated to it. Should not be
   151         * called externally.
   152         * @since Series60 4.0
   153         * @param aElement     The RTagInfo class holding information that describes
   154         *                     the element.
   155         * @param aAttributes  The attributes of the new element
   156         * @param aErrorCode   Error code
   157         */
   158         IMPORT_C virtual void ExpandL(const RTagInfo& aElement,
   159                                       const RAttributeArray& aAttributes,
   160                                       TInt aErrorCode);
   161                                       
   162         // Functions from base classes
   163 
   164         // From CSenBaseFragment
   165         
   166         /**
   167         * Resumes the parsing. Usually called by the delegate fragment which was
   168         *                      parsing itself after DelegateParsingL().
   169         * @since Series60 4.0
   170         * @param aElement     The RTagInfo class holding information that describes
   171         *                     the element.
   172         * @param aErrorCode   Error code
   173         */
   174         IMPORT_C virtual void OnResumeParsingFromL(const RTagInfo& aElement,
   175                                            TInt aErrorCode);
   176 
   177         /**
   178         * Sets the attributes for the fragment.
   179         * @since Series60 4.0
   180         * @param aAttributes    The array of attributes.
   181         */
   182         IMPORT_C virtual void AddAttributesL(const RAttributeArray& aAttrs);
   183         
   184         /**
   185          * Gets the fragment data as an UTF-8 form XML.
   186          * @since Series60 4.0
   187          * @return  fragment as XML. Caller takes ownership.
   188          */ 
   189         IMPORT_C virtual HBufC8* AsXmlL();
   190         
   191         /**
   192          * Callback function implementing the XML content handler interface.
   193          * Inheriting classes can override these.
   194          * @since Series60 4.0
   195          * @see MContentHandler
   196          */
   197     	IMPORT_C virtual void OnStartElementL(const RTagInfo& aElement,
   198     	                                      const RAttributeArray& aAttributes,
   199     	                                      TInt aErrorCode);
   200 
   201         /**
   202          * Callback function implementing the XML content handler interface.
   203          * Inheriting classes can override these.
   204          * @since Series60 4.0
   205          * @see MContentHandler
   206          */
   207         IMPORT_C virtual void OnContentL(const TDesC8& aBytes,
   208                                          TInt aErrorCode);
   209         
   210         /**
   211          * Overriding content writing from CSenBaseFragment to do nothing in
   212          * DOM fragment (because the tree is expanded).
   213          * @since Series60 4.0
   214          * @param aElement      The RTagInfo class holding information that
   215          *                      describes the element.
   216          * @param aAttributes   The attributes of the new element
   217          */
   218         IMPORT_C void OnWriteStartElementL(const RTagInfo& aElement, 
   219                                            const RAttributeArray& aAttributes);
   220 
   221         /**
   222          * Overriding content writing from CSenBaseFragment to do nothing in
   223          * DOM fragment (because the tree is expanded).
   224          * @since Series60 4.0
   225          * @param aElement      The RTagInfo class holding information that
   226          *                      describes the element.
   227          */
   228         IMPORT_C void OnWriteEndElementL(const RTagInfo& aElement);        
   229         /**
   230          * Callback function implementing the XML content handler interface.
   231          * Inheriting classes can override these.
   232          * @since Series60 4.0
   233          * @see MContentHandler
   234          */
   235         IMPORT_C virtual void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
   236 
   237         /**
   238          * Callback function implementing the XML content handler interface.
   239          * Inheriting classes can override these.
   240          * @since Series60 4.0
   241          * @see MContentHandler
   242          */
   243     	IMPORT_C virtual void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
   244 
   245         /**
   246          * Callback function implementing the XML content handler interface.
   247          * Inheriting classes can override these.
   248          * @since Series60 4.0
   249          * @see MContentHandler
   250          */
   251     	IMPORT_C virtual void OnEndDocumentL(TInt aErrorCode);
   252 
   253         /**
   254          * Callback function implementing the XML content handler interface.
   255          * Inheriting classes can override these.
   256          * @since Series60 4.0
   257          * @see MContentHandler
   258          */
   259     	IMPORT_C virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
   260 
   261         /**
   262          * Callback function implementing the XML content handler interface.
   263          * Inheriting classes can override these.
   264          * @since Series60 4.0
   265          * @see MContentHandler
   266          */
   267     	IMPORT_C virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
   268 
   269         /**
   270          * Callback function implementing the XML content handler interface.
   271          * Inheriting classes can override these.
   272          * @since Series60 4.0
   273          * @see MContentHandler
   274          */
   275     	IMPORT_C virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt ErrorCode);
   276 
   277         /**
   278          * Callback function implementing the XML content handler interface.
   279          * Inheriting classes can override these.
   280          * @since Series60 4.0
   281          * @see MContentHandler
   282          */
   283     	IMPORT_C virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
   284 
   285         /**
   286          * Callback function implementing the XML content handler interface.
   287          * Inheriting classes can override these.
   288          * @since Series60 4.0
   289          * @see MContentHandler
   290          */
   291     	IMPORT_C virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
   292 
   293         /**
   294          * Callback function implementing the XML content handler interface.
   295          * Inheriting classes can override these.
   296          * @since Series60 4.0
   297          * @see MContentHandler
   298          */
   299     	IMPORT_C virtual void OnError(TInt aErrorCode);
   300 
   301         /**
   302          * Callback function implementing the XML content handler interface.
   303          * Inheriting classes can override these.
   304          * @since Series60 4.0
   305          * @see MContentHandler
   306          */
   307     	IMPORT_C virtual TAny* GetExtendedInterface(const TInt32 aUid);
   308 
   309         // From CSenBaseFragment
   310         IMPORT_C virtual TPtrC8 ContentL();
   311         
   312         IMPORT_C virtual TXmlEngNamespace Namespace(const TDesC8& aPrefix);
   313         
   314 //        IMPORT_C virtual void DetachL();
   315         
   316         IMPORT_C virtual void ResetContentL();
   317 
   318         IMPORT_C virtual TPtrC8 LocalName() const;
   319         
   320         IMPORT_C virtual TPtrC8 NsUri() const;
   321 
   322         IMPORT_C virtual TPtrC8 NsPrefix() const;    
   323 
   324         IMPORT_C virtual TXmlEngElement AsElementL();
   325 
   326         IMPORT_C virtual RSenDocument& AsDocumentL();
   327 
   328         IMPORT_C virtual TXmlEngElement ExtractElement();
   329         
   330         IMPORT_C virtual void OnDelegateParsingL(CSenFragmentBase& aDelegate);
   331 
   332         IMPORT_C virtual void OnDelegateParsingL(const RTagInfo& aElement, 
   333                                                  const RAttributeArray& aAttributes, 
   334                                                  TInt aErrorCode);
   335         
   336         IMPORT_C virtual void SetOwner(CSenFragmentBase& aFragment);
   337 
   338         IMPORT_C virtual HBufC* AsXmlUnicodeL();
   339 
   340         IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs);
   341 
   342         IMPORT_C virtual TBool ConsistsOfL(CSenFragmentBase& aCandidate);
   343         
   344         IMPORT_C void SetContentHandler(CSenFragmentBase& aContentHandler);
   345         
   346     protected: // From CSenBaseFragment
   347     
   348         void RenameL(const TDesC8& aLocalName, const TDesC8& aPrefix, const TDesC8& aNamespace);
   349 
   350         void RenameL(const TDesC8& aLocalName, const TDesC8& aNamespace);
   351 
   352         void RenameLocalNameL(const TDesC8& aLocalName);
   353 
   354         void RenameNamespaceL(const TDesC8& aNamespace);
   355 
   356         void RenamePrefixL(const TDesC8& aPrefix);
   357 
   358         void RenameNamespaceL(const TDesC8& aPrefix, const TDesC8& aNamespace);
   359          
   360         IMPORT_C TXmlEngElement SetContentOfL(const TDesC8& aLocalName,
   361                                         const TDesC8& aContent);
   362 
   363         IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName);        
   364 
   365         IMPORT_C virtual TBool ConsistsOfL(TXmlEngElement& aElement, TXmlEngElement& aCandidate);
   366 
   367         IMPORT_C virtual void AddNamespacesL();
   368 
   369     protected:  
   370         
   371         /**
   372         * C++ default constructor.
   373         */
   374         IMPORT_C CSenDomFragmentBase();
   375 
   376         /**
   377         * "ConstructL" method for calling the base classes ones.
   378         * @since Series60 4.0
   379         */
   380         IMPORT_C void BaseConstructL();
   381 
   382         /**
   383         * "ConstructL" method for calling the base classes ones.
   384         * @since Series60 4.0
   385         * @param aElement is the XML element of this fragment.
   386         */
   387         IMPORT_C void BaseConstructL(const TXmlEngElement& aElement);
   388 
   389         /**
   390         * "ConstructL" method for calling the base classes ones.
   391         * @since Series60 4.0
   392         * @param aLocalName The local name of the element
   393         */
   394         IMPORT_C void BaseConstructL(const TDesC8& aLocalName);
   395 
   396         /**
   397         * "ConstructL" method for calling the base classes ones.
   398         * @since Series60 4.0
   399         * @param aNsUri     The namespace URI of the element
   400         * @param aLocalName The local name of the element
   401         */
   402         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   403                                      const TDesC8& aLocalName);
   404 
   405         /**
   406         * "ConstructL" method for calling the base classes ones.
   407         * @since Series60 4.0
   408         * @param aNsUri     The namespace URI of the element
   409         * @param aLocalName The local name of the element
   410         * @param aPrefix    The prefix of the element
   411         */
   412         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   413                                      const TDesC8& aLocalName,
   414                                      const TDesC8& aPrefix);
   415 
   416         /**
   417         * "ConstructL" method for calling the base classes ones.
   418         * @since Series60 4.0
   419         * @param aNsUri     The namespace URI of the element
   420         * @param aLocalName The local name of the element
   421         * @param aPrefix    The prefix of the element
   422         * @param aAttrs     The attributes of the element
   423         */
   424         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   425                                      const TDesC8& aLocalName,
   426                                      const TDesC8& aPrefix,
   427                                      const RAttributeArray& aAttrs);
   428 
   429         /**
   430         * "ConstructL" method for calling the base classes ones.
   431         * @since Series60 4.0
   432         * @param aNsUri     The namespace URI of the element
   433         * @param aLocalName The local name of the element
   434         * @param aPrefix    The prefix of the element
   435         * @param aAttrs     The attributes of the element
   436         * @param aParent    The parent of the element
   437         */
   438         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   439                                      const TDesC8& aLocalName,
   440                                      const TDesC8& aPrefix,
   441                                      const RAttributeArray& aAttrs,
   442                                      TXmlEngElement& aParent);
   443                                      
   444         /**
   445         * "ConstructL" method for calling the base classes ones.
   446         * @since Series60 4.0
   447         * @param aNsUri         The namespace URI of the element
   448         * @param aLocalName     The local name of the element
   449         * @param aPrefix        The prefix of the element
   450         * @param aAttrs         The attributes of the element
   451         * @param aParent        The parent of the element
   452         * @param aOwnerDocument The document which will be the owner of
   453         *                       the elements of this fragment
   454         */
   455         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   456                                      const TDesC8& aLocalName,
   457                                      const TDesC8& aPrefix,
   458                                      const RAttributeArray& aAttrs,
   459                                      TXmlEngElement& aParent,
   460                                      RSenDocument& aOwnerDocument);
   461 
   462         /**
   463          *  Callback functions which implement the XML content handler interface.
   464          *  Inheriting classes can override these.
   465          */
   466          
   467         // From CSenBaseFragment 
   468                                        
   469     protected: // Data
   470         CSenDomFragmentBase* ipDomDelegate;
   471     };
   472 
   473 #endif //SEN_DOM_FRAGMENT_BASE_H
   474 
   475 // End of File
   476 
   477 
   478