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