epoc32/include/mw/senbasefragment.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.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:        Class implements basic functionality of an XML fragment
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
williamr@2
    25
#ifndef SEN_BASE_FRAGMENT_H
williamr@2
    26
#define SEN_BASE_FRAGMENT_H
williamr@2
    27
williamr@2
    28
//  INCLUDES
williamr@2
    29
#include <MSenContentHandlerClient.h>
williamr@2
    30
#include <SenElement.h>
williamr@2
    31
#include <SenFragment.h>
williamr@2
    32
williamr@2
    33
// CONSTANTS
williamr@2
    34
williamr@2
    35
// Fragment's internal states.
williamr@2
    36
const TInt KStateNotSet = -1;
williamr@2
    37
const TInt KStateIgnore =  0;
williamr@2
    38
const TInt KStateSave   =  1;
williamr@2
    39
const TInt KStateResume =  2;
williamr@2
    40
williamr@2
    41
// FORWARD DECLARATIONS
williamr@2
    42
class CSenXmlReader;
williamr@2
    43
williamr@2
    44
// CLASS DECLARATION
williamr@2
    45
williamr@2
    46
/**
williamr@2
    47
* Class implements basic functionality of an XML fragment
williamr@2
    48
* Typically BaseFragment is used to parse certain part of some XML document.
williamr@2
    49
* The element is identified by localname (or qualifiedname) and namespace.
williamr@2
    50
* All child elements between start tag and and end tag defined this fragment
williamr@2
    51
* will become content of this BaseFragment. In other words, BaseFragment has
williamr@2
    52
* all data inside a single element.
williamr@2
    53
* BaseFragment will parse only namespace (xmlns) attributes from a document
williamr@2
    54
* and rest of the attributes are to be handled by subclasses, which should
williamr@2
    55
* overwrite SetAttributesL() method to achieve this.
williamr@2
    56
* The CSenXmlReader class will do the actual parsing and this class will
williamr@2
    57
* act as content handler for XML parser SAX events.
williamr@2
    58
* @lib SenXML.dll
williamr@2
    59
* @since Series60 3.0
williamr@2
    60
*/
williamr@2
    61
class CSenBaseFragment : public CSenFragment, public MSenContentHandlerClient 
williamr@2
    62
    {
williamr@2
    63
    public:  // Constructors and destructor
williamr@2
    64
        
williamr@2
    65
        /**
williamr@2
    66
         *  Standard 2 phase constructor.
williamr@2
    67
         *  @since Series60 3.0
williamr@2
    68
         *  @param aElement is the element where construction 
williamr@2
    69
         *                  data will be copied from.
williamr@2
    70
         */
williamr@2
    71
        IMPORT_C static CSenBaseFragment* NewL(const CSenElement& aElement);
williamr@2
    72
williamr@2
    73
        /**
williamr@2
    74
         *  Standard 2 phase constructor.
williamr@2
    75
         *  Leave codes:    
williamr@2
    76
         *      KErrSenInvalidCharacters if aLocalName contains
williamr@2
    77
         *      illegal characters.     
williamr@2
    78
         *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
williamr@2
    79
         *  @since Series60 3.0
williamr@2
    80
         *  @param aLocalName: is the XML localname for this fragment
williamr@2
    81
         */
williamr@2
    82
        IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aLocalName);
williamr@2
    83
williamr@2
    84
        /**
williamr@2
    85
         *  Standard 2 phase constructor.
williamr@2
    86
         *  Leave codes:    
williamr@2
    87
         *      KErrSenInvalidCharacters if aLocalName contains
williamr@2
    88
         *      illegal characters.     
williamr@2
    89
         *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
williamr@2
    90
         *  @since Series60 3.0
williamr@2
    91
         *  @param aNsUri:  XML namespace URI
williamr@2
    92
         *  @param aLocalName:  XML localname
williamr@2
    93
         */
williamr@2
    94
        IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
williamr@2
    95
                                               const TDesC8& aLocalName);
williamr@2
    96
williamr@2
    97
        /**
williamr@2
    98
         *  Standard 2 phase constructor.
williamr@2
    99
         *  Leave codes:    
williamr@2
   100
         *      KErrSenInvalidCharacters if aLocalName or aQName contains
williamr@2
   101
         *      illegal characters.     
williamr@2
   102
         *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
   103
         *  @since Series60 3.0
williamr@2
   104
         *  @param aNsUri:  XML namespace URI
williamr@2
   105
         *  @param aLocalName:  XML localname
williamr@2
   106
         *  @param aQName:  XML qualifiedname
williamr@2
   107
         */
