|
28 | 28 | #include "PgArray.hpp"
|
29 | 29 | #include "oatpp-postgresql/Types.hpp"
|
30 | 30 |
|
31 |
| -#if defined(WIN32) || defined(_WIN32) |
32 |
| - #include <WinSock2.h> |
33 |
| -#else |
34 |
| - #include <arpa/inet.h> |
35 |
| -#endif |
36 |
| - |
37 | 31 | namespace oatpp { namespace postgresql { namespace mapping {
|
38 | 32 |
|
39 | 33 | Deserializer::InData::InData(PGresult* dbres, int row, int col, const std::shared_ptr<const data::mapping::TypeResolver>& pTypeResolver) {
|
@@ -333,65 +327,4 @@ oatpp::Void Deserializer::deserializeUuid(const Deserializer* _this, const InDat
|
333 | 327 |
|
334 | 328 | }
|
335 | 329 |
|
336 |
| -oatpp::Void Deserializer::deserializeArray(const Deserializer* _this, const InData& data, const Type* type) { |
337 |
| - |
338 |
| - (void) _this; |
339 |
| - (void) type; |
340 |
| - |
341 |
| - // Place to put our data |
342 |
| - oatpp::Void retval = nullptr; |
343 |
| - |
344 |
| - // see if we handle this type |
345 |
| - switch (data.oid) { |
346 |
| - case FLOAT8ARRAYOID: |
347 |
| - break; |
348 |
| - default: |
349 |
| - throw std::runtime_error("[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Unhandled array type."); |
350 |
| - } |
351 |
| - |
352 |
| - // parse out the array |
353 |
| - if (!data.isNull) { |
354 |
| - auto *pgArray = reinterpret_cast<const PgArray *>(data.data); |
355 |
| - |
356 |
| - // everything is in network order!!! |
357 |
| - // only handle 1d array for now |
358 |
| - if (ntohl(pgArray->header.ndim) > 1) { |
359 |
| - throw std::runtime_error("[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Dimension > 1"); |
360 |
| - } |
361 |
| - |
362 |
| - // make sure data is the right type |
363 |
| - if (ntohl(pgArray->header.oid) == FLOAT8OID) { |
364 |
| - // build the array |
365 |
| - auto vec = oatpp::Vector<Float64>::createShared(); |
366 |
| - auto nElem = ntohl(pgArray->header.size); |
367 |
| - for (int i = 0; i < nElem; i++) { |
368 |
| - // get element size, point to element data |
369 |
| - auto elemSize = ntohl(pgArray->elem[i].size); |
370 |
| - // quit if we get an empty element |
371 |
| - if (elemSize == 0) { |
372 |
| - break; |
373 |
| - } |
374 |
| - // make sure element size matches the data size |
375 |
| - if (elemSize != sizeof(v_float64)) { |
376 |
| - throw std::runtime_error( |
377 |
| - "[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Bad element size"); |
378 |
| - } |
379 |
| - // get the 64 bit host order data, pointing to next element |
380 |
| - // TODO: make sure this matches element size |
381 |
| - v_int64 l1 = ntohl(pgArray->elem[i].value[0]); |
382 |
| - v_int64 l2 = ntohl(pgArray->elem[i].value[1]); |
383 |
| - v_int64 intVal = (l1 << 32) | l2 ; |
384 |
| - v_float64 val = *reinterpret_cast<p_float64>(&intVal); |
385 |
| - vec->push_back(val); |
386 |
| - } |
387 |
| - retval = vec; |
388 |
| - } else { |
389 |
| - throw std::runtime_error( |
390 |
| - "[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Unhandled array value type."); |
391 |
| - } |
392 |
| - } |
393 |
| - |
394 |
| - return retval; |
395 |
| -} |
396 |
| - |
397 | 330 | }}}
|
0 commit comments