epoc32/include/mw/senbaseelement.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:        Implementation of an XML element functionality
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_ELEMENT_H
williamr@2
    26
#define SEN_BASE_ELEMENT_H
williamr@2
    27
williamr@2
    28
//  INCLUDES
williamr@2
    29
#include <s32mem.h>
williamr@2
    30
#include <SenElement.h>
williamr@4
    31
#include <SenNameSpace.h>
williamr@2
    32
#include <SenBaseAttribute.h>
williamr@2
    33
williamr@2
    34
// CLASS DECLARATION
williamr@2
    35
williamr@2
    36
/**
williamr@2
    37
*  Implementation of an XML element functionality
williamr@2
    38
*  Content is stored in UTF-8 form XML. Note, that
williamr@2
    39
*  setting any 8-bit content into XML without encoding
williamr@2
    40
*  it into form of legal is illegal. Instead, one
williamr@2
    41
*  should use encoding methods, like ones introduced 
williamr@2
    42
*  in SenXmlUtils class to encode basic entities, or
williamr@2
    43
*  use use some other encoding like MD5 for binary 
williamr@2
    44
*  data content.
williamr@2
    45
*  @lib SenXML.dll
williamr@2
    46
*  @since Series60 3.0
williamr@2
    47
*/
williamr@2
    48
class CSenBaseElement : public CSenElement
williamr@2
    49
    {
williamr@2
    50
    public:  // Constructors and destructor
williamr@2
    51
williamr@2
    52
        /**
williamr@2
    53
         *  Standard constructor.
williamr@2
    54
         *  @param aLocalName   the local name for this element.
williamr@2
    55
         *  Leave codes:    
williamr@2
    56
         *      KErrSenInvalidCharacters if aLocalName contains illegal characters.     
williamr@2
    57
         *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
williamr@2
    58
         */
williamr@2
    59
williamr@2
    60
        IMPORT_C static CSenBaseElement* NewL(const TDesC8& aLocalName);
williamr@2
    61
        /**
williamr@2
    62
         *  Standard constructor.
williamr@2
    63
         *  @param aNsUri       the namespace URI for this element.
williamr@2
    64
         *  @param aLocalName   the local name for this element.
williamr@2
    65
         *  Leave codes:    
williamr@2
    66
         *      KErrSenInvalidCharacters if aLocalName contains illegal characters.     
williamr@2
    67
         *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
williamr@2
    68
         */
williamr@2
    69
        IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri,
williamr@2
    70
                                              const TDesC8& aLocalName);
williamr@2
    71
williamr@2
    72
        /**
williamr@2
    73
         *  Standard constructor.
williamr@2
    74
         *  @param aNsUri       the namespace URI for this element.
williamr@2
    75
         *  @param aLocalName   the local name for this element.
williamr@2
    76
         *  @param aQName       the qualified name for this element.
williamr@2
    77
         *  Leave codes:    
williamr@2
    78
         *      KErrSenInvalidCharacters if aLocalName or aQName contains
williamr@2
    79
         *      illegal characters.     
williamr@2
    80
         *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
    81
         */
williamr@2
    82
        IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri,
williamr@2
    83
                                              const TDesC8& aLocalName,
williamr@2
    84
                                              const TDesC8& aQName);
williamr@2
    85
williamr@2
    86
        /**
williamr@2
    87
         *  Standard constructor.
williamr@2
    88
         *  @param aNsUri       the namespace URI for this element.
williamr@2
    89
         *  @param aLocalName   the local name for this element.
williamr@2
    90
         *  @param aQName       the qualified name for this element.
williamr@2
    91
         *  @param apAttrs      the attributes for this element.
williamr@2
    92
         *  Leave codes:    
williamr@2
    93
         *      KErrSenInvalidCharacters if aLocalName or aQName contains
williamr@2
    94
         *      illegal characters.     
williamr@2
    95
         *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
    96
         */
williamr@2
    97
        IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri,
williamr@2
    98
                                              const TDesC8& aLocalName,
williamr@2
    99
                                              const TDesC8& aQName,
williamr@2
   100
                                              const RAttributeArray& apAttrs);
williamr@2
   101
williamr@2
   102
        /**
williamr@2
   103
         *  Standard constructor.
williamr@2
   104
         *  @param aNsUri       the namespace URI for this element.
williamr@2
   105
         *  @param aLocalName   the local name for this element.
williamr@2
   106
         *  @param aQName       the qualified name for this element.
williamr@2
   107
         *  @param apAttrs      the attributes for this element.
williamr@2
   108
         *  @param aParent: the parent element for the new element
williamr@2
   109
         *  Leave codes:    
williamr@2
   110
         *      KErrSenInvalidCharacters if aLocalName or aQName contains
williamr@2
   111
         *      illegal characters.     
williamr@2
   112
         *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
   113
         */
williamr@2
   114
        IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri,
williamr@2
   115
                                              const TDesC8& aLocalName,
williamr@2
   116
                                              const TDesC8& aQName,
williamr@2
   117
                                              const RAttributeArray& apAttrs,
williamr@2
   118
                                              CSenElement& aParent);
williamr@2
   119
