1 /* |
1 /* |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
79 return *this; |
80 return *this; |
80 } |
81 } |
81 |
82 |
82 Serialiser& operator<<(std::wstring& val) |
83 Serialiser& operator<<(std::wstring& val) |
83 { |
84 { |
|
85 |
|
86 std::wstring tempval = val.c_str(); |
|
87 |
|
88 #ifdef __TOOLS2_LINUX__ |
|
89 std::wstring::size_type idx = 0; |
|
90 while( (idx = tempval.find(L"/", idx)) != std::wstring::npos) |
|
91 { |
|
92 tempval.replace( idx, 1, L"\\" ); |
|
93 } |
|
94 #endif |
|
95 |
84 Cardinality card; |
96 Cardinality card; |
85 TUint32 size = val.size() << 1; |
97 TUint32 size = tempval.size() << 1; |
|
98 |
|
99 #ifdef __TOOLS2_LINUX__ |
|
100 const wchar_t * source = tempval.c_str(); |
|
101 unsigned short int* buffer = new unsigned short int[size]; |
|
102 |
|
103 // Using a temp variable in place of buffer as ConvertUTF32toUTF16 modifies the source pointer passed. |
|
104 unsigned short int* temp = buffer; |
|
105 |
|
106 ConvertUTF32toUTF16(&source, tempval.c_str() + tempval.size(), &temp, temp + size, lenientConversion); |
|
107 |
|
108 // Appending NULL to the converted buffer. |
|
109 *temp = NULL; |
|
110 #endif |
|
111 |
86 card.SetSize(size); |
112 card.SetSize(size); |
87 *this << card; |
113 *this << card; |
88 |
114 |
89 TUnicodeCompressor comp; |
115 TUnicodeCompressor comp; |
90 TMemoryUnicodeSource src((TUint16*)val.c_str()); |
116 |
|
117 #ifdef __TOOLS2_LINUX__ |
|
118 TMemoryUnicodeSource src((TUint16*)buffer); |
|
119 #else |
|
120 TMemoryUnicodeSource src((TUint16*)tempval.c_str()); |
|
121 #endif |
|
122 |
91 //The compressed unicode output could end up larger than the input, thus restricting the output to KMaxTInt. |
123 //The compressed unicode output could end up larger than the input, thus restricting the output to KMaxTInt. |
92 comp.CompressL(*this, src, KMaxTInt, val.size()); |
124 comp.CompressL(*this, src, KMaxTInt, tempval.size()); |
|
125 #ifdef __TOOLS2_LINUX__ |
|
126 delete[] buffer; |
|
127 #endif |
93 return *this; |
128 return *this; |
94 } |
129 } |
95 |
130 |
96 template <class T> |
131 template <class T> |
97 Serialiser& operator<<(std::vector<T>& val) |
132 Serialiser& operator<<(std::vector<T>& val) |