williamr@2
   108
        IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
williamr@2
   109
                                               const TDesC8& aLocalName,
williamr@2
   110
                                               const TDesC8& aQName);
williamr@2
   111
williamr@2
   112
        /**
williamr@2
   113
         * Standard 2 phase constructor.
williamr@2
   114
         * Leave codes: 
williamr@2
   115
         *      KErrSenInvalidCharacters if aLocalName or aQName contains
williamr@2
   116
         *      illegal characters.     
williamr@2
   117
         *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
   118
         * @since Series60 3.0
williamr@2
   119
         * @param aNsUri:   XML namespace URI
williamr@2
   120
         * @param aLocalName:   XML localname
williamr@2
   121
         * @param aQName:   XML qualifiedname
williamr@2
   122
         * @param apAttrs:  XML attributes
williamr@2
   123
         */
williamr@2
   124
         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
williamr@2
   125
                                                const TDesC8& aLocalName,
williamr@2
   126
                                                const TDesC8& aQName,
williamr@2
   127
                                                const RAttributeArray& apAttrs);
williamr@2
   128
williamr@2
   129
        /**
williamr@2
   130
         *  Standard 2 phase constructor.
williamr@2
   131
         *  @param aParent  Element to be set as fragment's parent element.
williamr@2
   132
         *    Leave codes:  
williamr@2
   133
         *          KErrSenInvalidCharacters if aLocalName or aQName contains
williamr@2
   134
         *          illegal characters.     
williamr@2
   135
         *          KErrSenZeroLengthDescriptor if aLocalName or aQName is of
williamr@2
   136
         *      zero length.
williamr@2
   137
         *  @since Series60 3.0
williamr@2
   138
         *  @param aNsUri:  XML namespace URI
williamr@2
   139
         *  @param aLocalName:  XML localname
williamr@2
   140
         *  @param aQName:  XML qualifiedname
williamr@2
   141
         *  @param apAttrs: XML attributes
williamr@2
   142
         *  @param aParent: Parent element
williamr@2
   143
         */
williamr@2
   144
        IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
williamr@2
   145
                                               const TDesC8& aLocalName,
williamr@2
   146
                                               const TDesC8& aQName,
williamr@2
   147
                                               const RAttributeArray& apAttrs,
williamr@2
   148
                                               CSenElement& aParent);
williamr@2
   149
williamr@2
   150
        /**
williamr@2
   151
         * Destructor.
williamr@2
   152
         */
williamr@2
   153
        IMPORT_C virtual ~CSenBaseFragment();
williamr@2
   154
williamr@2
   155
williamr@2
   156
        // New functions
williamr@2
   157
    
williamr@2
   158
        /**
williamr@2
   159
         * Getter for the content,which is returned as UTF-8 form XML.
williamr@2
   160
         * @since Series60 3.0
williamr@2
   161
         * @return content as UTF-8 form XML.
williamr@2
   162
         */
williamr@2
   163
        IMPORT_C virtual TPtrC8 Content();
williamr@2
   164
        /**
williamr@2
   165
         * Gets the namespace object with a given prefix.
williamr@2
   166
         * @since Series60 3.0
williamr@2
   167
         * @param   aPrefix:    prefix that wanted namespace should have.
williamr@2
   168
         * @return namespace with the given prefix. If not found or given prefix
williamr@2
   169
         * is zero length, will return NULL.
williamr@2
   170
         */
williamr@2
   171
        IMPORT_C virtual CSenNamespace* Namespace(const TDesC8& aPrefix);
williamr@2
   172
        
williamr@2
   173
        /**
williamr@2
   174
         * @since Series60 3.0
williamr@2
   175
         * @param aPrefix is the XML namespace prefix
williamr@2
   176
         */
williamr@2
   177
        IMPORT_C virtual void EnsureNamespace(const TDesC8& aPrefix);
williamr@2
   178
        
williamr@2
   179
        /**
williamr@2
   180
         * @since Series60 3.0
williamr@2
   181
         * @return Detaches this fragment from its owner. All namespace
williamr@2
   182
         * references from possible parent fragments are declared in
williamr@2
   183
         * the scope of this fragment prior detaching.
williamr@2
   184
         */
williamr@2
   185
        IMPORT_C virtual void DetachL();