williamr@2
   120
        /**
williamr@2
   121
        * Destructor.
williamr@2
   122
        */
williamr@2
   123
        IMPORT_C virtual ~CSenBaseElement();
williamr@2
   124
williamr@2
   125
        // New functions
williamr@2
   126
    
williamr@2
   127
        /**
williamr@2
   128
         * Adds attributes to the element. Calls internally AddAttributesL()
williamr@2
   129
         * Can be overridden to replace old attributes.
williamr@2
   130
         * @param   aAttrs: the array of attributes.
williamr@2
   131
         */
williamr@2
   132
        IMPORT_C virtual void SetAttributesL(const RAttributeArray& apAttrs);
williamr@2
   133
    
williamr@2
   134
        // Functions from base classes
williamr@2
   135
    
williamr@2
   136
        // From CSenElement
williamr@2
   137
    
williamr@2
   138
        /**
williamr@2
   139
        *   Getter for Element's local name.
williamr@2
   140
        *   @return Localname or KNullDesC if not set.
williamr@2
   141
        */  
williamr@2
   142
        IMPORT_C virtual const TDesC8& LocalName() const;
williamr@2
   143
williamr@2
   144
        /**
williamr@2
   145
        *   Getter for Element's namespace URI.
williamr@2
   146
        *   @return Namespace URI or KNullDesC if not set.
williamr@2
   147
        */
williamr@2
   148
        IMPORT_C virtual const TDesC8& NamespaceURI() const;
williamr@2
   149
williamr@2
   150
        /**
williamr@2
   151
         *  Getter for namespace prefix of this element.
williamr@2
   152
         *  @return namespace prefix or KNullDesC if not set.
williamr@2
   153
         */
williamr@2
   154
        IMPORT_C virtual const TDesC8& NsPrefix() const;
williamr@2
   155
williamr@2
   156
        /**
williamr@2
   157
         *  Setter for namespace prefix of this element.
williamr@2
   158
         *  @param aPrefix: new namespace prefix for the element.
williamr@2
   159
         */
williamr@2
   160
        IMPORT_C virtual void SetPrefixL(const TDesC8& aPrefix);
williamr@2
   161
williamr@2
   162
        /**
williamr@2
   163
         *  Method for checking if the element has any content within.
williamr@2
   164
         *  @return ETrue if has content, EFalse if not.
williamr@2
   165
         */
williamr@2
   166
        IMPORT_C virtual TBool HasContent() const;
williamr@2
   167
williamr@2
   168
        /**
williamr@2
   169
         *  Getter for the content of the element.
williamr@2
   170
         *  @return the content or KNullDesC if empty.
williamr@2
   171
         */
williamr@2
   172
        IMPORT_C virtual TPtrC8 Content() const;
williamr@2
   173
williamr@2
   174
        /**
williamr@2
   175
         *  Getter for the content of the element, unicode version.
williamr@2
   176
         *  @return content as unicode. Ownership IS TRANSFERRED to the caller.
williamr@2
   177
         */
williamr@2
   178
        IMPORT_C virtual HBufC* ContentUnicodeL() const;
williamr@2
   179
williamr@2
   180
        /**
williamr@2
   181
         *  Sets the content to the element. Old content is overwritten.
williamr@2
   182
         *  @param  aContent:   The content to be set. Can be KNullDesC8.
williamr@2
   183
         *  @return The content of the element or KNullDesC8 if no content was set.
williamr@2
   184
         */
williamr@2
   185
        IMPORT_C virtual TPtrC8 SetContentL(const TDesC8& aContent);
williamr@2
   186
williamr@2
   187
        /**
williamr@2
   188
         *  Gets the write stream for the content for easy appending.
williamr@2
   189
         *  Writing 8-bit (UTF-8) string to the returned stream will be appended
williamr@2
   190
         *  to the content.
williamr@2
   191
         *  @return reference to the RWriteStream.
williamr@2
   192
         */
williamr@2
   193
        IMPORT_C virtual RWriteStream& ContentWriteStreamL();
williamr@2
   194
williamr@2
   195
        /**
williamr@2
   196
         * Checks if element matches to another element
williamr@2
   197
         * by its content and child elements. Element
williamr@2
   198
         * can contain more data than the given pattern.
williamr@2
   199
         * @since Series60 3.0
williamr@2
   200
         * @param aCandidate    The pattern to be matched. Must contain same or 
williamr@2
   201
         *                  less data for match to come true.
williamr@2
   202
         * @return ETrue if content and possible children match exactly 
williamr@2
   203
         *          to given pattern. EFalse otherwise.
williamr@2
   204
         */
williamr@2
   205
        IMPORT_C virtual TBool ConsistsOfL(MSenElement& aCandidate);
williamr@2
   206
williamr@2
   207
        /**
williamr@2
   208
        *   Setter for Element's namespace URI.
williamr@2
   209
        *   @param aNsUri:  Namespace URI
williamr@2
   210
         */
williamr@2
   211
        IMPORT_C virtual void SetNamespaceL(const TDesC8& aNsUri);
williamr@2
   212
