idlehomescreen/xmluirendering/dom/src/xndomattribute.cpp
changeset 0 f72a12da539e
child 2 08c6ee43b396
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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:  Represent single xmluiml attribute
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "xndomattribute.h"
       
    22 #include    "xndomstringpool.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 // -----------------------------------------------------------------------------
       
    26 // CXnDomAttribute::CXnDomAttribute
       
    27 // C++ default constructor can NOT contain any code, that
       
    28 // might leave.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CXnDomAttribute::CXnDomAttribute( CXnDomStringPool& aStringPool ):
       
    32     iStringPool( aStringPool ),
       
    33     iNameRef( KErrNotFound ),
       
    34     iValueRef( KErrNotFound )
       
    35     {
       
    36     }
       
    37 
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CXnDomAttribute::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CXnDomAttribute::ConstructL( const TDesC8& aName )
       
    45     {
       
    46     iNameRef = iStringPool.AddStringL( aName );
       
    47     }
       
    48 // -----------------------------------------------------------------------------
       
    49 // CXnDomAttribute::NewL
       
    50 // Two-phased constructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CXnDomAttribute* CXnDomAttribute::NewL( 
       
    54     const TDesC8& aName,
       
    55     CXnDomStringPool& aStringPool )
       
    56     {
       
    57     CXnDomAttribute* self = new( ELeave ) CXnDomAttribute( aStringPool );
       
    58     
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL( aName );
       
    61     CleanupStack::Pop( self );
       
    62 
       
    63     return self;
       
    64     }    
       
    65 
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CXnDomAttribute::NewL
       
    69 // Two-phased stream constructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CXnDomAttribute* CXnDomAttribute::NewL( 
       
    73     RReadStream& aStream, 
       
    74     CXnDomStringPool& aStringPool )
       
    75     {
       
    76     CXnDomAttribute* self = new( ELeave ) CXnDomAttribute( aStringPool );
       
    77     CleanupStack::PushL( self );
       
    78     aStream >> *self;
       
    79     CleanupStack::Pop( self );
       
    80 
       
    81     return self;
       
    82     }    
       
    83     
       
    84 // -----------------------------------------------------------------------------
       
    85 // CXnDomAttribute::~CXnDomAttribute
       
    86 // Destructor
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C CXnDomAttribute::~CXnDomAttribute()
       
    90     {
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CXnDomAttribute::CloneL
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 EXPORT_C CXnDomAttribute* CXnDomAttribute::CloneL()
       
    98     {
       
    99     CXnDomAttribute* clone = new (ELeave)CXnDomAttribute( iStringPool );
       
   100     clone->iNameRef = iNameRef;
       
   101     clone->iValueRef = iValueRef;
       
   102     return clone;
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CXnDomAttribute::CloneL
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 CXnDomAttribute* CXnDomAttribute::CloneL( CXnDomStringPool& aStringPool )
       
   110     {
       
   111     const TDesC8& name = iStringPool.String( iNameRef );
       
   112     
       
   113     CXnDomAttribute* clone = CXnDomAttribute::NewL( name, aStringPool );
       
   114     CleanupStack::PushL( clone );
       
   115     if ( iValueRef > KErrNotFound )
       
   116         {
       
   117         const TDesC8& value = iStringPool.String( iValueRef );
       
   118         clone->SetValueL( value );
       
   119         }
       
   120     CleanupStack::Pop( clone );    
       
   121     return clone;
       
   122     
       
   123     }
       
   124     
       
   125 // -----------------------------------------------------------------------------
       
   126 // CXnDomAttribute::Name
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C const TDesC8& CXnDomAttribute::Name()
       
   130     {
       
   131     return iStringPool.String( iNameRef );
       
   132     }
       
   133     
       
   134 // -----------------------------------------------------------------------------
       
   135 // CXnDomProperty::NameStringPoolIndex
       
   136 // -----------------------------------------------------------------------------
       
   137 //        
       
   138 EXPORT_C TInt16 CXnDomAttribute::NameStringPoolIndex()const
       
   139     {
       
   140     return iNameRef;    
       
   141     }    
       
   142 // -----------------------------------------------------------------------------
       
   143 // CXnDomAttribute::Value
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C const TDesC8& CXnDomAttribute::Value()
       
   147     {
       
   148     if ( iValueRef > KErrNotFound )
       
   149         {
       
   150         return iStringPool.String( iValueRef );
       
   151         }
       
   152     return KNullDesC8;
       
   153     }
       
   154     
       
   155 // -----------------------------------------------------------------------------
       
   156 // CXnDomProperty::ValueStringPoolIndex
       
   157 // -----------------------------------------------------------------------------
       
   158 //        
       
   159 EXPORT_C TInt16 CXnDomAttribute::ValueStringPoolIndex()const
       
   160     {
       
   161     return iValueRef;    
       
   162     }    
       
   163 // -----------------------------------------------------------------------------
       
   164 // CXnDomAttribute::SetValueL
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CXnDomAttribute::SetValueL( const TDesC8& aValue )
       
   168     {
       
   169     iValueRef = iStringPool.AddStringL( aValue );
       
   170     }
       
   171 
       
   172    
       
   173 // -----------------------------------------------------------------------------
       
   174 // CXnDomAttribute::Size
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 TInt CXnDomAttribute::Size() const
       
   178     {
       
   179     TInt size( 0 );
       
   180     
       
   181     size += sizeof(TInt16); // iNameRef     
       
   182       
       
   183     size += sizeof(TInt16); // iValueRef
       
   184     
       
   185     return size;    
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CXnDomAttribute::ExternalizeL
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 void CXnDomAttribute::ExternalizeL( RWriteStream& aStream ) const
       
   193     {
       
   194     aStream.WriteInt16L( iNameRef );
       
   195     aStream.WriteInt16L( iValueRef );
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CXnDomAttribute::InternalizeL
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 void CXnDomAttribute::InternalizeL( RReadStream& aStream )
       
   203     {
       
   204     iNameRef = aStream.ReadInt16L() + iStringPool.Offset();
       
   205     iValueRef = aStream.ReadInt16L()  + iStringPool.Offset();
       
   206     }
       
   207 //  End of File