williamr@2
   186
        
williamr@2
   187
        /**
williamr@2
   188
         * @since Series60 3.0
williamr@2
   189
         * @param aAttrs are the attributes from which the namespaces
williamr@2
   190
         *        are searched from.
williamr@2
   191
         * @param aEnsure if set to TRUE, the namespaces are copied into
williamr@2
   192
         *         this fragment. If FALSE, then the namespaces are only
williamr@2
   193
         *         referenced, but not copied and owned by this class.
williamr@2
   194
         */
williamr@2
   195
        IMPORT_C virtual void SaveNamespacesL(const RAttributeArray& aAttrs,
williamr@2
   196
                                              TBool aEnsure);
williamr@2
   197
williamr@2
   198
        /**
williamr@2
   199
         * Resets the content of the fragment, and resets the namespaces.
williamr@2
   200
         * @since Series60 3.0
williamr@2
   201
         */
williamr@2
   202
        IMPORT_C virtual void ResetContentL();
williamr@2
   203
williamr@2
   204
        // Functions from base classes
williamr@2
   205
williamr@2
   206
        // From CSenFragment 
williamr@2
   207
        
williamr@2
   208
        /** 
williamr@2
   209
         * @since Series60 3.0
williamr@2
   210
         * @return the localname of this fragment as UTF-8 form descriptor
williamr@2
   211
         */
williamr@2
   212
        IMPORT_C virtual const TDesC8& LocalName() const;
williamr@2
   213
        
williamr@2
   214
        /**
williamr@2
   215
         * Getter for Fragment's namespace URI..
williamr@2
   216
         * @since Series60 3.0
williamr@2
   217
         * @return Namespace URI or KNullDesC if not set.
williamr@2
   218
         */
williamr@2
   219
        IMPORT_C virtual const TDesC8& NsUri() const;
williamr@2
   220
williamr@2
   221
        /**
williamr@2
   222
         * Getter for namespace prefix of this fragment.
williamr@2
   223
         * @since Series60 3.0
williamr@2
   224
         * @return namespace prefix or KNullDesC if not set.
williamr@2
   225
         */
williamr@2
   226
        IMPORT_C virtual const TDesC8& NsPrefix() const;    
williamr@2
   227
williamr@2
   228
        /**
williamr@2
   229
         * Getting the fragment as an XML element. This method will panic if 
williamr@2
   230
         * element has not been initialized for any reason.
williamr@2
   231
         * @since Series60 3.0
williamr@2
   232
         * @return the current object as element. Ownership is not transferred.
williamr@2
   233
         */
williamr@2
   234
        IMPORT_C virtual CSenElement& AsElement();
williamr@2
   235
williamr@2
   236
        /**
williamr@2
   237
         * Etracts the XML element from the fragment, leaving the fragment empty.
williamr@2
   238
         * Note(!): the return value (CSenElement) STRONGLY suggests that
williamr@2
   239
         * subclasses INHERIT CSenFragment in order properly comply the
williamr@2
   240
         * requirement of the ExtractElement() implementation.
williamr@2
   241
         * @since Series60 3.0
williamr@2
   242
         * @return the current object as element. May return NULL.
williamr@2
   243
         * Ownership IS TRANSFERRED to the caller.
williamr@2
   244
         */
williamr@2
   245
        IMPORT_C virtual CSenElement* ExtractElement();
williamr@2
   246
        
williamr@2
   247
        /**
williamr@2
   248
         * Gets the XML reader which this fragment uses for parsing.
williamr@2
   249
         * @since Series60 3.0
williamr@2
   250
         * @return the XML reader. Ownerships is not transferred,
williamr@2
   251
         * due even this class does not own the XML reader instance.
williamr@2
   252
         */
williamr@2
   253
        IMPORT_C virtual CSenXmlReader* Reader();
williamr@2
   254
williamr@2
   255
        /**
williamr@2
   256
         * Sets the XML reader to be used for parsing for the fragment.
williamr@2
   257
         * @since Series60 3.0
williamr@2
   258
         * @param aReader:      the reader to be used. 
williamr@2
   259
         *                      Ownership is NOT transferred.
williamr@2
   260
         */ 
williamr@2
   261
        IMPORT_C virtual void SetReader(CSenXmlReader& aReader);
williamr@2
   262
