/src/mozilla-central/storage/Variant.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
2 | | * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : |
3 | | * This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_storage_Variant_h__ |
8 | | #define mozilla_storage_Variant_h__ |
9 | | |
10 | | #include <utility> |
11 | | |
12 | | #include "nsIVariant.h" |
13 | | #include "nsMemory.h" |
14 | | #include "nsString.h" |
15 | | #include "nsTArray.h" |
16 | | |
17 | | #define VARIANT_BASE_IID \ |
18 | | { /* 78888042-0fa3-4f7a-8b19-7996f99bf1aa */ \ |
19 | | 0x78888042, 0x0fa3, 0x4f7a, \ |
20 | | { 0x8b, 0x19, 0x79, 0x96, 0xf9, 0x9b, 0xf1, 0xaa } \ |
21 | | } |
22 | | |
23 | | /** |
24 | | * This class is used by the storage module whenever an nsIVariant needs to be |
25 | | * returned. We provide traits for the basic sqlite types to make use easier. |
26 | | * The following types map to the indicated sqlite type: |
27 | | * int64_t -> INTEGER (use IntegerVariant) |
28 | | * double -> FLOAT (use FloatVariant) |
29 | | * nsString -> TEXT (use TextVariant) |
30 | | * nsCString -> TEXT (use UTF8TextVariant) |
31 | | * uint8_t[] -> BLOB (use BlobVariant) |
32 | | * nullptr -> NULL (use NullVariant) |
33 | | */ |
34 | | |
35 | | namespace mozilla { |
36 | | namespace storage { |
37 | | |
38 | | //////////////////////////////////////////////////////////////////////////////// |
39 | | //// Base Class |
40 | | |
41 | | class Variant_base : public nsIVariant |
42 | | { |
43 | | public: |
44 | | NS_DECL_THREADSAFE_ISUPPORTS |
45 | | NS_DECL_NSIVARIANT |
46 | | NS_DECLARE_STATIC_IID_ACCESSOR(VARIANT_BASE_IID) |
47 | | |
48 | | protected: |
49 | | virtual ~Variant_base() { } |
50 | | }; |
51 | | |
52 | | NS_DEFINE_STATIC_IID_ACCESSOR(Variant_base, |
53 | | VARIANT_BASE_IID) |
54 | | |
55 | | //////////////////////////////////////////////////////////////////////////////// |
56 | | //// Traits |
57 | | |
58 | | /** |
59 | | * Generics |
60 | | */ |
61 | | |
62 | | template <typename DataType> |
63 | | struct variant_traits |
64 | | { |
65 | | static inline uint16_t type() { return nsIDataType::VTYPE_EMPTY; } |
66 | | }; |
67 | | |
68 | | template <typename DataType, bool Adopting=false> |
69 | | struct variant_storage_traits |
70 | | { |
71 | | typedef DataType ConstructorType; |
72 | | typedef DataType StorageType; |
73 | | static inline void storage_conversion(const ConstructorType aData, StorageType* _storage) |
74 | 0 | { |
75 | 0 | *_storage = aData; |
76 | 0 | } Unexecuted instantiation: mozilla::storage::variant_storage_traits<double, false>::storage_conversion(double, double*) Unexecuted instantiation: mozilla::storage::variant_storage_traits<long, false>::storage_conversion(long, long*) |
77 | | |
78 | | static inline void destroy(const StorageType& _storage) |
79 | 0 | { } Unexecuted instantiation: mozilla::storage::variant_storage_traits<double, false>::destroy(double const&) Unexecuted instantiation: mozilla::storage::variant_storage_traits<long, false>::destroy(long const&) |
80 | | }; |
81 | | |
82 | 0 | #define NO_CONVERSION return NS_ERROR_CANNOT_CONVERT_DATA; |
83 | | |
84 | | template <typename DataType, bool Adopting=false> |
85 | | struct variant_integer_traits |
86 | | { |
87 | | typedef typename variant_storage_traits<DataType, Adopting>::StorageType StorageType; |
88 | 0 | static inline nsresult asInt32(const StorageType &, int32_t *) { NO_CONVERSION } Unexecuted instantiation: mozilla::storage::variant_integer_traits<nsTString<char>, false>::asInt32(nsTString<char> const&, int*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<nsTString<char16_t>, false>::asInt32(nsTString<char16_t> const&, int*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<double, false>::asInt32(double const&, int*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<unsigned char [], false>::asInt32(FallibleTArray<unsigned char> const&, int*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<unsigned char [], true>::asInt32(std::__1::pair<unsigned char*, int> const&, int*) |
89 | 0 | static inline nsresult asInt64(const StorageType &, int64_t *) { NO_CONVERSION } Unexecuted instantiation: mozilla::storage::variant_integer_traits<nsTString<char>, false>::asInt64(nsTString<char> const&, long*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<nsTString<char16_t>, false>::asInt64(nsTString<char16_t> const&, long*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<double, false>::asInt64(double const&, long*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<unsigned char [], false>::asInt64(FallibleTArray<unsigned char> const&, long*) Unexecuted instantiation: mozilla::storage::variant_integer_traits<unsigned char [], true>::asInt64(std::__1::pair<unsigned char*, int> const&, long*) |
90 | | }; |
91 | | |
92 | | template <typename DataType, bool Adopting=false> |
93 | | struct variant_float_traits |
94 | | { |
95 | | typedef typename variant_storage_traits<DataType, Adopting>::StorageType StorageType; |
96 | 0 | static inline nsresult asDouble(const StorageType &, double *) { NO_CONVERSION } Unexecuted instantiation: mozilla::storage::variant_float_traits<nsTString<char>, false>::asDouble(nsTString<char> const&, double*) Unexecuted instantiation: mozilla::storage::variant_float_traits<nsTString<char16_t>, false>::asDouble(nsTString<char16_t> const&, double*) Unexecuted instantiation: mozilla::storage::variant_float_traits<unsigned char [], false>::asDouble(FallibleTArray<unsigned char> const&, double*) Unexecuted instantiation: mozilla::storage::variant_float_traits<unsigned char [], true>::asDouble(std::__1::pair<unsigned char*, int> const&, double*) |
97 | | }; |
98 | | |
99 | | template <typename DataType, bool Adopting=false> |
100 | | struct variant_text_traits |
101 | | { |
102 | | typedef typename variant_storage_traits<DataType, Adopting>::StorageType StorageType; |
103 | 0 | static inline nsresult asUTF8String(const StorageType &, nsACString &) { NO_CONVERSION } Unexecuted instantiation: mozilla::storage::variant_text_traits<double, false>::asUTF8String(double const&, nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::variant_text_traits<long, false>::asUTF8String(long const&, nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::variant_text_traits<unsigned char [], false>::asUTF8String(FallibleTArray<unsigned char> const&, nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::variant_text_traits<unsigned char [], true>::asUTF8String(std::__1::pair<unsigned char*, int> const&, nsTSubstring<char>&) |
104 | 0 | static inline nsresult asString(const StorageType &, nsAString &) { NO_CONVERSION } Unexecuted instantiation: mozilla::storage::variant_text_traits<double, false>::asString(double const&, nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::variant_text_traits<long, false>::asString(long const&, nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::variant_text_traits<unsigned char [], false>::asString(FallibleTArray<unsigned char> const&, nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::variant_text_traits<unsigned char [], true>::asString(std::__1::pair<unsigned char*, int> const&, nsTSubstring<char16_t>&) |
105 | | }; |
106 | | |
107 | | template <typename DataType, bool Adopting=false> |
108 | | struct variant_blob_traits |
109 | | { |
110 | | typedef typename variant_storage_traits<DataType, Adopting>::StorageType StorageType; |
111 | | static inline nsresult asArray(const StorageType &, uint16_t *, uint32_t *, void **) |
112 | 0 | { NO_CONVERSION } Unexecuted instantiation: mozilla::storage::variant_blob_traits<nsTString<char>, false>::asArray(nsTString<char> const&, unsigned short*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::variant_blob_traits<nsTString<char16_t>, false>::asArray(nsTString<char16_t> const&, unsigned short*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::variant_blob_traits<double, false>::asArray(double const&, unsigned short*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::variant_blob_traits<long, false>::asArray(long const&, unsigned short*, unsigned int*, void**) |
113 | | }; |
114 | | |
115 | | #undef NO_CONVERSION |
116 | | |
117 | | /** |
118 | | * INTEGER types |
119 | | */ |
120 | | |
121 | | template < > |
122 | | struct variant_traits<int64_t> |
123 | | { |
124 | 0 | static inline uint16_t type() { return nsIDataType::VTYPE_INT64; } |
125 | | }; |
126 | | template < > |
127 | | struct variant_integer_traits<int64_t> |
128 | | { |
129 | | static inline nsresult asInt32(int64_t aValue, |
130 | | int32_t *_result) |
131 | 0 | { |
132 | 0 | if (aValue > INT32_MAX || aValue < INT32_MIN) |
133 | 0 | return NS_ERROR_CANNOT_CONVERT_DATA; |
134 | 0 | |
135 | 0 | *_result = static_cast<int32_t>(aValue); |
136 | 0 | return NS_OK; |
137 | 0 | } |
138 | | static inline nsresult asInt64(int64_t aValue, |
139 | | int64_t *_result) |
140 | 0 | { |
141 | 0 | *_result = aValue; |
142 | 0 | return NS_OK; |
143 | 0 | } |
144 | | }; |
145 | | // xpcvariant just calls get double for integers... |
146 | | template < > |
147 | | struct variant_float_traits<int64_t> |
148 | | { |
149 | | static inline nsresult asDouble(int64_t aValue, |
150 | | double *_result) |
151 | 0 | { |
152 | 0 | *_result = double(aValue); |
153 | 0 | return NS_OK; |
154 | 0 | } |
155 | | }; |
156 | | |
157 | | /** |
158 | | * FLOAT types |
159 | | */ |
160 | | |
161 | | template < > |
162 | | struct variant_traits<double> |
163 | | { |
164 | 0 | static inline uint16_t type() { return nsIDataType::VTYPE_DOUBLE; } |
165 | | }; |
166 | | template < > |
167 | | struct variant_float_traits<double> |
168 | | { |
169 | | static inline nsresult asDouble(double aValue, |
170 | | double *_result) |
171 | 0 | { |
172 | 0 | *_result = aValue; |
173 | 0 | return NS_OK; |
174 | 0 | } |
175 | | }; |
176 | | |
177 | | /** |
178 | | * TEXT types |
179 | | */ |
180 | | |
181 | | template < > |
182 | | struct variant_traits<nsString> |
183 | | { |
184 | 0 | static inline uint16_t type() { return nsIDataType::VTYPE_ASTRING; } |
185 | | }; |
186 | | template < > |
187 | | struct variant_storage_traits<nsString> |
188 | | { |
189 | | typedef const nsAString & ConstructorType; |
190 | | typedef nsString StorageType; |
191 | | static inline void storage_conversion(ConstructorType aText, StorageType* _outData) |
192 | 0 | { |
193 | 0 | *_outData = aText; |
194 | 0 | } |
195 | | static inline void destroy(const StorageType& _outData) |
196 | 0 | { } |
197 | | }; |
198 | | template < > |
199 | | struct variant_text_traits<nsString> |
200 | | { |
201 | | static inline nsresult asUTF8String(const nsString &aValue, |
202 | | nsACString &_result) |
203 | 0 | { |
204 | 0 | CopyUTF16toUTF8(aValue, _result); |
205 | 0 | return NS_OK; |
206 | 0 | } |
207 | | static inline nsresult asString(const nsString &aValue, |
208 | | nsAString &_result) |
209 | 0 | { |
210 | 0 | _result = aValue; |
211 | 0 | return NS_OK; |
212 | 0 | } |
213 | | }; |
214 | | |
215 | | template < > |
216 | | struct variant_traits<nsCString> |
217 | | { |
218 | 0 | static inline uint16_t type() { return nsIDataType::VTYPE_UTF8STRING; } |
219 | | }; |
220 | | template < > |
221 | | struct variant_storage_traits<nsCString> |
222 | | { |
223 | | typedef const nsACString & ConstructorType; |
224 | | typedef nsCString StorageType; |
225 | | static inline void storage_conversion(ConstructorType aText, StorageType* _outData) |
226 | 0 | { |
227 | 0 | *_outData = aText; |
228 | 0 | } |
229 | | static inline void destroy(const StorageType &aData) |
230 | 0 | { } |
231 | | }; |
232 | | template < > |
233 | | struct variant_text_traits<nsCString> |
234 | | { |
235 | | static inline nsresult asUTF8String(const nsCString &aValue, |
236 | | nsACString &_result) |
237 | 0 | { |
238 | 0 | _result = aValue; |
239 | 0 | return NS_OK; |
240 | 0 | } |
241 | | static inline nsresult asString(const nsCString &aValue, |
242 | | nsAString &_result) |
243 | 0 | { |
244 | 0 | CopyUTF8toUTF16(aValue, _result); |
245 | 0 | return NS_OK; |
246 | 0 | } |
247 | | }; |
248 | | |
249 | | /** |
250 | | * BLOB types |
251 | | */ |
252 | | |
253 | | template < > |
254 | | struct variant_traits<uint8_t[]> |
255 | | { |
256 | 0 | static inline uint16_t type() { return nsIDataType::VTYPE_ARRAY; } |
257 | | }; |
258 | | template < > |
259 | | struct variant_storage_traits<uint8_t[], false> |
260 | | { |
261 | | typedef std::pair<const void *, int> ConstructorType; |
262 | | typedef FallibleTArray<uint8_t> StorageType; |
263 | | static inline void storage_conversion(ConstructorType aBlob, StorageType* _outData) |
264 | 0 | { |
265 | 0 | _outData->Clear(); |
266 | 0 | (void)_outData->AppendElements(static_cast<const uint8_t *>(aBlob.first), |
267 | 0 | aBlob.second, fallible); |
268 | 0 | } |
269 | | static inline void destroy(const StorageType& _outData) |
270 | 0 | { } |
271 | | }; |
272 | | template < > |
273 | | struct variant_storage_traits<uint8_t[], true> |
274 | | { |
275 | | typedef std::pair<uint8_t *, int> ConstructorType; |
276 | | typedef std::pair<uint8_t *, int> StorageType; |
277 | | static inline void storage_conversion(ConstructorType aBlob, StorageType* _outData) |
278 | 0 | { |
279 | 0 | *_outData = aBlob; |
280 | 0 | } |
281 | | static inline void destroy(StorageType &aData) |
282 | 0 | { |
283 | 0 | if (aData.first) { |
284 | 0 | free(aData.first); |
285 | 0 | aData.first = nullptr; |
286 | 0 | } |
287 | 0 | } |
288 | | }; |
289 | | template < > |
290 | | struct variant_blob_traits<uint8_t[], false> |
291 | | { |
292 | | static inline nsresult asArray(FallibleTArray<uint8_t> &aData, |
293 | | uint16_t *_type, |
294 | | uint32_t *_size, |
295 | | void **_result) |
296 | 0 | { |
297 | 0 | // For empty blobs, we return nullptr. |
298 | 0 | if (aData.Length() == 0) { |
299 | 0 | *_result = nullptr; |
300 | 0 | *_type = nsIDataType::VTYPE_UINT8; |
301 | 0 | *_size = 0; |
302 | 0 | return NS_OK; |
303 | 0 | } |
304 | 0 | |
305 | 0 | // Otherwise, we copy the array. |
306 | 0 | *_result = moz_xmemdup(aData.Elements(), aData.Length() * sizeof(uint8_t)); |
307 | 0 |
|
308 | 0 | // Set type and size |
309 | 0 | *_type = nsIDataType::VTYPE_UINT8; |
310 | 0 | *_size = aData.Length(); |
311 | 0 | return NS_OK; |
312 | 0 | } |
313 | | }; |
314 | | |
315 | | template < > |
316 | | struct variant_blob_traits<uint8_t[], true> |
317 | | { |
318 | | static inline nsresult asArray(std::pair<uint8_t *, int> &aData, |
319 | | uint16_t *_type, |
320 | | uint32_t *_size, |
321 | | void **_result) |
322 | 0 | { |
323 | 0 | // For empty blobs, we return nullptr. |
324 | 0 | if (aData.second == 0) { |
325 | 0 | *_result = nullptr; |
326 | 0 | *_type = nsIDataType::VTYPE_UINT8; |
327 | 0 | *_size = 0; |
328 | 0 | return NS_OK; |
329 | 0 | } |
330 | 0 | |
331 | 0 | // Otherwise, transfer the data out. |
332 | 0 | *_result = aData.first; |
333 | 0 | aData.first = nullptr; |
334 | 0 | MOZ_ASSERT(*_result); // We asked for it twice, better not use adopting! |
335 | 0 |
|
336 | 0 | // Set type and size |
337 | 0 | *_type = nsIDataType::VTYPE_UINT8; |
338 | 0 | *_size = aData.second; |
339 | 0 | return NS_OK; |
340 | 0 | } |
341 | | }; |
342 | | |
343 | | /** |
344 | | * nullptr type |
345 | | */ |
346 | | |
347 | | class NullVariant : public Variant_base |
348 | | { |
349 | | public: |
350 | | NS_IMETHOD GetDataType(uint16_t *_type) override |
351 | 0 | { |
352 | 0 | NS_ENSURE_ARG_POINTER(_type); |
353 | 0 | *_type = nsIDataType::VTYPE_EMPTY; |
354 | 0 | return NS_OK; |
355 | 0 | } |
356 | | |
357 | | NS_IMETHOD GetAsAUTF8String(nsACString &_str) override |
358 | 0 | { |
359 | 0 | // Return a void string. |
360 | 0 | _str.SetIsVoid(true); |
361 | 0 | return NS_OK; |
362 | 0 | } |
363 | | |
364 | | NS_IMETHOD GetAsAString(nsAString &_str) override |
365 | 0 | { |
366 | 0 | // Return a void string. |
367 | 0 | _str.SetIsVoid(true); |
368 | 0 | return NS_OK; |
369 | 0 | } |
370 | | }; |
371 | | |
372 | | //////////////////////////////////////////////////////////////////////////////// |
373 | | //// Template Implementation |
374 | | |
375 | | template <typename DataType, bool Adopting=false> |
376 | | class Variant final : public Variant_base |
377 | | { |
378 | | ~Variant() |
379 | 0 | { |
380 | 0 | variant_storage_traits<DataType, Adopting>::destroy(mData); |
381 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::~Variant() Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::~Variant() Unexecuted instantiation: mozilla::storage::Variant<double, false>::~Variant() Unexecuted instantiation: mozilla::storage::Variant<long, false>::~Variant() Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::~Variant() Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::~Variant() |
382 | | |
383 | | public: |
384 | | explicit Variant(const typename variant_storage_traits<DataType, Adopting>::ConstructorType aData) |
385 | 0 | { |
386 | 0 | variant_storage_traits<DataType, Adopting>::storage_conversion(aData, &mData); |
387 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::Variant(nsTSubstring<char> const&) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::Variant(nsTSubstring<char16_t> const&) Unexecuted instantiation: mozilla::storage::Variant<double, false>::Variant(double) Unexecuted instantiation: mozilla::storage::Variant<long, false>::Variant(long) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::Variant(std::__1::pair<void const*, int>) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::Variant(std::__1::pair<unsigned char*, int>) |
388 | | |
389 | | NS_IMETHOD GetDataType(uint16_t *_type) override |
390 | 0 | { |
391 | 0 | *_type = variant_traits<DataType>::type(); |
392 | 0 | return NS_OK; |
393 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::GetDataType(unsigned short*) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::GetDataType(unsigned short*) Unexecuted instantiation: mozilla::storage::Variant<double, false>::GetDataType(unsigned short*) Unexecuted instantiation: mozilla::storage::Variant<long, false>::GetDataType(unsigned short*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::GetDataType(unsigned short*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::GetDataType(unsigned short*) |
394 | | NS_IMETHOD GetAsInt32(int32_t *_integer) override |
395 | 0 | { |
396 | 0 | return variant_integer_traits<DataType, Adopting>::asInt32(mData, _integer); |
397 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::GetAsInt32(int*) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::GetAsInt32(int*) Unexecuted instantiation: mozilla::storage::Variant<double, false>::GetAsInt32(int*) Unexecuted instantiation: mozilla::storage::Variant<long, false>::GetAsInt32(int*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::GetAsInt32(int*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::GetAsInt32(int*) |
398 | | |
399 | | NS_IMETHOD GetAsInt64(int64_t *_integer) override |
400 | 0 | { |
401 | 0 | return variant_integer_traits<DataType, Adopting>::asInt64(mData, _integer); |
402 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::GetAsInt64(long*) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::GetAsInt64(long*) Unexecuted instantiation: mozilla::storage::Variant<double, false>::GetAsInt64(long*) Unexecuted instantiation: mozilla::storage::Variant<long, false>::GetAsInt64(long*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::GetAsInt64(long*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::GetAsInt64(long*) |
403 | | |
404 | | NS_IMETHOD GetAsDouble(double *_double) override |
405 | 0 | { |
406 | 0 | return variant_float_traits<DataType, Adopting>::asDouble(mData, _double); |
407 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::GetAsDouble(double*) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::GetAsDouble(double*) Unexecuted instantiation: mozilla::storage::Variant<double, false>::GetAsDouble(double*) Unexecuted instantiation: mozilla::storage::Variant<long, false>::GetAsDouble(double*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::GetAsDouble(double*) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::GetAsDouble(double*) |
408 | | |
409 | | NS_IMETHOD GetAsAUTF8String(nsACString &_str) override |
410 | 0 | { |
411 | 0 | return variant_text_traits<DataType, Adopting>::asUTF8String(mData, _str); |
412 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::GetAsAUTF8String(nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::GetAsAUTF8String(nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::Variant<double, false>::GetAsAUTF8String(nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::Variant<long, false>::GetAsAUTF8String(nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::GetAsAUTF8String(nsTSubstring<char>&) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::GetAsAUTF8String(nsTSubstring<char>&) |
413 | | |
414 | | NS_IMETHOD GetAsAString(nsAString &_str) override |
415 | 0 | { |
416 | 0 | return variant_text_traits<DataType, Adopting>::asString(mData, _str); |
417 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::GetAsAString(nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::GetAsAString(nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::Variant<double, false>::GetAsAString(nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::Variant<long, false>::GetAsAString(nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::GetAsAString(nsTSubstring<char16_t>&) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::GetAsAString(nsTSubstring<char16_t>&) |
418 | | |
419 | | NS_IMETHOD GetAsArray(uint16_t *_type, |
420 | | nsIID *, |
421 | | uint32_t *_size, |
422 | | void **_data) override |
423 | 0 | { |
424 | 0 | return variant_blob_traits<DataType, Adopting>::asArray(mData, _type, _size, _data); |
425 | 0 | } Unexecuted instantiation: mozilla::storage::Variant<nsTString<char>, false>::GetAsArray(unsigned short*, nsID*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::Variant<nsTString<char16_t>, false>::GetAsArray(unsigned short*, nsID*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::Variant<double, false>::GetAsArray(unsigned short*, nsID*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::Variant<long, false>::GetAsArray(unsigned short*, nsID*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], false>::GetAsArray(unsigned short*, nsID*, unsigned int*, void**) Unexecuted instantiation: mozilla::storage::Variant<unsigned char [], true>::GetAsArray(unsigned short*, nsID*, unsigned int*, void**) |
426 | | |
427 | | private: |
428 | | typename variant_storage_traits<DataType, Adopting>::StorageType mData; |
429 | | }; |
430 | | |
431 | | //////////////////////////////////////////////////////////////////////////////// |
432 | | //// Handy typedefs! Use these for the right mapping. |
433 | | |
434 | | typedef Variant<int64_t> IntegerVariant; |
435 | | typedef Variant<double> FloatVariant; |
436 | | typedef Variant<nsString> TextVariant; |
437 | | typedef Variant<nsCString> UTF8TextVariant; |
438 | | typedef Variant<uint8_t[], false> BlobVariant; |
439 | | typedef Variant<uint8_t[], true> AdoptedBlobVariant; |
440 | | |
441 | | } // namespace storage |
442 | | } // namespace mozilla |
443 | | |
444 | | #include "Variant_inl.h" |
445 | | |
446 | | #endif // mozilla_storage_Variant_h__ |