williamr@2
   213
        /**
williamr@2
   214
        *   Setter for Element's namespace URI.
williamr@2
   215
        *   @param aNsPrefix:   Namespace prefix
williamr@2
   216
        *   @param aNsUri:      Namespace URI
williamr@2
   217
         */
williamr@2
   218
        IMPORT_C virtual void SetNamespaceL(const TDesC8& aNsPrefix,
williamr@2
   219
                                            const TDesC8& aNsUri);
williamr@2
   220
williamr@2
   221
        /**
williamr@2
   222
         * Adds a namespace declaration.
williamr@2
   223
         * If this element (or its parent if parameter aCheckInParent is ETrue) 
williamr@2
   224
         * already has a Namespace with the same prefix and URI the given
williamr@2
   225
         * Namespace is not added.
williamr@2
   226
         * @param aNewNamespace
williamr@2
   227
         * @param aCheckInParent
williamr@2
   228
         * @return the added Namespace, or the equivalent pre-existing one.
williamr@2
   229
         */ 
williamr@2
   230
        IMPORT_C virtual const CSenNamespace* AddNamespaceL(
williamr@2
   231
                                            CSenNamespace& aNewNamespace,
williamr@2
   232
                                            TBool aCheckInParent);
williamr@2
   233
        /**
williamr@2
   234
        *   Method for adding a namespace for the Element.
williamr@2
   235
        *   @param aPrefix: Namespace prefix
williamr@2
   236
        *   @param aUri:    Namespace URI
williamr@2
   237
        *   @return the added Namespace, or the equivalent pre-existing one.
williamr@2
   238
         */
williamr@2
   239
        IMPORT_C virtual const CSenNamespace* AddNamespaceL(const TDesC8& aPrefix,
williamr@2
   240
                                                            const TDesC8& aUri);
williamr@2
   241
        /**
williamr@2
   242
        *   Getter for Element's namespace.
williamr@2
   243
        *   @return const pointer to the CSenNamespace object of this Element.
williamr@2
   244
        *           NULL if not set.
williamr@2
   245
         */ 
williamr@2
   246
        IMPORT_C virtual const CSenNamespace* Namespace();
williamr@2
   247
williamr@2
   248
        /**
williamr@2
   249
         * @param prefix
williamr@2
   250
         * @return the found Namespace that is declared for the given prefix
williamr@2
   251
         * within the scope of this Element. If no such prefix is
williamr@2
   252
         * declared return null.
williamr@2
   253
         */     
williamr@2
   254
        IMPORT_C virtual const CSenNamespace* Namespace(const TDesC8& aNsPrefix);
williamr@2
   255
williamr@2
   256
        /**
williamr@2
   257
         * @param aNsPrefix:        The prefix used to search
williamr@2
   258
         * @param aCheckInParent:   The flag indicating whether to check parent's
williamr@2
   259
         *                          namespaces too if not found in the current 
williamr@2
   260
         *                          element. 
williamr@2
   261
         *                          ETrue to check, EFalse for not to check.
williamr@2
   262
         * @return the found Namespace that is declared for the given prefix 
williamr@2
   263
         *                   and namespace URI within the scope of this Element
williamr@2
   264
         *                   or NULL if not found
williamr@2
   265
         */ 
williamr@2
   266
        IMPORT_C virtual const CSenNamespace* Namespace(const TDesC8& aNsPrefix,
williamr@2
   267
                                                        const TBool aCheckInParent);
williamr@2
   268
williamr@2
   269
        /**
williamr@2
   270
         * @param aNsPrefix:    The prefix used to search
williamr@2
   271
         * @param aUri:         The namespace URI used to search.
williamr@2
   272
         * @return the found Namespace that is declared for the given prefix 
williamr@2
   273
         *                   and namespace URI within the scope of this Element
williamr@2
   274
         *                   or NULL if not found.
williamr@2
   275
         */     
williamr@2
   276
        IMPORT_C virtual const CSenNamespace* Namespace(const TDesC8& aNsPrefix,
williamr@2
   277
                                                        const TDesC8& aUri);
williamr@2
   278
williamr@2
   279
        /**
williamr@2
   280
         *  Getting the child elements of this element matching the given criteria.
williamr@2
   281
         *  @param aElementArray:   Array to be filled with the matching elements,
williamr@2
   282
         *                          or empty array if no matching found. 
williamr@2
   283
         *                          Any modifications made on the returned items
williamr@2
   284
         *                          modify the real childs too.
williamr@2
   285
         *  @param aNsUri:          namespace URI to be matched
williamr@2
   286
         *  @param aLocalName:      local name to be matched
williamr@2
   287
         *  @return KErrNone        ok
williamr@2
   288
         *          KErrNotFound    No child elements exist.
williamr@2
   289
         */     
williamr@2
   290
        IMPORT_C virtual TInt ElementsL(RPointerArray<CSenElement>& aElementArray,
williamr@2
   291
                                        const TDesC8& aNsUri,
williamr@2
   292
                                        const TDesC8& aLocalName);
williamr@2
   293
        