williamr@2
   263
        /**
williamr@2
   264
         *  Leave codes:    
williamr@2
   265
         *  KErrSenXmlReaderNotSet  if XML reader has not been set.
williamr@2
   266
         *  Method to invoke parsing of a XML data.
williamr@2
   267
         *  Note that SetReader() must be called before this method can be used.
williamr@2
   268
         *  Note that CSenBaseFragment does not parse any other
williamr@2
   269
         *  attributes, but XML namespace attributes only. This
williamr@2
   270
         *  is due to allow subclasses to process only those attributes
williamr@2
   271
         *  they are interested in, and not others.
williamr@2
   272
         *  @since Series60 3.0
williamr@2
   273
         *  @param aXml:    The data to be parsed.
williamr@2
   274
         */ 
williamr@2
   275
        IMPORT_C virtual void ParseL(const TDesC8& aXml);
williamr@2
   276
williamr@2
   277
        /**
williamr@2
   278
         * Same as ParseL() except that it doesn't leave in case of an error. 
williamr@2
   279
         * Instead errors are trapped and error is returned.
williamr@2
   280
         * SetReader() must be called before this method can be used.
williamr@2
   281
         * @since Series60 3.0
williamr@2
   282
         * @param aXml: The data to be parsed.
williamr@2
   283
         * @return KErrNone or other system-wide Symbian error codes.
williamr@2
   284
         */ 
williamr@2
   285
        IMPORT_C virtual TInt BuildFrom(const TDesC8& aXml);
williamr@2
   286
williamr@2
   287
        /**
williamr@2
   288
         * Leave codes: 
williamr@2
   289
         * KErrSenXmlReaderNotSet   if XML reader has not been set.
williamr@2
   290
         * Let the delegate MSenFragment handle the following SAX events.
williamr@2
   291
         * This fragment is made the owner of the delegate and the delegate
williamr@2
   292
         * is expected to make this MSenFragment the receiver of SAX events
williamr@2
   293
         * once it has seen the end element for itself.
williamr@2
   294
         * @since Series60 3.0
williamr@2
   295
         * @param aDelegate is the fragment to start handling the SAX events.
williamr@2
   296
         */
williamr@2
   297
        IMPORT_C virtual void DelegateParsingL(MSenFragment& aDelegate);
williamr@2
   298
williamr@2
   299
        /**
williamr@2
   300
         * Leave codes: 
williamr@2
   301
         * KErrSenXmlReaderNotSet   if XML reader has not been set.
williamr@2
   302
         * Creates a new fragment and lets the created MSenFragment handle the 
williamr@2
   303
         * following SAX events. This fragment is made the owner of the delegate
williamr@2
   304
         * and the delegate is expected to make this MSenFragment act as receiver
williamr@2
   305
         * for SAX events (callbacks) once it has seen the end element for itself.
williamr@2
   306
         * @since Series60 3.0
williamr@2
   307
         * @param aNsUri    The XML namespace URI for the delegate to be created
williamr@2
   308
         * @param aLocalName    The XML localname for the delegate to be created
williamr@2
   309
         * @param aQName    The XML qualifiedname for the delegate to be created
williamr@2
   310
         * @param aAttrs:   The XML attributes for the delegate to be created
williamr@2
   311
         */
williamr@2
   312
        IMPORT_C virtual void DelegateParsingL(const TDesC8& aNsUri,
williamr@2
   313
                                               const TDesC8& aLocalName,
williamr@2
   314
                                               const TDesC8& aQName,
williamr@2
   315
                                               const RAttributeArray& aAttrs);
williamr@2
   316
        
williamr@2
   317
        /**
williamr@2
   318
         * Sets the reader for this fragment and sets this to be the 
williamr@2
   319
         * content handler of the following SAX events.
williamr@2
   320
         * @since Series60 3.0
williamr@2
   321
         * @param aReader is the XML parser to be used.
williamr@2
   322
         */ 
williamr@2
   323
        IMPORT_C virtual void ParseWithL(CSenXmlReader& aReader);
williamr@2
   324
williamr@2
   325
        /**
williamr@2
   326
         * Sets a new parent for this fragment.
williamr@2
   327
         * @since Series60 3.0
williamr@2
   328
         * @param aFragment:    the new parent.
williamr@2
   329
         */
williamr@2
   330
        IMPORT_C virtual void SetOwner(MSenFragment& aFragment);
williamr@2
   331
