1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/tulstringresourcereader.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,76 @@
1.4 +/*
1.5 +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#ifndef TULSTRINGRESOURCEREADER_H
1.24 +#define TULSTRINGRESOURCEREADER_H
1.25 +
1.26 +#include <coemain.h> // RResourceReader
1.27 +
1.28 +/**
1.29 +CTulStringResourceReader reads strings from resource without CCoeEnv.
1.30 +If resource file given to the constructor is not found, the constructor leaves.
1.31 +This module is mainly for server usage, where there is the need to read resources,
1.32 +but no CCoeEnv instance is present.
1.33 +
1.34 +Usage:
1.35 +
1.36 +@code
1.37 +#include <stringresourcereader.h>
1.38 +#include <errorres.rsg> // Resource to be read header
1.39 +
1.40 +TFileName myFileName( _L("z:\\resource\\errorres.rsc") );
1.41 +CTulStringResourceReader* test = CTulStringResourceReader::NewL( myFileName );
1.42 +
1.43 +TPtrC buf;
1.44 +buf.Set(test-> ReadResourceString(R_ERROR_RES_GENERAL));
1.45 +
1.46 +// Note that buf will only be valid as long as CTulStringResourceReader
1.47 +// instance is alive and no new string is read by the same instance.
1.48 +// If you need to read multiple strings, make copies.
1.49 +
1.50 +delete test;
1.51 +@endcode
1.52 +
1.53 +@publishedAll
1.54 +@released
1.55 +*/
1.56 +class CTulStringResourceReader : public CBase
1.57 + {
1.58 +public: // Constructors and destructor
1.59 + IMPORT_C static CTulStringResourceReader* NewL(TFileName& aResFile);
1.60 + IMPORT_C static CTulStringResourceReader* NewLC(TFileName& aResFile);
1.61 + IMPORT_C static CTulStringResourceReader* NewL(TFileName& aResFile, RFs& aFs);
1.62 + IMPORT_C static CTulStringResourceReader* NewLC(TFileName& aResFile, RFs& aFs);
1.63 + ~CTulStringResourceReader();
1.64 +public:
1.65 + IMPORT_C const TDesC& ReadResourceString( TInt aResourceId );
1.66 +private:
1.67 + CTulStringResourceReader();
1.68 + void ConstructL(TFileName& aResFile);
1.69 + void ConstructL(TFileName& aResFile, RFs& aFs);
1.70 +private:
1.71 + RResourceFile iResourceFile;
1.72 + HBufC* iResourceBuffer;
1.73 + RFs iFsSession;
1.74 + TPtrC iTruncatedTextPointer;
1.75 + TBool iFsConnected; // ETrue if connected to the file server, else EFalse
1.76 + };
1.77 +
1.78 +#endif // TULSTRINGRESOURCEREADER_H
1.79 +