1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/INC/ENVIRON.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,64 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Abstraction for "an environment" holding pairs of C strings (name, value)
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32std.h>
1.22 +#include <e32base.h>
1.23 +#include <stddef.h> //for wchar_t
1.24 +
1.25 +class CEnvironment;
1.26 +class TEnvVar
1.27 +/**
1.28 +@internalComponent
1.29 +*/
1.30 + {
1.31 + friend class CEnvironment; // who manages my storage
1.32 +public:
1.33 + void Release();
1.34 + void ConstructL(const TDesC16& aName, const wchar_t* aValue);
1.35 + TInt SetValue(const wchar_t* aValue);
1.36 + HBufC16* Match(const TDesC16& aName);
1.37 + TUint Length() const;
1.38 + const TInt NotEmpty() const { return (TInt)iValue; };
1.39 + static TInt Externalize(const wchar_t* aPair, TDes16& aBuffer);
1.40 + TInt Externalize(TDes16& aBuffer);
1.41 + void ConstructL(const TText16*& aPtr);
1.42 +private:
1.43 + static TPtrC16 ValuePtr(const wchar_t* aValue);
1.44 + HBufC16* iName;
1.45 + HBufC16* iValue; // data is zero terminated
1.46 + };
1.47 +
1.48 +NONSHARABLE_CLASS(CEnvironment) : public CBase
1.49 +/**
1.50 +@internalComponent
1.51 +*/
1.52 + {
1.53 +public:
1.54 + CEnvironment() {};
1.55 + ~CEnvironment();
1.56 +
1.57 + wchar_t* getenv(const wchar_t* aName) const;
1.58 + int setenv(const wchar_t* aName, const wchar_t* aValue, int aReplace, int& anErrno);
1.59 + void unsetenv(const wchar_t* aName);
1.60 +
1.61 + void ConstructL(TUint aCount, TDes16& aBuffer);
1.62 + HBufC16* ExternalizeLC(TUint& aCount);
1.63 + HBufC16* ExternalizeLC(TUint& aCount, wchar_t** envp);
1.64 +private:
1.65 + TUint iCount;
1.66 + TEnvVar* iVars;
1.67 + };