williamr@2
   332
        /**
williamr@2
   333
         * Leave codes: 
williamr@2
   334
         * KErrSenXmlReaderNotSet   if XML reader has not been set.  Resumes 
williamr@2
   335
         *     parsing to be handled by this fragment. Usually called by some
williamr@2
   336
         *     delegate fragment which was set to be content handler because this
williamr@2
   337
         *     fragment called DelegateParsingL().
williamr@2
   338
         * @since Series60 3.0
williamr@2
   339
         * @param aNsUri    The namespace URI of the current element
williamr@2
   340
         * @param aLocalName    The local name of the current element
williamr@2
   341
         * @param aQName    The qualified name of the current element
williamr@2
   342
         */ 
williamr@2
   343
        IMPORT_C virtual void ResumeParsingFromL(const TDesC8& aNsUri,
williamr@2
   344
                                                 const TDesC8& aLocalName,
williamr@2
   345
                                                 const TDesC8& aQName);
williamr@2
   346
williamr@2
   347
        /**
williamr@2
   348
         * Sets the attributes for the fragment. BaseFragment parses only
williamr@2
   349
         * namespace (xmlns) attributes from the document.
williamr@2
   350
         * Subclasses should override this method if they are intrested
williamr@2
   351
         * of handling any other XML attributes and their corresponding
williamr@2
   352
         * values.
williamr@2
   353
         * @since Series60 3.0
williamr@2
   354
         * @param aAttrs:   the array of attributes.
williamr@2
   355
         */
williamr@2
   356
        IMPORT_C virtual void SetAttributesL(const RAttributeArray& aAttrs);
williamr@2
   357
        
williamr@2
   358
        /**
williamr@2
   359
         * Writes the start element tag to the content stream. 
williamr@2
   360
         * Derivants can override the basic usage used in BaseFragment.
williamr@2
   361
         * @since Series60 3.0
williamr@2
   362
         * @param aNsUri        The namespace URI of the current element
williamr@2
   363
         * @param aLocalName        The local name of the current element
williamr@2
   364
         * @param aQName        The qualified name of the current element
williamr@2
   365
         * @param aAttrs        is the array of attributes.
williamr@2
   366
         */
williamr@2
   367
        IMPORT_C void WriteStartElementL(const TDesC8& aNsUri,
williamr@2
   368
                                         const TDesC8& aLocalName,
williamr@2
   369
                                         const TDesC8& aQName,
williamr@2
   370
                                         const RAttributeArray& aAttrs);
williamr@2
   371
        
williamr@2
   372
        /**
williamr@2
   373
         * Writes the end element tag to the content stream. 
williamr@2
   374
         * Derivants can override the basic usage used in BaseFragment.
williamr@2
   375
         * @since Series60 3.0
williamr@2
   376
         * @param aNsUri        The namespace URI of the current element
williamr@2
   377
         * @param aLocalName    The local name of the current element
williamr@2
   378
         * @param aQName        The qualified name of the current element
williamr@2
   379
         */
williamr@2
   380
        IMPORT_C void WriteEndElementL(const TDesC8& aNsUri,
williamr@2
   381
                                       const TDesC8& aLocalName,
williamr@2
   382
                                       const TDesC8& aQName);
williamr@2
   383
williamr@2
   384
        /**
williamr@2
   385
         * Gets the fragment data as an unicode XML.
williamr@2
   386
         * @since Series60 3.0
williamr@2
   387
         * @return  fragment as XML. Caller takes ownership.
williamr@2
   388
         */ 
williamr@2
   389
        IMPORT_C virtual HBufC* AsXmlUnicodeL();
williamr@2
   390
williamr@2
   391
        /**
williamr@2
   392
         * Gets the fragment data as an UTF-8 form XML.
williamr@2
   393
         * @since Series60 3.0
williamr@2
   394
         * @return  fragment as XML. Caller takes ownership.
williamr@2
   395
         */ 
williamr@2
   396
        IMPORT_C virtual HBufC8* AsXmlL();
williamr@2
   397
williamr@2
   398
        /**
williamr@2
   399
         * Invokes AsElement()->WriteAsXMLToL(aWs);
williamr@2
   400
         * @since Series60 3.0
williamr@2
   401
         * @param aWs is the stream into which the UTF-8 form XML will
williamr@2
   402
         *            be written.
williamr@2
   403
         */
williamr@2
   404
        IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs);
williamr@2
   405