williamr@2
   294
        /**
williamr@2
   295
         *  Getting the child elements of this element matching the given criteria.
williamr@2
   296
         *  @param aElementArray:   Array to be filled with the matching elements,
williamr@2
   297
         *                          or empty array if no matching found. 
williamr@2
   298
         *                          Any modifications made on the returned items
williamr@2
   299
         *                          modify the real childs too.
williamr@2
   300
         *  @param aNsUri:          namespace URI to be matched
williamr@2
   301
         *  @param aLocalName:      local name to be matched
williamr@2
   302
         *  @return KErrNone        ok
williamr@2
   303
         *          KErrNotFound    No child elements exist.
williamr@2
   304
         */     
williamr@2
   305
        IMPORT_C virtual TInt ElementsL(RPointerArray<CSenElement>& aElementArray,
williamr@2
   306
                                        const TDesC8& aLocalName);
williamr@2
   307
williamr@2
   308
        /**
williamr@2
   309
         *  Getting the child elements of this element.
williamr@2
   310
         *  @return an array of child elements. This is an empty array if there
williamr@2
   311
         *          are no children. Any modifications made on the returned array
williamr@2
   312
         *          modify the element object.
williamr@2
   313
         */     
williamr@2
   314
        IMPORT_C virtual RPointerArray<CSenElement>& ElementsL();
williamr@2
   315
williamr@2
   316
        /**
williamr@2
   317
         *  Gets all the attributes of this element in an array.
williamr@2
   318
         *  @return array of attributes. Array will be empty if element has 
williamr@2
   319
         *          no attributes.
williamr@2
   320
         */     
williamr@2
   321
        IMPORT_C virtual RPointerArray<CSenBaseAttribute>& AttributesL();
williamr@2
   322
williamr@2
   323
        /**
williamr@2
   324
         *  Gets all the namespaces of this element in an array.
williamr@2
   325
         *  @return array of namespaces. Array will be empty if element has 
williamr@2
   326
         *          no namespaces.
williamr@2
   327
         */     
williamr@2
   328
        IMPORT_C virtual RPointerArray<CSenNamespace>& NamespacesL();
williamr@2
   329
williamr@2
   330
        /**
williamr@2
   331
         *  Gets the value of the given attribute.
williamr@2
   332
         *  @param aName:   Name of the attribute in question.
williamr@2
   333
         *  @return the value of the attribute, or NULL if not found. Ownership is
williamr@2
   334
         *          NOT TRANSFERRED.
williamr@2
   335
         */     
williamr@2
   336
        IMPORT_C virtual const TDesC8* AttrValue(const TDesC8& aName);
williamr@2
   337
        
williamr@2
   338
        /**
williamr@2
   339
         *  Adds an attribute. If attribute is already existing, 
williamr@2
   340
         *  the value of the attribute will be replaced.
williamr@2
   341
         */
williamr@2
   342
        IMPORT_C virtual void AddAttrL(const TDesC8& aName, const TDesC8& aValue);
williamr@2
   343
williamr@2
   344
        /**
williamr@2
   345
         *  Gets the parent element of this element.
williamr@2
   346
         *  @return the parent element or NULL if no parent set. 
williamr@2
   347
         *          Ownership is NOT transferred to the caller.
williamr@2
   348
         */     
williamr@2
   349
        IMPORT_C virtual CSenElement* Parent();
williamr@2
   350
williamr@2
   351
        /**
williamr@2
   352
         *  Sets the parent element to this element. Notice that the element is not
williamr@2
   353
         *  automatically added as a child of the parent. Parent's 
williamr@2
   354
         *  AddElementL() should be called instead.
williamr@2
   355
         *  @param apParent:    The wanted parent. Can be NULL.
williamr@2
   356
         *  @return the parent element
williamr@2
   357
         */ 
williamr@2
   358
        IMPORT_C virtual CSenElement* SetParent(CSenElement* apParent);
williamr@2
   359
williamr@2
   360
        /**
williamr@2
   361
         *  Gets the root element. If no parent element, returns this element.
williamr@2
   362
         *  @return the root of the tree. Ownership is NOT transferred.
williamr@2
   363
         */     
williamr@2
   364
        IMPORT_C virtual MSenElement& Root();
williamr@2
   365
williamr@2
   366
        /**
williamr@2
   367
         *  Gets the child element with the specified local name.
williamr@2
   368
         *  Assumes that namespace is the same as this parent element.
williamr@2
   369
         *  @return the child element or NULL if the child with the specified 
williamr@2
   370
         *          local name is not found. Ownership is NOT transferred.
williamr@2
   371
         */ 
williamr@2
   372
        IMPORT_C virtual CSenElement* Element(const TDesC8& aLocalName);
williamr@2
   373
williamr@2
   374
        /**
williamr@2
   375
         *  Gets the child element with the specified local name and namespace URI.
williamr@2
   376
         *  @return the child element or NULL if the child with the specified 
williamr@2
   377
         *          criterias is not found. Ownership is NOT transferred.
williamr@2
   378
         */ 
williamr@2
   379
        IMPORT_C virtual CSenElement* Element(  const TDesC8& aNsUri,
williamr@2
   380
                                                const TDesC8& aLocalName);
williamr@2
   381
