idlehomescreen/xmluirendering/dom/src/xndomattribute.cpp
changeset 2 08c6ee43b396
parent 0 f72a12da539e
equal deleted inserted replaced
1:5315654608de 2:08c6ee43b396
    26 // CXnDomAttribute::CXnDomAttribute
    26 // CXnDomAttribute::CXnDomAttribute
    27 // C++ default constructor can NOT contain any code, that
    27 // C++ default constructor can NOT contain any code, that
    28 // might leave.
    28 // might leave.
    29 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    30 //
    30 //
    31 CXnDomAttribute::CXnDomAttribute( CXnDomStringPool& aStringPool ):
    31 CXnDomAttribute::CXnDomAttribute( CXnDomStringPool* aStringPool ):
    32     iStringPool( aStringPool ),
    32     iStringPool( aStringPool ),
    33     iNameRef( KErrNotFound ),
    33     iNameRef( KErrNotFound ),
    34     iValueRef( KErrNotFound )
    34     iValueRef( KErrNotFound )
    35     {
    35     {
    36     }
    36     }
    41 // Symbian 2nd phase constructor can leave.
    41 // Symbian 2nd phase constructor can leave.
    42 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    43 //
    43 //
    44 void CXnDomAttribute::ConstructL( const TDesC8& aName )
    44 void CXnDomAttribute::ConstructL( const TDesC8& aName )
    45     {
    45     {
    46     iNameRef = iStringPool.AddStringL( aName );
    46     iNameRef = iStringPool->AddStringL( aName );
    47     }
    47     }
    48 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    49 // CXnDomAttribute::NewL
    49 // CXnDomAttribute::NewL
    50 // Two-phased constructor.
    50 // Two-phased constructor.
    51 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    52 //
    52 //
    53 EXPORT_C CXnDomAttribute* CXnDomAttribute::NewL( 
    53 EXPORT_C CXnDomAttribute* CXnDomAttribute::NewL( 
    54     const TDesC8& aName,
    54     const TDesC8& aName,
    55     CXnDomStringPool& aStringPool )
    55     CXnDomStringPool* aStringPool )
    56     {
    56     {
    57     CXnDomAttribute* self = new( ELeave ) CXnDomAttribute( aStringPool );
    57     CXnDomAttribute* self = new( ELeave ) CXnDomAttribute( aStringPool );
    58     
    58     
    59     CleanupStack::PushL( self );
    59     CleanupStack::PushL( self );
    60     self->ConstructL( aName );
    60     self->ConstructL( aName );
    69 // Two-phased stream constructor.
    69 // Two-phased stream constructor.
    70 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    71 //
    71 //
    72 CXnDomAttribute* CXnDomAttribute::NewL( 
    72 CXnDomAttribute* CXnDomAttribute::NewL( 
    73     RReadStream& aStream, 
    73     RReadStream& aStream, 
    74     CXnDomStringPool& aStringPool )
    74     CXnDomStringPool* aStringPool )
    75     {
    75     {
    76     CXnDomAttribute* self = new( ELeave ) CXnDomAttribute( aStringPool );
    76     CXnDomAttribute* self = new( ELeave ) CXnDomAttribute( aStringPool );
    77     CleanupStack::PushL( self );
    77     CleanupStack::PushL( self );
    78     aStream >> *self;
    78     aStream >> *self;
    79     CleanupStack::Pop( self );
    79     CleanupStack::Pop( self );
   106 // CXnDomAttribute::CloneL
   106 // CXnDomAttribute::CloneL
   107 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   108 //
   108 //
   109 CXnDomAttribute* CXnDomAttribute::CloneL( CXnDomStringPool& aStringPool )
   109 CXnDomAttribute* CXnDomAttribute::CloneL( CXnDomStringPool& aStringPool )
   110     {
   110     {
   111     const TDesC8& name = iStringPool.String( iNameRef );
   111     const TDesC8& name = iStringPool->String( iNameRef );
   112     
   112     
   113     CXnDomAttribute* clone = CXnDomAttribute::NewL( name, aStringPool );
   113     CXnDomAttribute* clone = CXnDomAttribute::NewL( name, &aStringPool );
   114     CleanupStack::PushL( clone );
   114     CleanupStack::PushL( clone );
   115     if ( iValueRef > KErrNotFound )
   115     if ( iValueRef > KErrNotFound )
   116         {
   116         {
   117         const TDesC8& value = iStringPool.String( iValueRef );
   117         const TDesC8& value = iStringPool->String( iValueRef );
   118         clone->SetValueL( value );
   118         clone->SetValueL( value );
   119         }
   119         }
   120     CleanupStack::Pop( clone );    
   120     CleanupStack::Pop( clone );    
   121     return clone;
   121     return clone;
   122     
   122     
   126 // CXnDomAttribute::Name
   126 // CXnDomAttribute::Name
   127 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   128 //
   128 //
   129 EXPORT_C const TDesC8& CXnDomAttribute::Name()
   129 EXPORT_C const TDesC8& CXnDomAttribute::Name()
   130     {
   130     {
   131     return iStringPool.String( iNameRef );
   131     return iStringPool->String( iNameRef );
   132     }
   132     }
   133     
   133     
   134 // -----------------------------------------------------------------------------
   134 // -----------------------------------------------------------------------------
   135 // CXnDomProperty::NameStringPoolIndex
   135 // CXnDomProperty::NameStringPoolIndex
   136 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   145 //
   145 //
   146 EXPORT_C const TDesC8& CXnDomAttribute::Value()
   146 EXPORT_C const TDesC8& CXnDomAttribute::Value()
   147     {
   147     {
   148     if ( iValueRef > KErrNotFound )
   148     if ( iValueRef > KErrNotFound )
   149         {
   149         {
   150         return iStringPool.String( iValueRef );
   150         return iStringPool->String( iValueRef );
   151         }
   151         }
   152     return KNullDesC8;
   152     return KNullDesC8;
   153     }
   153     }
   154     
   154     
   155 // -----------------------------------------------------------------------------
   155 // -----------------------------------------------------------------------------
   158 //        
   158 //        
   159 EXPORT_C TInt16 CXnDomAttribute::ValueStringPoolIndex()const
   159 EXPORT_C TInt16 CXnDomAttribute::ValueStringPoolIndex()const
   160     {
   160     {
   161     return iValueRef;    
   161     return iValueRef;    
   162     }    
   162     }    
       
   163 
   163 // -----------------------------------------------------------------------------
   164 // -----------------------------------------------------------------------------
   164 // CXnDomAttribute::SetValueL
   165 // CXnDomAttribute::SetValueL
   165 // -----------------------------------------------------------------------------
   166 // -----------------------------------------------------------------------------
   166 //
   167 //
   167 EXPORT_C void CXnDomAttribute::SetValueL( const TDesC8& aValue )
   168 EXPORT_C void CXnDomAttribute::SetValueL( const TDesC8& aValue )
   168     {
   169     {
   169     iValueRef = iStringPool.AddStringL( aValue );
   170     iValueRef = iStringPool->AddStringL( aValue );
   170     }
   171     }
   171 
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CXnDomAttribute::SwapStringPoolL
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C void CXnDomAttribute::SwapStringPoolL( CXnDomStringPool* aStringPool )
       
   178     {
       
   179     if( !aStringPool )
       
   180         {
       
   181         User::Leave( KErrArgument );
       
   182         }
       
   183     
       
   184     iNameRef = aStringPool->AddStringL( iStringPool->String( iNameRef ) );
       
   185     iValueRef = aStringPool->AddStringL( iStringPool->String( iValueRef ) );
       
   186     
       
   187     iStringPool = aStringPool;
       
   188     }
   172    
   189    
   173 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   174 // CXnDomAttribute::Size
   191 // CXnDomAttribute::Size
   175 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   176 //
   193 //
   199 // CXnDomAttribute::InternalizeL
   216 // CXnDomAttribute::InternalizeL
   200 // -----------------------------------------------------------------------------
   217 // -----------------------------------------------------------------------------
   201 //
   218 //
   202 void CXnDomAttribute::InternalizeL( RReadStream& aStream )
   219 void CXnDomAttribute::InternalizeL( RReadStream& aStream )
   203     {
   220     {
   204     iNameRef = aStream.ReadInt16L() + iStringPool.Offset();
   221     iNameRef = aStream.ReadInt16L();
   205     iValueRef = aStream.ReadInt16L()  + iStringPool.Offset();
   222     iValueRef = aStream.ReadInt16L();
   206     }
   223     }
   207 //  End of File  
   224 //  End of File