williamr@2
   406
        /**
williamr@2
   407
         * Checks if fragment matches to another fragment 
williamr@2
   408
         * by its content and child elements. 
williamr@2
   409
         * Fragment can contain more data than the given candidate.
williamr@2
   410
         * @since Series60 3.0
williamr@2
   411
         * @param aCandidate    The pattern to be matched. Must contain same or 
williamr@2
   412
         *                      less data for match to come true.
williamr@2
   413
         * @return ETrue if content and possible children match exactly 
williamr@2
   414
         *               to given pattern. EFalse otherwise.
williamr@2
   415
         */
williamr@2
   416
        IMPORT_C virtual TBool ConsistsOfL(MSenFragment& aCandidate);
williamr@2
   417
williamr@2
   418
    protected:  
williamr@2
   419
        
williamr@2
   420
        /**
williamr@2
   421
        * C++ default constructor.
williamr@2
   422
        */
williamr@2
   423
        IMPORT_C CSenBaseFragment();        
williamr@2
   424
        
williamr@2
   425
        /**
williamr@2
   426
         * Following BaseConstructL methods should be called from ConstructL() 
williamr@2
   427
         * methods of some deriving (fragment) class.
williamr@2
   428
         */
williamr@2
   429
williamr@2
   430
        /**
williamr@2
   431
        * BaseConstructL, where an element is given as initializer.
williamr@2
   432
        * @since Series60 3.0
williamr@2
   433
        * @param aElement from which this fragment will be constructed from.
williamr@2
   434
        */
williamr@2
   435
        IMPORT_C void BaseConstructL(const CSenElement& aElement);
williamr@2
   436
        
williamr@2
   437
        /**
williamr@2
   438
        * BaseConstructL setting XML localname for this fragment.
williamr@2
   439
        * @since Series60 3.0
williamr@2
   440
        * @param aLocalName XML localname for this fragment
williamr@2
   441
        */
williamr@2
   442
        IMPORT_C void BaseConstructL(const TDesC8& aLocalName);
williamr@2
   443
williamr@2
   444
        /**
williamr@2
   445
        * BaseConstructL offering possibility to set XML namespace and localname.
williamr@2
   446
        * @since Series60 3.0
williamr@2
   447
        * @param aNsUri XML namespace URI for this fragment
williamr@2
   448
        * @param aLocalName XML localname for this fragment
williamr@2
   449
        */
williamr@2
   450
        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
williamr@2
   451
                                     const TDesC8& aLocalName);
williamr@2
   452
williamr@2
   453
        /**
williamr@2
   454
        * Base constructor
williamr@2
   455
        * @since Series60 3.0
williamr@2
   456
        * @param aNsUri XML namespace URI for this fragment
williamr@2
   457
        * @param aLocalName XML localname for this fragment
williamr@2
   458
        * @param aQName XML qualifiedname for this fragment
williamr@2
   459
        */
williamr@2
   460
        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
williamr@2
   461
                                     const TDesC8& aLocalName,
williamr@2
   462
                                     const TDesC8& aQName);
williamr@2
   463
        /**
williamr@2
   464
        * Base constructor
williamr@2
   465
        * @since Series60 3.0
williamr@2
   466
        * @param aNsUri XML namespace URI for this fragment
williamr@2
   467
        * @param aLocalName XML localname for this fragment
williamr@2
   468
        * @param aQName XML qualifiedname for this fragment
williamr@2
   469
        * @param aAttrs XML attributes for this fragment
williamr@2
   470
        */
williamr@2
   471
        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
williamr@2
   472
                                     const TDesC8& aLocalName,
williamr@2
   473
                                     const TDesC8& aQName,
williamr@2
   474
                                     const RAttributeArray& aAttrs);
williamr@2
   475
williamr@2
   476
        /**
williamr@2
   477
        * Base constructor
williamr@2
   478
        * @since Series60 3.0
williamr@2
   479
        * @param aNsUri XML namespace URI for this fragment
williamr@2
   480
        * @param aLocalName XML localname for this fragment
williamr@2
   481
        * @param aQName XML qualifiedname for this fragment
williamr@2
   482
        * @param aAttrs XML attributes for this fragment
williamr@2
   483
        * @param aParent parent to be set for this fragmemt
williamr@2
   484
        */
williamr@2
   485
        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
williamr@2
   486
                                     const TDesC8& aLocalName,
williamr@2
   487
                                     const TDesC8& aQName,
williamr@2
   488
                                     const RAttributeArray& aAttrs,
williamr@2
   489
                                     CSenElement& aParent);
williamr@2
   490