williamr@2
   382
        /**
williamr@2
   383
         * Create a new element ready for adding or insertion.
williamr@2
   384
         * If the given namespace prefix is not declared yet
williamr@2
   385
         * the element will not be created and NULL will be returned.
williamr@2
   386
         * @param aNsPrefix:    The namespace prefix
williamr@2
   387
         * @param aLocalName:   The new elements localname
williamr@2
   388
         * @return  the new Element just created, or NULL if given prefix was not
williamr@2
   389
         *          declared yet. Ownership is transferred to the caller.
williamr@2
   390
         *  Leave codes:    
williamr@2
   391
         *      KErrSenInvalidCharacters if aLocalName contains illegal characters.     
williamr@2
   392
         *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
   393
         */     
williamr@2
   394
        IMPORT_C virtual CSenElement* CreateElementL(const TDesC8& aNsPrefix,
williamr@2
   395
                                                     const TDesC8& aLocalName);
williamr@2
   396
williamr@2
   397
        /**
williamr@2
   398
         * Insert an Element into the list of children elements
williamr@2
   399
         * so that the inserted Element is placed right before the aBeforeElement.
williamr@2
   400
         * If aBeforeElement is not found, element will be appended to the last
williamr@2
   401
         * position.
williamr@2
   402
         * Function leaves if error occurs in inserting.
williamr@2
   403
         * @param aInsertedElement: the element to be inserted. 
williamr@2
   404
         *                          Ownership is transferred.
williamr@2
   405
         * @param aBeforeElement:   the element which will be right next to the 
williamr@2
   406
         *                          element just inserted.
williamr@2
   407
         * @return the inserted Element
williamr@2
   408
         */     
williamr@2
   409
        IMPORT_C virtual CSenElement& InsertElementL(CSenElement& aElement,
williamr@2
   410
                                                     const CSenElement& aBeforeElement);
williamr@2
   411
williamr@2
   412
        /**
williamr@2
   413
         * Adds an Element to the children elements. 
williamr@2
   414
         * Sets this element to be the new parent of the given element.
williamr@2
   415
         * @param aElement: the element to be added. Ownership is transferred.
williamr@2
   416
         * @return the added Element
williamr@2
   417
         */ 
williamr@2
   418
        IMPORT_C virtual CSenElement& AddElementL(CSenElement& aElement);
williamr@2
   419
williamr@2
   420
        /**
williamr@2
   421
         * Constructs and adds a new element to the children elements. 
williamr@2
   422
         * Sets this element to be the new parent of the given element.
williamr@2
   423
         * @param aNsUri:       namespace URI of the new element
williamr@2
   424
         * @param aLocalName:   local name of the new element
williamr@2
   425
         * @return the added Element
williamr@2
   426
         *  Leave codes:    
williamr@2
   427
         *      KErrSenInvalidCharacters if aLocalName contains illegal characters.     
williamr@2
   428
         *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
williamr@2
   429
         */     
williamr@2
   430
        IMPORT_C virtual CSenElement& AddElementL(  const TDesC8& aNsUri,
williamr@2
   431
                                                    const TDesC8& aLocalName);
williamr@2
   432
williamr@2
   433
        /**
williamr@2
   434
         * Constructs and adds a new element to the children elements. 
williamr@2
   435
         * Sets this element to be the new parent of the given element.
williamr@2
   436
         * @param aNsUri:       namespace URI of the new element
williamr@2
   437
         * @param aLocalName:   local name of the new element
williamr@2
   438
         * @param aQName:       qualified name of the new element
williamr@2
   439
         * @return the added Element
williamr@2
   440
         *  Leave codes:    
williamr@2
   441
         *      KErrSenInvalidCharacters if aLocalName or aQName contain illegal 
williamr@2
   442
         *      characters.     
williamr@2
   443
         *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
   444
         */ 
williamr@2
   445
        IMPORT_C virtual CSenElement& AddElementL(const TDesC8& aNsUri,
williamr@2
   446
                                                  const TDesC8& aLocalName,
williamr@2
   447
                                                  const TDesC8& aQName);
williamr@2
   448
williamr@2
   449
        /**
williamr@2
   450
         * Constructs and adds a new element to the children elements. 
williamr@2
   451
         * Sets this element to be the new parent of the given element.
williamr@2
   452
         * Note: Element is created with no specific namespace, default namespace
williamr@2
   453
         * of some of the upper level elements are in effect if there is such a 
williamr@2
   454
         * namespace.
williamr@2
   455
         * @param aLocalName:   local name of the new element
williamr@2
   456
         * @return the added Element
williamr@2
   457
         *  Leave codes:    
williamr@2
   458
         *      KErrSenInvalidCharacters if aLocalName contains illegal characters.     
williamr@2
   459
         *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
williamr@2
   460
         */     
williamr@2
   461
        IMPORT_C virtual CSenElement& AddElementL(const TDesC8& aLocalName);
williamr@2
   462
williamr@2
   463
        /**
williamr@2
   464
         *  Remove an element from the childs.
williamr@2
   465
         *  @param  aElement:   the element to be removed.
williamr@2
   466
         *  @return The removed element. May be NULL if nothing was removed
williamr@2
   467
         *          (if element was not found from the childs).
williamr@2
   468
         *          The caller TAKES OWNERSHIP of the removed element.
williamr@2
   469
         */     
