homescreenpluginsrv/hspsdom/src/hspsdomnode.cpp
branchRCL_3
changeset 19 502e5d91ad42
parent 9 d0529222e3f0
equal deleted inserted replaced
18:bd874ee5e5e2 19:502e5d91ad42
    52     const TDesC8& aName,
    52     const TDesC8& aName,
    53     const TDesC8& aNS )
    53     const TDesC8& aNS )
    54     {
    54     {
    55     iNameRef = iStringPool.AddStringL( aName );
    55     iNameRef = iStringPool.AddStringL( aName );
    56     iNSRef = iStringPool.AddStringL( aNS );
    56     iNSRef = iStringPool.AddStringL( aNS );
    57     
    57     Construct2L();
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // ChspsDomNode::ConstructL
       
    62 // Symbian 2nd phase constructor can leave.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void ChspsDomNode::ConstructL(
       
    66     const TInt aName,
       
    67     const TInt aNS )
       
    68     {
       
    69     iNameRef = aName;
       
    70     iNSRef = aNS;
       
    71     Construct2L();
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // ChspsDomNode::Construct2L 
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void ChspsDomNode::Construct2L()
       
    79     {
    58     iChildList = ChspsDomList::NewL( ChspsDomList::ENodeList, iStringPool );
    80     iChildList = ChspsDomList::NewL( ChspsDomList::ENodeList, iStringPool );
    59     iAttributeList = ChspsDomList::NewL( ChspsDomList::EAttributeList, iStringPool );
    81     iAttributeList = ChspsDomList::NewL( ChspsDomList::EAttributeList, iStringPool );
    60     }
    82     }
    61 
    83 
    62 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    78     return self;
   100     return self;
    79     }
   101     }
    80 
   102 
    81 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
    82 // ChspsDomNode::NewL
   104 // ChspsDomNode::NewL
       
   105 // Two-phased constructor.
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 ChspsDomNode* ChspsDomNode::NewL(
       
   109     const TInt aName,
       
   110     const TInt aNS, 
       
   111     ChspsDomStringPool& aStringPool )
       
   112     {
       
   113     ChspsDomNode* self = new( ELeave ) ChspsDomNode( aStringPool );
       
   114     
       
   115     CleanupStack::PushL( self );
       
   116     self->ConstructL( aName, aNS );
       
   117     CleanupStack::Pop( self );
       
   118 
       
   119     return self;
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // ChspsDomNode::NewL
    83 // Two-phased stream constructor.
   124 // Two-phased stream constructor.
    84 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
    85 //
   126 //
    86 ChspsDomNode* ChspsDomNode::NewL( RReadStream& aStream, ChspsDomStringPool& aStringPool )
   127 ChspsDomNode* ChspsDomNode::NewL( RReadStream& aStream, ChspsDomStringPool& aStringPool )
    87     {
   128     {
   107 // -----------------------------------------------------------------------------
   148 // -----------------------------------------------------------------------------
   108 // ChspsDomNode::CloneL
   149 // ChspsDomNode::CloneL
   109 // Clones this node and it's child nodes. This is a recursive function.
   150 // Clones this node and it's child nodes. This is a recursive function.
   110 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   111 //
   152 //
   112 EXPORT_C ChspsDomNode* ChspsDomNode::CloneL( ChspsDomStringPool& aStringPool )
   153 EXPORT_C ChspsDomNode* ChspsDomNode::CloneL( ChspsDomStringPool& aStringPool,
   113     {
   154                                              const TBool aFastClone )
   114     const TDesC8& name = iStringPool.String( iNameRef );
   155     {
   115     const TDesC8& ns = iStringPool.String( iNSRef );
   156     ChspsDomNode* clone = NULL;
   116     
   157     
   117     ChspsDomNode*  clone = ChspsDomNode::NewL( name, ns, aStringPool );
   158     if( aFastClone )
       
   159         {
       
   160         clone = ChspsDomNode::NewL( iNameRef, iNSRef, aStringPool );
       
   161         }
       
   162     else
       
   163         {
       
   164         const TDesC8& name = iStringPool.String( iNameRef );
       
   165         const TDesC8& ns = iStringPool.String( iNSRef );        
       
   166         clone = ChspsDomNode::NewL( name, ns, aStringPool );
       
   167         }
       
   168 
   118     CleanupStack::PushL( clone );
   169     CleanupStack::PushL( clone );
       
   170 
   119     if ( iPCData )
   171     if ( iPCData )
   120         {
   172         {
   121         clone->AppendPCDataL( *iPCData );
   173         clone->AppendPCDataL( *iPCData );
   122         }
   174         }
       
   175     
   123     clone->iNodeId = iNodeId;
   176     clone->iNodeId = iNodeId;
   124     clone->iRefNode = iRefNode;
   177     clone->iRefNode = iRefNode;
   125     
   178     
   126     TInt childCount( iChildList->Length() );
   179     TInt childCount( iChildList->Length() );
   127    
   180    
   128     for ( TInt i=0; i<childCount; i++ )
   181     for( TInt i = 0; i < childCount; i++ )
   129         {
   182         {
   130         ChspsDomNode* childClone = 
   183         ChspsDomNode* childClone = 
   131             static_cast<ChspsDomNode*>( iChildList->Item(i) )->CloneL( aStringPool );
   184             static_cast<ChspsDomNode*>( iChildList->Item(i) )->CloneL( aStringPool, aFastClone );
   132         CleanupStack::PushL( childClone );
   185         CleanupStack::PushL( childClone );
   133         childClone->iParentNode = clone;
   186         childClone->iParentNode = clone;
   134         clone->iChildList->AddItemL( childClone );
   187         clone->iChildList->AddItemL( childClone );
   135         CleanupStack::Pop( childClone );
   188         CleanupStack::Pop( childClone );
   136         }
   189         }
   137     
   190     
   138     TInt attrCount( iAttributeList->Length() );
   191     TInt attrCount( iAttributeList->Length() );
   139     for ( TInt j=0; j<attrCount; j++ )
   192     for( TInt j = 0; j < attrCount; j++ )
   140         {
   193         {
   141         ChspsDomAttribute* attrClone = 
   194         ChspsDomAttribute* attrClone = 
   142             static_cast<ChspsDomAttribute*>( iAttributeList->Item(j) )->CloneL( aStringPool );
   195             static_cast<ChspsDomAttribute*>( iAttributeList->Item(j) )->CloneL( aStringPool, aFastClone );
   143         CleanupStack::PushL( attrClone );
   196         CleanupStack::PushL( attrClone );
   144         clone->iAttributeList->AddItemL( attrClone );
   197         clone->iAttributeList->AddItemL( attrClone );
   145         CleanupStack::Pop( attrClone );
   198         CleanupStack::Pop( attrClone );
   146         }
   199         }
   147     CleanupStack::Pop( clone );
   200     CleanupStack::Pop( clone );
   488 // -----------------------------------------------------------------------------
   541 // -----------------------------------------------------------------------------
   489 // ChspsDomNode::ExternalizeL
   542 // ChspsDomNode::ExternalizeL
   490 // -----------------------------------------------------------------------------
   543 // -----------------------------------------------------------------------------
   491 //
   544 //
   492 void ChspsDomNode::ExternalizeL( RWriteStream& aStream ) const
   545 void ChspsDomNode::ExternalizeL( RWriteStream& aStream ) const
   493     {
   546     {    
   494     
       
   495     aStream.WriteInt16L( iNameRef );
   547     aStream.WriteInt16L( iNameRef );
   496     aStream.WriteInt16L( iNSRef );
   548     aStream.WriteInt16L( iNSRef );
   497     aStream.WriteInt8L( iRefNode );
   549     aStream.WriteInt8L( iRefNode );
   498     
   550     
   499     if ( iPCData )
   551     if ( iPCData )