From 5301580346293266cc64ea4002938d1786dc6016 Mon Sep 17 00:00:00 2001 From: Don Smyth Date: Mon, 4 Jan 2021 10:36:51 -0800 Subject: [PATCH] Remove obsolete DeserializeArray, move arpa/inet.h include to Deserializer.hpp --- src/oatpp-postgresql/mapping/Deserializer.cpp | 67 ------------------- src/oatpp-postgresql/mapping/Deserializer.hpp | 8 ++- 2 files changed, 6 insertions(+), 69 deletions(-) diff --git a/src/oatpp-postgresql/mapping/Deserializer.cpp b/src/oatpp-postgresql/mapping/Deserializer.cpp index f480169..730e318 100644 --- a/src/oatpp-postgresql/mapping/Deserializer.cpp +++ b/src/oatpp-postgresql/mapping/Deserializer.cpp @@ -28,12 +28,6 @@ #include "PgArray.hpp" #include "oatpp-postgresql/Types.hpp" -#if defined(WIN32) || defined(_WIN32) - #include -#else - #include -#endif - namespace oatpp { namespace postgresql { namespace mapping { Deserializer::InData::InData(PGresult* dbres, int row, int col, const std::shared_ptr& pTypeResolver) { @@ -333,65 +327,4 @@ oatpp::Void Deserializer::deserializeUuid(const Deserializer* _this, const InDat } -oatpp::Void Deserializer::deserializeArray(const Deserializer* _this, const InData& data, const Type* type) { - - (void) _this; - (void) type; - - // Place to put our data - oatpp::Void retval = nullptr; - - // see if we handle this type - switch (data.oid) { - case FLOAT8ARRAYOID: - break; - default: - throw std::runtime_error("[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Unhandled array type."); - } - - // parse out the array - if (!data.isNull) { - auto *pgArray = reinterpret_cast(data.data); - - // everything is in network order!!! - // only handle 1d array for now - if (ntohl(pgArray->header.ndim) > 1) { - throw std::runtime_error("[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Dimension > 1"); - } - - // make sure data is the right type - if (ntohl(pgArray->header.oid) == FLOAT8OID) { - // build the array - auto vec = oatpp::Vector::createShared(); - auto nElem = ntohl(pgArray->header.size); - for (int i = 0; i < nElem; i++) { - // get element size, point to element data - auto elemSize = ntohl(pgArray->elem[i].size); - // quit if we get an empty element - if (elemSize == 0) { - break; - } - // make sure element size matches the data size - if (elemSize != sizeof(v_float64)) { - throw std::runtime_error( - "[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Bad element size"); - } - // get the 64 bit host order data, pointing to next element - // TODO: make sure this matches element size - v_int64 l1 = ntohl(pgArray->elem[i].value[0]); - v_int64 l2 = ntohl(pgArray->elem[i].value[1]); - v_int64 intVal = (l1 << 32) | l2 ; - v_float64 val = *reinterpret_cast(&intVal); - vec->push_back(val); - } - retval = vec; - } else { - throw std::runtime_error( - "[oatpp::postgresql::mapping::Deserializer::deserializeArray()]: Unhandled array value type."); - } - } - - return retval; -} - }}} diff --git a/src/oatpp-postgresql/mapping/Deserializer.hpp b/src/oatpp-postgresql/mapping/Deserializer.hpp index 48967c6..5c6876c 100644 --- a/src/oatpp-postgresql/mapping/Deserializer.hpp +++ b/src/oatpp-postgresql/mapping/Deserializer.hpp @@ -32,6 +32,12 @@ #include +#if defined(WIN32) || defined(_WIN32) +#include +#else +#include +#endif + namespace oatpp { namespace postgresql { namespace mapping { /** @@ -100,8 +106,6 @@ private: static oatpp::Void deserializeUuid(const Deserializer* _this, const InData& data, const Type* type); - static oatpp::Void deserializeArray(const Deserializer* _this, const InData& data, const Type* type); - template static oatpp::Void deserializeArray2(const Deserializer* _this, const InData& data, const Type* type) {