williamr@2
   491
        /**
williamr@2
   492
        * BaseConstructL() setting the XML reader for this fragment
williamr@2
   493
        * @since Series60 3.0
williamr@2
   494
        * @param aReader is the XML reader for this fragment
williamr@2
   495
        */
williamr@2
   496
        IMPORT_C void BaseConstructL(CSenXmlReader& aReader);
williamr@2
   497
        
williamr@2
   498
        // New functions
williamr@2
   499
         
williamr@2
   500
        /**
williamr@2
   501
        * Makes the content internal stream for content saving available.
williamr@2
   502
        * @since Series60 3.0
williamr@2
   503
        */
williamr@2
   504
        IMPORT_C virtual void AllocContentSaverL();     
williamr@2
   505
williamr@2
   506
        /**
williamr@2
   507
         * Callback function implementing the XML content handler interface.
williamr@2
   508
         * Inheriting classes can override these.
williamr@2
   509
         * @since Series60 3.0
williamr@2
   510
         * @param aNsUri        The namespace URI of the new element
williamr@2
   511
         * @param aLocalName    The local name of the new element
williamr@2
   512
         * @param aQName        The qualified name of the new element
williamr@2
   513
         * @param aAttrs        The attributes of the new element
williamr@2
   514
         */
williamr@2
   515
        IMPORT_C virtual void StartElementL(const TDesC8& aNsUri,
williamr@2
   516
                                            const TDesC8& aLocalName,
williamr@2
   517
                                            const TDesC8& aQName,
williamr@2
   518
                                            const RAttributeArray& aAttrs);
williamr@2
   519
williamr@2
   520
        /**
williamr@2
   521
        * Callback function which implement the XML content handler interface.
williamr@2
   522
        * Inheriting classes can override these.
williamr@2
   523
        * @since Series60 3.0
williamr@2
   524
        * @param aNsUri     The namespace URI of the new element
williamr@2
   525
        * @param aLocalName     The local name of the new element
williamr@2
   526
        * @param aQName     The qualified name of the new element
williamr@2
   527
        */
williamr@2
   528
        IMPORT_C virtual void EndElementL(const TDesC8& aNsUri,
williamr@2
   529
                                          const TDesC8& aLocalName,
williamr@2
   530
                                          const TDesC8& aQName);
williamr@2
   531
williamr@2
   532
        /**
williamr@2
   533
        * Function which implement the XML content handler interface.
williamr@2
   534
        * Inheriting classes can override these.
williamr@2
   535
        * This one is called when content is starting.
williamr@2
   536
        * @since Series60 3.0
williamr@2
   537
        * @param aChars     The content characters.
williamr@2
   538
        * @param aStart     The starting index
williamr@2
   539
        * @param aLength        The length of the characters.
williamr@2
   540
        */
williamr@2
   541
        IMPORT_C virtual void CharactersL(const TDesC8& aChars,
williamr@2
   542
                                          TInt aStart,
williamr@2
   543
                                          TInt aLength);
williamr@2
   544
williamr@2
   545
        /**
williamr@2
   546
        *  Callback function which implement the XML content handler interface.
williamr@2
   547
        *  Inheriting classes can override these. Note that overrides should
williamr@2
   548
        *  return TRUE (1) on success and FALSE (0) on failure to parser.
williamr@2
   549
        *
williamr@2
   550
        *  @since Series60 3.0
williamr@2
   551
        *  @param aName     The entity name
williamr@2
   552
        *
williamr@2
   553
        */
williamr@2
   554
        IMPORT_C TInt StartEntity(TDesC8& aName);
williamr@2
   555
williamr@2
   556
        /**
williamr@2
   557
         * Sets content to a child element. If no element with given local name
williamr@2
   558
         * is not found, new one is added and content is set to that one.
williamr@2
   559
         * @since Series60 3.0
williamr@2
   560
         * @param aLocalName    The local name of element which content
williamr@2
   561
         *                      is about to be set
williamr@2
   562
         * @param aContent      Content to be set.
williamr@2
   563
         * @return              the element where content was set.
williamr@2
   564
         * Leave codes: 
williamr@2
   565
         *      KErrSenInvalidCharacters if aLocalName contains illegal characters.     
williamr@2
   566
         *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
williamr@2
   567
         */
williamr@2
   568
        IMPORT_C MSenElement& SetContentOfL(const TDesC8& aLocalName,
williamr@2
   569
                                            const TDesC8& aContent);