williamr@2
   470
        IMPORT_C virtual CSenElement* RemoveElement(CSenElement& aElement);
williamr@2
   471
williamr@2
   472
        /**
williamr@2
   473
         *  Remove an element from the childs.
williamr@2
   474
         *  @param  aNsUri:     the namespace URI of the element to be removed.
williamr@2
   475
         *  @param  aLocalName: the local name of the element to be removed.
williamr@2
   476
         *  @return The removed element. May be NULL if nothing was removed
williamr@2
   477
         *          (if element was not found from the childs).
williamr@2
   478
         *          The caller TAKES OWNERSHIP of the removed element.
williamr@2
   479
         */     
williamr@2
   480
        IMPORT_C virtual CSenElement* RemoveElement(const TDesC8& aNsUri,
williamr@2
   481
                                                    const TDesC8& aLocalName);
williamr@2
   482
williamr@2
   483
        /**
williamr@2
   484
         *  Remove an element from the childs.
williamr@2
   485
         *  @param  aLocalName: the local name of the element to be removed.
williamr@2
   486
         *  @return The removed element. May be NULL if nothing was removed
williamr@2
   487
         *          (if element was not found from the childs).
williamr@2
   488
         *          The caller TAKES OWNERSHIP of the removed element.
williamr@2
   489
         */     
williamr@2
   490
        IMPORT_C virtual CSenElement* RemoveElement(const TDesC8& aLocalName);
williamr@2
   491
williamr@2
   492
        /**
williamr@2
   493
         *  Replaces an element from the childs with another element. 
williamr@2
   494
         *  Element's local name and namespace URI will be used to match the
williamr@2
   495
         *  element to be replaced. If matching element is not found, will
williamr@2
   496
         *  normally add the given element to the childs.
williamr@2
   497
         *  @param  aElement:   the element to be added. Ownership is transferred.
williamr@2
   498
         *  @return The old element. May be NULL if nothing was replaced
williamr@2
   499
         *          (if element was not found from the childs).
williamr@2
   500
         *          The caller TAKES OWNERSHIP of the old element.
williamr@2
   501
         */ 
williamr@2
   502
        IMPORT_C virtual CSenElement* ReplaceElementL(CSenElement& aElement);
williamr@2
   503
williamr@2
   504
        /**
williamr@2
   505
         *  Gets the element as an XML buffer. Buffer will contain all the childs
williamr@2
   506
         *  @return element as XML. Caller takes ownership.
williamr@2
   507
         */ 
williamr@2
   508
        IMPORT_C virtual HBufC8* AsXmlL();
williamr@2
   509
williamr@2
   510
        /**
williamr@2
   511
         *  Gets the element as an unicode XML buffer. 
williamr@2
   512
         *  Buffer will contain all the childs etc.
williamr@2
   513
         *  @return element as XML. Caller takes ownership.
williamr@2
   514
         */     
williamr@2
   515
        IMPORT_C virtual HBufC* AsXmlUnicodeL();
williamr@2
   516
williamr@2
   517
        /**
williamr@2
   518
         *  Element writes itself to a write stream using UTF-8 charset encoding.
williamr@2
   519
         *  @param aWriteStream:    The stream to write to.
williamr@2
   520
         */     
williamr@2
   521
        IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWriteStream);
williamr@2
   522
williamr@2
   523
        /**
williamr@2
   524
         *  Element writes its namespaces to a write stream using UTF-8 charset 
williamr@2
   525
         *  encoding.
williamr@2
   526
         *  @param aWriteStream:    The stream to write to.
williamr@2
   527
         */     
williamr@2
   528
        IMPORT_C virtual void WriteNamespacesToL(RWriteStream& aWriteStream);
williamr@2
   529
williamr@2
   530
        /**
williamr@2
   531
         *  Gets the current element as XML element. Mostly used to get the
williamr@2
   532
         *  classes which implement this interface as an instance of this 
williamr@2
   533
         *  interface.
williamr@2
   534
         *  @return the current object as element. Ownership is NOT transferred.
williamr@2
   535
         */     
williamr@2
   536
        IMPORT_C virtual MSenElement* AsElement();
williamr@2
   537
williamr@2
   538
        /**
williamr@2
   539
         *  Copies content from given element to this element appending to the 
williamr@2
   540
         *  existing content if there is any.
williamr@2
   541
         *  @param aSource: The source element.
williamr@2
   542
         */ 
williamr@2
   543
        IMPORT_C void CopyFromL(CSenElement& aSource);
williamr@2
   544
williamr@2
   545
        /**
williamr@2
   546
         * Detach the element from its parent.
williamr@2
   547
         * If the element, or one of its children, is dependent
williamr@2
   548
         * on a namespace declared in the scope of the parent
williamr@2
   549
         * copy those namespace declarations to this element.
williamr@2
   550
         * @return this Element. Ownership IS TRANSFERRED to the caller.
williamr@2
   551
         */ 
williamr@2
   552
        IMPORT_C virtual CSenElement* DetachL();
williamr@2
   553
