sl@0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Abstraction for "an environment" holding pairs of C strings (name, value)
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32std.h>
|
sl@0
|
19 |
#include <e32base.h>
|
sl@0
|
20 |
#include <stddef.h> //for wchar_t
|
sl@0
|
21 |
|
sl@0
|
22 |
class CEnvironment;
|
sl@0
|
23 |
class TEnvVar
|
sl@0
|
24 |
/**
|
sl@0
|
25 |
@internalComponent
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
{
|
sl@0
|
28 |
friend class CEnvironment; // who manages my storage
|
sl@0
|
29 |
public:
|
sl@0
|
30 |
void Release();
|
sl@0
|
31 |
void ConstructL(const TDesC16& aName, const wchar_t* aValue);
|
sl@0
|
32 |
TInt SetValue(const wchar_t* aValue);
|
sl@0
|
33 |
HBufC16* Match(const TDesC16& aName);
|
sl@0
|
34 |
TUint Length() const;
|
sl@0
|
35 |
const TInt NotEmpty() const { return (TInt)iValue; };
|
sl@0
|
36 |
static TInt Externalize(const wchar_t* aPair, TDes16& aBuffer);
|
sl@0
|
37 |
TInt Externalize(TDes16& aBuffer);
|
sl@0
|
38 |
void ConstructL(const TText16*& aPtr);
|
sl@0
|
39 |
private:
|
sl@0
|
40 |
static TPtrC16 ValuePtr(const wchar_t* aValue);
|
sl@0
|
41 |
HBufC16* iName;
|
sl@0
|
42 |
HBufC16* iValue; // data is zero terminated
|
sl@0
|
43 |
};
|
sl@0
|
44 |
|
sl@0
|
45 |
NONSHARABLE_CLASS(CEnvironment) : public CBase
|
sl@0
|
46 |
/**
|
sl@0
|
47 |
@internalComponent
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
{
|
sl@0
|
50 |
public:
|
sl@0
|
51 |
CEnvironment() {};
|
sl@0
|
52 |
~CEnvironment();
|
sl@0
|
53 |
|
sl@0
|
54 |
wchar_t* getenv(const wchar_t* aName) const;
|
sl@0
|
55 |
int setenv(const wchar_t* aName, const wchar_t* aValue, int aReplace, int& anErrno);
|
sl@0
|
56 |
void unsetenv(const wchar_t* aName);
|
sl@0
|
57 |
|
sl@0
|
58 |
void ConstructL(TUint aCount, TDes16& aBuffer);
|
sl@0
|
59 |
HBufC16* ExternalizeLC(TUint& aCount);
|
sl@0
|
60 |
HBufC16* ExternalizeLC(TUint& aCount, wchar_t** envp);
|
sl@0
|
61 |
private:
|
sl@0
|
62 |
TUint iCount;
|
sl@0
|
63 |
TEnvVar* iVars;
|
sl@0
|
64 |
};
|