williamr@2
   570
        /**
williamr@2
   571
         * Gets the content of a given element.
williamr@2
   572
         * @since Series60 3.0
williamr@2
   573
         * @param aLocalName    The local name of the element which content is 
williamr@2
   574
         *                      asked
williamr@2
   575
         * @return  the content which was asked
williamr@2
   576
         */
williamr@2
   577
        IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName);        
williamr@2
   578
williamr@2
   579
    private: // New functions
williamr@2
   580
        
williamr@2
   581
        /**
williamr@2
   582
         * Leaving variant which is then trapped in the non-leaving function.
williamr@2
   583
         */
williamr@2
   584
        TPtrC8 ContentL();
williamr@2
   585
    
williamr@2
   586
        // Functions from base classes
williamr@2
   587
williamr@2
   588
        // From MSenContentHandlerClient
williamr@2
   589
        
williamr@2
   590
        IMPORT_C virtual TInt StartDocument();
williamr@2
   591
        IMPORT_C virtual TInt EndDocument();
williamr@2
   592
        IMPORT_C virtual TInt StartElement(const TDesC8& aNsUri,
williamr@2
   593
                                           const TDesC8& aLocalName,
williamr@2
   594
                                           const TDesC8& aQName,
williamr@2
   595
                                           const RAttributeArray& aAttrs);
williamr@2
   596
        
williamr@2
   597
        IMPORT_C virtual TInt EndElement(const TDesC8& aNsUri,
williamr@2
   598
                                         const TDesC8& aLocalName,
williamr@2
   599
                                         const TDesC8& aQName);
williamr@2
   600
williamr@2
   601
        IMPORT_C virtual TInt Characters(const TDesC8& aChars,
williamr@2
   602
                                         const TInt aStart,
williamr@2
   603
                                         const TInt aLength);
williamr@2
   604
williamr@2
   605
        IMPORT_C virtual TInt Error(TInt aErrorCode);
williamr@2
   606
williamr@2
   607
        //IMPORT_C TInt StartEntityL(const TDesC8& aName);
williamr@2
   608
williamr@2
   609
williamr@2
   610
    protected: // Data
williamr@2
   611
williamr@2
   612
        // State variable indicating what this fragment
williamr@2
   613
        // is currently parsing. Even states (like 0)
williamr@2
   614
        // mean that this fragment is ignoring the
williamr@2
   615
        // data, and odd states indicate, that fragment
williamr@2
   616
        // is storing the data into itself.
williamr@2
   617
        TInt iState;
williamr@2
   618
        // Owned element containing this XML fragment data.
williamr@2
   619
        CSenElement* ipElement;
williamr@2
   620
        // Pointer to XML parser. Not owned.
williamr@2
   621
        CSenXmlReader* iXmlReader;      
williamr@2
   622
        // Possible owner fragment, if such exists. Not owned.
williamr@2
   623
        MSenFragment* ipOwner;
williamr@2
   624
        // Internal write stream, into which UTF-8 form XML is stored
williamr@2
   625
        RWriteStream iWs;
williamr@2
   626
williamr@2
   627
    private: // Data
williamr@2
   628
         
williamr@2
   629
        // Owned pointer to delegate fragment
williamr@2
   630
        CSenFragment* ipDelegate;
williamr@2
   631
        // Not owned. Holds namespaces that are referred to from 
williamr@2
   632
        // within the content but were not declared within this 
williamr@2
   633
        // BaseFragment.
williamr@2
   634
        RPointerArray<CSenNamespace> iNamespaces;
williamr@2
   635
        // Owned. Holds prefixes that have been declared within the 
williamr@2
   636
        // scope of this BaseFragment
williamr@2
   637
        RPointerArray<HBufC8> iPrefixes;
williamr@2
   638
        // Actual flat buffer to content which includes namespaces.
williamr@2
   639
        CBufFlat* ipContentWithNamespaces;
williamr@2
   640
        // Indicating that content writing stream is initialized.
williamr@2
   641
        TBool hasContentWriteStream;
williamr@2
   642
        // Indicates whether or not ipElement member is an owned
williamr@2
   643
        TBool iElementOwned;
williamr@2
   644
    };
williamr@2
   645
williamr@2
   646
#endif //SEN_BASE_FRAGMENT_H
williamr@2
   647
williamr@2
   648
// End of File
williamr@2
   649
williamr@2
   650
williamr@2
   651