idlehomescreen/inc/xndomnode.h
branchRCL_3
changeset 34 5456b4e8b3a8
equal deleted inserted replaced
33:5f0182e07bfb 34:5456b4e8b3a8
       
     1 /*
       
     2 * Copyright (c) 2005,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:  Primary datatype for the entire Document Object Model.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef XN_DOM_NODE_H
       
    21 #define XN_DOM_NODE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <s32strm.h>
       
    26 #include "mxndomlistitem.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 enum TContentType
       
    30     {
       
    31     EEmpty = 0,
       
    32     EAny,
       
    33     EPCData
       
    34     };
       
    35 
       
    36 class CXnDomList;
       
    37 class CXnDomStringPool;
       
    38 class CXnNode;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  @ingroup group_domdocument
       
    44 *  Class represents a single node in the document tree.
       
    45 *
       
    46 *  @lib xndomdocument.lib
       
    47 *  @since Series 60 3.1
       
    48 */
       
    49 class CXnDomNode : public CBase, public MXnDomListItem
       
    50     {
       
    51 
       
    52     public:  // Constructors and destructor
       
    53         
       
    54         /**
       
    55         * Two-phased constructor.
       
    56         */
       
    57         static CXnDomNode* NewL( 
       
    58             const TDesC8& aName, 
       
    59             const TDesC8& aNS,
       
    60             CXnDomStringPool* aStringPool );
       
    61               
       
    62         /**
       
    63         * Two-phased stream constructor.
       
    64         */
       
    65         static CXnDomNode* NewL( RReadStream& aStream, CXnDomStringPool* aStringPool );
       
    66         
       
    67         /**
       
    68         * Destructor.
       
    69         */
       
    70         virtual ~CXnDomNode();
       
    71       
       
    72     public: // New functions       
       
    73         /**
       
    74         * Makes a clone from this node and it's child nodes.
       
    75         * @since Series 60 3.1
       
    76         * @param aStringPool. A new string pool.
       
    77         * @return Pointer to a clone node. Caller has the ownership.
       
    78         */
       
    79         IMPORT_C CXnDomNode* CloneL( CXnDomStringPool& aStringPool );
       
    80         
       
    81         /**
       
    82         * Get the namespace of this node. 
       
    83         * @since Series 60 3.1
       
    84         * @return Pointer to the namespace buffer
       
    85         */
       
    86         IMPORT_C const TDesC8& Namespace();
       
    87         
       
    88         /**
       
    89         * Node's attributes exist in a list.
       
    90         * @since Series 60 3.1
       
    91         * @return Reference to a attribute list. 
       
    92         */
       
    93         IMPORT_C CXnDomList& AttributeList()const;
       
    94                 
       
    95         /**
       
    96         * Node's properties exist in a list.
       
    97         * @since Series 60 3.1
       
    98         * @return Reference to a property list. 
       
    99         */
       
   100         IMPORT_C CXnDomList& PropertyList();
       
   101         
       
   102         /**
       
   103         * Node need to know it's parent.
       
   104         * @since Series 60 3.1
       
   105         * @param aParent Pointer to this node parent
       
   106         */
       
   107         IMPORT_C void SetParent( CXnDomNode* aParent );
       
   108         
       
   109         /**
       
   110         * Node's parent is enquered e.g to traverse the document.
       
   111         * @since Series 60 3.1
       
   112         * @return Pointer to a parent node
       
   113         */
       
   114         IMPORT_C CXnDomNode* Parent() const;
       
   115         
       
   116         /**
       
   117         * Node id is for a uiengine use.
       
   118         * @since Series 60 3.1
       
   119         * @param aNodeId Unique identifier
       
   120         */
       
   121         IMPORT_C void SetNodeId( const TInt aNodeId );
       
   122 
       
   123         /**
       
   124         * Get the node unique identifier.
       
   125         * @since Series 60 3.1
       
   126         * @return Node unique identifier
       
   127         */
       
   128         IMPORT_C TInt NodeId() const;
       
   129 
       
   130         /**
       
   131         * Get the node unique identifier.
       
   132         * @since Series 60 3.1
       
   133         * @return Node unique identifier
       
   134         */
       
   135         IMPORT_C TInt ItemIndex( const MXnDomListItem& aItem )const;
       
   136 
       
   137         /**
       
   138         * Access to child nodes.
       
   139         * @since Series 60 3.1
       
   140         * @return Pointer to a list of child nodes
       
   141         */
       
   142         IMPORT_C CXnDomList& ChildNodes();
       
   143         
       
   144         /**
       
   145         * Child nodes of this node are needed to be able to 
       
   146         * traverse the document.
       
   147         * @since Series 60 3.1
       
   148         * @param aNode Node owns it's childs
       
   149         */
       
   150         IMPORT_C void AddChildL( CXnDomNode* aNode );
       
   151 
       
   152          /**
       
   153         * Child nodes of this node are needed to be able to 
       
   154         * traverse the document.
       
   155         * @since Series 60 3.1
       
   156         * @param aNode Node owns it's childs
       
   157         * @param aIndex Index in list where the node is added
       
   158         */
       
   159         IMPORT_C void AddChildL( CXnDomNode* aNode, TInt aIndex );
       
   160        
       
   161         /**
       
   162         * Removes node from the child list and frees memory allocated  
       
   163         * for a child node and it descendants.
       
   164         * @since Series 60 3.1
       
   165         * @param aNode Node to be released
       
   166         */
       
   167         IMPORT_C void DeleteChild( CXnDomNode* aNode );
       
   168         
       
   169         /**
       
   170         * Replaces a child node with the other node. Memory allocated for 
       
   171         * the node is freed.   
       
   172         * @since Series 60 3.1
       
   173         * @param aNode Node to be replaced
       
   174         * @param aNewNode New node
       
   175         */
       
   176         IMPORT_C void ReplaceChildL( CXnDomNode* aNode, CXnDomNode* aNewNode );
       
   177         
       
   178         /**
       
   179         * Get the character data
       
   180         * @since Series 60 3.1
       
   181         * @return Reference to a buffer
       
   182         */
       
   183         IMPORT_C const TDesC8& PCData();
       
   184         
       
   185         /**
       
   186         * Append PCData into node. Thus it is possible to have
       
   187         * "<root>a <first/> c <second/> e </root>" PCData.
       
   188         * @since Series 60 3.1
       
   189         * @param aPCData UTF-8 encoded parsed character data
       
   190         */
       
   191         IMPORT_C void AppendPCDataL( const TDesC8& aPCData );
       
   192         
       
   193         /**
       
   194         * Set parsed character data.
       
   195         * @since Series 60 3.1
       
   196         * @param aPCData UTF-8 encoded parsed character data
       
   197         */
       
   198         IMPORT_C void SetPCDataL( const TDesC8& aPCData );
       
   199         
       
   200         /**
       
   201         * Set content type
       
   202         * @since Series 60 3.1
       
   203         * @return content type
       
   204         */
       
   205         IMPORT_C const TContentType& ContentType();
       
   206         
       
   207         /**
       
   208         * Get content type
       
   209         * @since Series 60 3.1
       
   210         * @param aContentType content type
       
   211         */
       
   212         IMPORT_C void SetContentType( const TContentType& aContentType );
       
   213         
       
   214         /**
       
   215         * Recursive function to count all child nodes belonging
       
   216         * to this node. 
       
   217         * @since Series 60 3.1
       
   218         * @return This node and it's all childs count
       
   219         */
       
   220         IMPORT_C TInt DescendantCount() const;
       
   221         
       
   222         /**
       
   223         * Get pointer to the dom's string pool.
       
   224         * @since Series 60 3.1
       
   225         * @return Reference to string pool
       
   226         */
       
   227         IMPORT_C CXnDomStringPool* StringPool() const;
       
   228         
       
   229         /**
       
   230         * Deletes attributes when they are not needed anymore.
       
   231         * I.e. UIEngine has copied them into property list.
       
   232         * @since Series 60 3.1
       
   233         */
       
   234         IMPORT_C void DeleteAttributeList();
       
   235         
       
   236         /**
       
   237         * Returns value of given attribute
       
   238         * @param aAttribute Name of the attribute
       
   239         * @since S60 3.1
       
   240         * @return Value of an attribute
       
   241         */
       
   242         IMPORT_C const TDesC8& AttributeValue(const TDesC8& aAttribute) const;
       
   243    
       
   244    public: //From MXnDomListItem
       
   245         
       
   246         
       
   247         /**
       
   248         * Documented in CXnDomListItem::Size
       
   249         */
       
   250         TInt Size() const;
       
   251         
       
   252         /**
       
   253         * Documented in CXnDomListItem::ExternalizeL
       
   254         * NOTE: This function is not implemented yet!
       
   255         */
       
   256         void ExternalizeL( RWriteStream& aStream ) const;
       
   257         
       
   258         /**
       
   259         * Documented in CXnDomListItem::InternalizeL
       
   260         */
       
   261         void InternalizeL( RReadStream& aStream );
       
   262         
       
   263         /**
       
   264         * Documented in CXnDomListItem::Name
       
   265         */
       
   266         IMPORT_C const TDesC8& Name();        
       
   267     
       
   268     public:          
       
   269     
       
   270         /**
       
   271         * Sets pointer to associated layout node
       
   272         * @since S60 3.1
       
   273         * @param aNode Pointer to associated layout node
       
   274         */
       
   275         IMPORT_C void SetLayoutNode(CXnNode* aNode);
       
   276         
       
   277         /**
       
   278         * Returns pointer to associated layout node
       
   279         * @since S60 3.1
       
   280         * @return Pointer to associated layout node
       
   281         */
       
   282         IMPORT_C CXnNode* LayoutNode();
       
   283         
       
   284         /**
       
   285         * Set the namespace for this node. 
       
   286         * @since Series 60 3.1
       
   287         * @param aNS New namespace
       
   288         */
       
   289         IMPORT_C void SetNamespaceL(const TDesC8& aNS);
       
   290         
       
   291         /**
       
   292         * Set ownership of node and its children
       
   293         * @since Series 60 5.1
       
   294         * @param aNS. A new namespace.
       
   295         * @return void
       
   296         */
       
   297         IMPORT_C void SetOwnershipL( const TDesC8& aNS );        
       
   298 
       
   299         /**
       
   300          * Swap used string pool.
       
   301          * 
       
   302          * @param aStringPool   New string pool to be used.
       
   303          *                      Ownership not transferred!
       
   304          */
       
   305         IMPORT_C void SwapStringPoolL( CXnDomStringPool* aStringPool );
       
   306         
       
   307     private:
       
   308         /**
       
   309         * C++ default constructor.
       
   310         */
       
   311         CXnDomNode( CXnDomStringPool* aStringPool );
       
   312         
       
   313         /**
       
   314         * By default Symbian 2nd phase constructor is private.
       
   315         */
       
   316         void ConstructL( const TDesC8& aName, const TDesC8& aNS );
       
   317         
       
   318     private:    // Data
       
   319         
       
   320         //iNameRef refers to a name string in a string pool 
       
   321         TInt                iNameRef;
       
   322         
       
   323         //iNSRef refers to a namespace string in a string pool 
       
   324         TInt                iNSRef;
       
   325         
       
   326         //iStringPool is used to resolve strings based on references
       
   327         CXnDomStringPool*   iStringPool;
       
   328         
       
   329         //Type of the elements content
       
   330         TContentType        iContentType;
       
   331         
       
   332         //Parsed character data
       
   333         HBufC8*             iPCData;
       
   334         
       
   335         //Node's parent pointer 
       
   336         CXnDomNode*         iParentNode;
       
   337         
       
   338         //Node unique identifier
       
   339         TInt                iNodeId;
       
   340         
       
   341         //Node's childs are collected into a list. Childs are owned by node
       
   342         CXnDomList*         iChildList;
       
   343         
       
   344         //Node is the owner of the attributes
       
   345         CXnDomList*         iAttributeList;
       
   346         
       
   347         //Node is the owner of the properties
       
   348         CXnDomList*         iPropertyList;
       
   349         
       
   350         // Not owned
       
   351         CXnNode*            iLayoutNode;
       
   352     };
       
   353 
       
   354 #endif      // XN_DOM_NODE_H 
       
   355             
       
   356 // End of File