williamr@2
   554
        /**
williamr@2
   555
         *  Gets a child element from a specified index.
williamr@2
   556
         *  @param  aIndex: the index what to get
williamr@2
   557
         *  @return child element from a current index. NULL if no child in given
williamr@2
   558
         *          index is found
williamr@2
   559
         */ 
williamr@2
   560
        IMPORT_C virtual CSenElement* Child(TInt aIndex);
williamr@2
   561
williamr@2
   562
        /**
williamr@2
   563
         * (Re-) Set the name and namespace of this Element. The element will be
williamr@2
   564
         * given the localName in the the given namespace. A prefix will be
williamr@2
   565
         * computed from the qualified name.
williamr@2
   566
         * This method should be used with care and is mainly intended for
williamr@2
   567
         * protected use in implementations.
williamr@2
   568
         * @param aNamespaceURI:    The new namespace URI.
williamr@2
   569
         * @param aLocalName:       The new local name.
williamr@2
   570
         * @param aQName:           The new qualified name.
williamr@2
   571
         */ 
williamr@2
   572
        IMPORT_C virtual void Set(const TDesC8& aNsUri, 
williamr@2
   573
                                  const TDesC8& aLocalName,
williamr@2
   574
                                    const TDesC8& aQName);
williamr@2
   575
williamr@2
   576
        /**
williamr@2
   577
         *  Adds new attributes to the element.
williamr@2
   578
         *  @param  aAttrs: the array of attributes.
williamr@2
   579
         */ 
williamr@2
   580
        IMPORT_C virtual void AddAttributesL(const RAttributeArray& apAttrs);
williamr@2
   581
williamr@2
   582
    protected:  
williamr@2
   583
    
williamr@2
   584
        /**
williamr@2
   585
         * C++ default constructor.
williamr@2
   586
         */
williamr@2
   587
        IMPORT_C CSenBaseElement();
williamr@2
   588
williamr@2
   589
        /**
williamr@2
   590
         * Following BaseConstructL methods should be called from the deriving
williamr@2
   591
         * classes ConstructL() methods. Parameter info is found in the
williamr@2
   592
         * corresponding NewL-methods.
williamr@2
   593
         */
williamr@2
   594
        IMPORT_C void BaseConstructL(   const TDesC8& aLocalName);
williamr@2
   595
        
williamr@2
   596
        IMPORT_C void BaseConstructL(   const TDesC8& aNsUri,
williamr@2
   597
                                        const TDesC8& aLocalName);
williamr@2
   598
        
williamr@2
   599
        IMPORT_C void BaseConstructL(   const TDesC8& aNsUri,
williamr@2
   600
                                        const TDesC8& aLocalName,
williamr@2
   601
                                        const TDesC8& aQName);
williamr@2
   602
williamr@2
   603
        IMPORT_C void BaseConstructL(   const TDesC8& aNsUri,
williamr@2
   604
                                        const TDesC8& aLocalName,
williamr@2
   605
                                        const TDesC8& aQName,
williamr@2
   606
                                        const RAttributeArray& apAttrs);
williamr@2
   607
williamr@2
   608
        IMPORT_C void BaseConstructL(   const TDesC8& aNsUri,
williamr@2
   609
                                        const TDesC8& aLocalName,
williamr@2
   610
                                        const TDesC8& aQName,
williamr@2
   611
                                        const RAttributeArray& apAttrs,
williamr@2
   612
                                        CSenElement& aParent);
williamr@2
   613
    
williamr@2
   614
        // New functions
williamr@2
   615
        
williamr@2
   616
        /**
williamr@2
   617
         * Method for finding an attribute with given name.
williamr@2
   618
         * @param aName a name of the attribute to be searched for
williamr@2
   619
         * @return the 1st attribute with the name, or NULL. 
williamr@2
   620
         *              Ownership is not transferred.
williamr@2
   621
         */
williamr@2
   622
        IMPORT_C virtual CSenBaseAttribute* FindAttr(const TDesC8& aName);
williamr@2
   623
williamr@2
   624
        /**
williamr@2
   625
         * Method for finding index for a wanted element.
williamr@2
   626
         * @param aNsUri        a namespace URI which needs to match
williamr@2
   627
         * @param aLocalName    a local name which needs to match
williamr@2
   628
         * @return Index of the element with given characteristics.
williamr@2
   629
         *          or KErrNotFound if none matching
williamr@2
   630
         */
williamr@2
   631
        IMPORT_C virtual TInt IndexOfElement(const TDesC8& aNsUri,
williamr@2
   632
                                             const TDesC8& aLocalName) const;
williamr@2
   633
        
williamr@2
   634
        /**
williamr@2
   635
         * Writes element's attributes into a writestream.
williamr@2
   636
         * @param aWriteStream  writestream to write into
williamr@2
   637
         */
williamr@2
   638
        IMPORT_C virtual void WriteAttrsToL(RWriteStream& aWriteStream);
williamr@2
   639
williamr@2
   640
        /**
williamr@2
   641
         * Helper function to write an attribute into a writestream.
williamr@2
   642
         * @param aWriteStream  writestream to write into
williamr@2
   643
         * @param aName attribute name
williamr@2
   644
         * @param aValue    attribute value
williamr@2
   645
         */
