sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Abstraction for "an environment" holding pairs of C strings (name, value) sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include //for wchar_t sl@0: sl@0: class CEnvironment; sl@0: class TEnvVar sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: friend class CEnvironment; // who manages my storage sl@0: public: sl@0: void Release(); sl@0: void ConstructL(const TDesC16& aName, const wchar_t* aValue); sl@0: TInt SetValue(const wchar_t* aValue); sl@0: HBufC16* Match(const TDesC16& aName); sl@0: TUint Length() const; sl@0: const TInt NotEmpty() const { return (TInt)iValue; }; sl@0: static TInt Externalize(const wchar_t* aPair, TDes16& aBuffer); sl@0: TInt Externalize(TDes16& aBuffer); sl@0: void ConstructL(const TText16*& aPtr); sl@0: private: sl@0: static TPtrC16 ValuePtr(const wchar_t* aValue); sl@0: HBufC16* iName; sl@0: HBufC16* iValue; // data is zero terminated sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CEnvironment) : public CBase sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: CEnvironment() {}; sl@0: ~CEnvironment(); sl@0: sl@0: wchar_t* getenv(const wchar_t* aName) const; sl@0: int setenv(const wchar_t* aName, const wchar_t* aValue, int aReplace, int& anErrno); sl@0: void unsetenv(const wchar_t* aName); sl@0: sl@0: void ConstructL(TUint aCount, TDes16& aBuffer); sl@0: HBufC16* ExternalizeLC(TUint& aCount); sl@0: HBufC16* ExternalizeLC(TUint& aCount, wchar_t** envp); sl@0: private: sl@0: TUint iCount; sl@0: TEnvVar* iVars; sl@0: };