Skip to content

Commit 5301580

Browse files
committed
Remove obsolete DeserializeArray, move arpa/inet.h include to
Deserializer.hpp
1 parent 54bf0a9 commit 5301580

File tree

2 files changed

+6
-69
lines changed

2 files changed

+6
-69
lines changed

src/oatpp-postgresql/mapping/Deserializer.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
#include "PgArray.hpp"
2929
#include "oatpp-postgresql/Types.hpp"
3030

31-
#if defined(WIN32) || defined(_WIN32)
32-
#include <WinSock2.h>
33-
#else
34-
#include <arpa/inet.h>
35-
#endif
36-
3731
namespace oatpp { namespace postgresql { namespace mapping {
3832

3933
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
333327

334328
}
335329

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-
397330
}}}

src/oatpp-postgresql/mapping/Deserializer.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232

3333
#include <libpq-fe.h>
3434

35+
#if defined(WIN32) || defined(_WIN32)
36+
#include <WinSock2.h>
37+
#else
38+
#include <arpa/inet.h>
39+
#endif
40+
3541
namespace oatpp { namespace postgresql { namespace mapping {
3642

3743
/**
@@ -100,8 +106,6 @@ class Deserializer {
100106

101107
static oatpp::Void deserializeUuid(const Deserializer* _this, const InData& data, const Type* type);
102108

103-
static oatpp::Void deserializeArray(const Deserializer* _this, const InData& data, const Type* type);
104-
105109
template<class Collection>
106110
static oatpp::Void deserializeArray2(const Deserializer* _this, const InData& data, const Type* type) {
107111

0 commit comments

Comments
 (0)