phonebookui/Phonebook2/Presentation/src/CPbk2LocalizedText.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Phonebook 2 Localized text.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPbk2LocalizedText.h"
       
    20 
       
    21 /// SYSTEM INCLUDES
       
    22 #include <barsread.h> // TResourceReader
       
    23 
       
    24 namespace{
       
    25     
       
    26 #ifdef _DEBUG
       
    27 namespace {
       
    28 
       
    29     enum TPanic
       
    30         {
       
    31         EPanic_PreCond_Text = 1
       
    32         };
       
    33         
       
    34     void Panic( TPanic aPanicCode )
       
    35         {
       
    36         _LIT( KPanicCat, "CPbk2LocalizedText" );
       
    37         User::Panic( KPanicCat, aPanicCode );
       
    38         }
       
    39 }
       
    40 #endif // _DEBUG    
       
    41 
       
    42 } // namespace
       
    43 
       
    44 
       
    45 // --------------------------------------------------------------------------
       
    46 // CPbk2LocalizedText::CPbk2LocalizedText
       
    47 // --------------------------------------------------------------------------
       
    48 //
       
    49 CPbk2LocalizedText::CPbk2LocalizedText()
       
    50     {
       
    51     // Do nothing    
       
    52     }
       
    53     
       
    54 // --------------------------------------------------------------------------
       
    55 // CPbk2LocalizedText::CPbk2LocalizedText
       
    56 // --------------------------------------------------------------------------
       
    57 //
       
    58 CPbk2LocalizedText::CPbk2LocalizedText( 
       
    59         TInt aUid, 
       
    60         HBufC* aText ) : 
       
    61     iContextUid( aUid ), 
       
    62     iText( aText )
       
    63     {
       
    64     // Do nothing    
       
    65     }    
       
    66     
       
    67 // --------------------------------------------------------------------------
       
    68 // CPbk2LocalizedText::~CPbk2LocalizedText
       
    69 // --------------------------------------------------------------------------
       
    70 //
       
    71 CPbk2LocalizedText::~CPbk2LocalizedText()
       
    72     {
       
    73     delete iText;
       
    74     }
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 // CPbk2LocalizedText::NewL
       
    78 // --------------------------------------------------------------------------
       
    79 //
       
    80 CPbk2LocalizedText* CPbk2LocalizedText::NewL( TResourceReader& aReader )
       
    81     {
       
    82     CPbk2LocalizedText* self = new ( ELeave ) CPbk2LocalizedText();
       
    83     CleanupStack::PushL( self );
       
    84     self->ConstructL( aReader );
       
    85     CleanupStack::Pop( self );
       
    86     return self; 
       
    87     }
       
    88     
       
    89 // --------------------------------------------------------------------------
       
    90 // CPbk2LocalizedText::NewL
       
    91 // --------------------------------------------------------------------------
       
    92 //
       
    93 CPbk2LocalizedText* CPbk2LocalizedText::NewL(
       
    94         TInt aUid, 
       
    95         HBufC* aText )
       
    96     {
       
    97     CPbk2LocalizedText* self = 
       
    98         new ( ELeave ) CPbk2LocalizedText( aUid, aText );
       
    99     return self; 
       
   100     }    
       
   101 
       
   102 // --------------------------------------------------------------------------
       
   103 // CPbk2LocalizedText::ConstructL
       
   104 // --------------------------------------------------------------------------
       
   105 //
       
   106 void CPbk2LocalizedText::ConstructL( TResourceReader& aReader )
       
   107     {
       
   108     iContextUid = aReader.ReadInt16();
       
   109     iText = aReader.ReadHBufCL();
       
   110     }
       
   111 
       
   112 // --------------------------------------------------------------------------
       
   113 // CPbk2LocalizedText::ContextId
       
   114 // --------------------------------------------------------------------------
       
   115 //
       
   116 TInt CPbk2LocalizedText::ContextUid() const
       
   117     {
       
   118     return iContextUid;
       
   119     }
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // CPbk2LocalizedText::Text
       
   123 // --------------------------------------------------------------------------
       
   124 //
       
   125 const TDesC& CPbk2LocalizedText::Text() const
       
   126     {
       
   127     __ASSERT_DEBUG( iText, Panic( EPanic_PreCond_Text ));
       
   128     return *iText;
       
   129     }
       
   130 
       
   131 // End of file