williamr@2
   646
        IMPORT_C virtual void WriteAttrToL(RWriteStream& aWriteStream,
williamr@2
   647
                                           const TDesC8& aName,
williamr@2
   648
                                           const TDesC8& aValue);
williamr@2
   649
williamr@2
   650
        /**
williamr@2
   651
         * Writes all internal elements into a writestream.
williamr@2
   652
         * @param aWriteStream  writestream to write into
williamr@2
   653
         */
williamr@2
   654
        IMPORT_C virtual void WriteElementsToL(RWriteStream& aWriteStream);
williamr@2
   655
williamr@2
   656
        /**
williamr@2
   657
         * Writes all element's content into a writestream.
williamr@2
   658
         * @param aWriteStream  writestream to write into
williamr@2
   659
         */
williamr@2
   660
        IMPORT_C virtual void WriteContentToL(RWriteStream& aWriteStream);
williamr@2
   661
williamr@2
   662
        /**
williamr@2
   663
        * Adds an attribute into this element. Used also adding new namespaces
williamr@2
   664
        * into the element.
williamr@2
   665
        * @param aQName     Attribute's qualified name
williamr@2
   666
        * @param aLocalName Attribute's local name
williamr@2
   667
        * @param aValue     Attribute's value
williamr@2
   668
        * @return value of the attribute as string (TDesC&)
williamr@2
   669
        * Leave codes:  
williamr@2
   670
        *       KErrSenInvalidCharacters if aLocalName or aQName contain illegal 
williamr@2
   671
        *       characters.     
williamr@2
   672
        *       KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
williamr@2
   673
        */
williamr@2
   674
        IMPORT_C virtual const TDesC8& AddAttributeL(const TDesC8& aQName,
williamr@2
   675
                                                     const TDesC8& aLocalName,
williamr@2
   676
                                                     const TDesC8& aValue);
williamr@2
   677
williamr@2
   678
        /**
williamr@2
   679
        * Adds an attribute into this element. Used also adding new namespaces
williamr@2
   680
        * into the element.
williamr@2
   681
        * @param aLocalName Attribute's local name
williamr@2
   682
        * @param aValue     Attribute's value
williamr@2
   683
        * @return value of the attribute as string (TDesC&)
williamr@2
   684
        * Leave codes:  
williamr@2
   685
        *       KErrSenInvalidCharacters if aLocalName contains illegal characters.     
williamr@2
   686
        *       KErrSenZeroLengthDescriptor if aAttrName is zero length, or
williamr@2
   687
        *       if the local name part of it is zero length.
williamr@2
   688
        */
williamr@2
   689
        IMPORT_C virtual const TDesC8& AddAttributeL(const TDesC8& aAttrName,
williamr@2
   690
                                                     const TDesC8& aValue);
williamr@2
   691
williamr@2
   692
        /** 
williamr@2
   693
        * Adds an attribute into this element.
williamr@2
   694
        * @param apAttribute    Attribute to be added. Ownership is transferred
williamr@2
   695
        *                       to this element.
williamr@2
   696
        * @return attribute value as a string (TDesC8&)
williamr@2
   697
        */
williamr@2
   698
        IMPORT_C const TDesC8& AddAttributeL(CSenBaseAttribute* apAttribute);
williamr@2
   699
williamr@2
   700
        /**
williamr@2
   701
        *   Allocates a new buffer for saving content, if none allocated yet.
williamr@2
   702
        */
williamr@2
   703
        IMPORT_C virtual void AllocContentBufL();
williamr@2
   704
        
williamr@2
   705
        /**
williamr@2
   706
        * Writes element into a dynamic buffer.
williamr@2
   707
        * @param aBuf   a dynamic buffer where to append everything.
williamr@2
   708
        * @return the modified buffer as TPtrC8.
williamr@2
   709
        */
williamr@2
   710
        IMPORT_C virtual TPtrC8 WriteToBufL(CBufBase& aBuf);
williamr@2
   711
williamr@2
   712
    private: // New functions
williamr@2
   713
            
williamr@2
   714
        void AddNamespaceMissingFromL(RPointerArray<CSenNamespace>& aNamespaces);
williamr@2
   715
williamr@2
   716
    private: // Data
williamr@2
   717
        HBufC8* ipLocalName; // Owned
williamr@2
   718
        HBufC8* iNotUsed;   // Not used (kept for binary compatibility)
williamr@2
   719
        CBufFlat* ipContentBuf; // Owned
williamr@2
   720
        RBufWriteStream iContentWriteStream;
williamr@2
   721
        RPointerArray<CSenBaseAttribute> iAttrs;    // Elements owned
williamr@2
   722
        RPointerArray<CSenElement> iElements;       // Elements owned
williamr@2
   723
        RPointerArray<CSenNamespace> iNamespaces;   // Elements owned
williamr@2
   724
        CSenElement*    ipParent;                   // Not owned
williamr@2
   725
        CSenNamespace*  ipNamespace;                // Not Owned (deleted in upper level array)
williamr@2
   726
    };
williamr@2
   727
williamr@2
   728
#endif // SEN_BASE_ELEMENT_H
williamr@2
   729
williamr@2
   730
// End of File
williamr@2
   731