|
1 /** @file |
|
2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: HTTP header |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "upnphttpheader.h" |
|
22 |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CUpnpHttpHeader::CUpnpHttpHeader |
|
28 // C++ default constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CUpnpHttpHeader::CUpnpHttpHeader() |
|
33 { |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CUpnpHttpHeader::ConstructL |
|
38 // Symbian 2nd phase constructor can leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void CUpnpHttpHeader::ConstructL( const TDesC8& aName, const TDesC8& aValue ) |
|
42 { |
|
43 iName = HBufC8::NewL(aName.Length()); |
|
44 iName->Des().SetLength(0); |
|
45 iName->Des().Append(aName); |
|
46 |
|
47 iValue = HBufC8::NewL(aValue.Length()); |
|
48 iValue->Des().SetLength(0); |
|
49 iValue->Des().Append(aValue); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CUpnpHttpHeader::NewL |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CUpnpHttpHeader* CUpnpHttpHeader::NewL(const TDesC8& aName, const TDesC8& aValue) |
|
58 { |
|
59 CUpnpHttpHeader* self = new (ELeave) CUpnpHttpHeader(); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(aName, aValue); |
|
62 CleanupStack::Pop(); |
|
63 |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CUpnpHttpHeader::~CUpnpHttpHeader |
|
69 // Destructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CUpnpHttpHeader::~CUpnpHttpHeader() |
|
73 { |
|
74 if (iName) |
|
75 { |
|
76 delete iName; |
|
77 iName = NULL; |
|
78 } |
|
79 |
|
80 if (iValue) |
|
81 { |
|
82 delete iValue; |
|
83 iValue = NULL; |
|
84 } |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CUpnpHttpHeader::Name |
|
89 // Returns name of HTTPHeader. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C TDesC8& CUpnpHttpHeader::Name() |
|
93 { |
|
94 if ( iName != NULL ) |
|
95 { |
|
96 return *iName; |
|
97 } |
|
98 else |
|
99 { |
|
100 return ( TDesC8& ) KNullDesC8(); |
|
101 } |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CUpnpHttpHeader::Value |
|
106 // Returns value of HTTPHeader. |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C TDesC8& CUpnpHttpHeader::Value() |
|
110 { |
|
111 if ( iName != NULL ) |
|
112 { |
|
113 return *iValue; |
|
114 } |
|
115 else |
|
116 { |
|
117 return ( TDesC8& ) KNullDesC8(); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CUpnpHttpHeader::SetNameL |
|
123 // Set name of HTTPHeader. |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 EXPORT_C void CUpnpHttpHeader::SetNameL( const TDesC8& aName ) |
|
127 { |
|
128 if ( iName ) |
|
129 { |
|
130 delete iName; |
|
131 iName = NULL; |
|
132 } |
|
133 |
|
134 iName = HBufC8::NewL( aName.Length() ); |
|
135 iName->Des().SetLength( 0 ); |
|
136 iName->Des().Append(aName); |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CUpnpHttpHeader::SetValueL |
|
141 // Set value of HTTPHeader. |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C void CUpnpHttpHeader::SetValueL( const TDesC8& aValue ) |
|
145 { |
|
146 if ( iValue ) |
|
147 { |
|
148 delete iValue; |
|
149 iValue = NULL; |
|
150 } |
|
151 |
|
152 iValue = HBufC8::NewL( aValue.Length() ); |
|
153 iValue->Des().SetLength( 0 ); |
|
154 iValue->Des().Append( aValue ); |
|
155 } |
|
156 |
|
157 // End of File |