Ser/De: Arrays. Refactor method names.

This commit is contained in:
lganzzzo 2021-02-10 01:29:21 +02:00
parent d1bcba1380
commit 28af5a276e
4 changed files with 17 additions and 11 deletions

View File

@ -64,9 +64,9 @@ Deserializer::Deserializer() {
setDeserializerMethod(data::mapping::type::__class::AbstractObject::CLASS_ID, nullptr); setDeserializerMethod(data::mapping::type::__class::AbstractObject::CLASS_ID, nullptr);
setDeserializerMethod(data::mapping::type::__class::AbstractEnum::CLASS_ID, &Deserializer::deserializeEnum); setDeserializerMethod(data::mapping::type::__class::AbstractEnum::CLASS_ID, &Deserializer::deserializeEnum);
setDeserializerMethod(data::mapping::type::__class::AbstractVector::CLASS_ID, &Deserializer::deserializeArray2<oatpp::AbstractVector>); setDeserializerMethod(data::mapping::type::__class::AbstractVector::CLASS_ID, &Deserializer::deserializeArray<oatpp::AbstractVector>);
setDeserializerMethod(data::mapping::type::__class::AbstractList::CLASS_ID, &Deserializer::deserializeArray2<oatpp::AbstractList>); setDeserializerMethod(data::mapping::type::__class::AbstractList::CLASS_ID, &Deserializer::deserializeArray<oatpp::AbstractList>);
setDeserializerMethod(data::mapping::type::__class::AbstractUnorderedSet::CLASS_ID, &Deserializer::deserializeArray2<oatpp::AbstractUnorderedSet>); setDeserializerMethod(data::mapping::type::__class::AbstractUnorderedSet::CLASS_ID, &Deserializer::deserializeArray<oatpp::AbstractUnorderedSet>);
setDeserializerMethod(data::mapping::type::__class::AbstractPairList::CLASS_ID, nullptr); setDeserializerMethod(data::mapping::type::__class::AbstractPairList::CLASS_ID, nullptr);
setDeserializerMethod(data::mapping::type::__class::AbstractUnorderedMap::CLASS_ID, nullptr); setDeserializerMethod(data::mapping::type::__class::AbstractUnorderedMap::CLASS_ID, nullptr);

View File

@ -212,7 +212,7 @@ private:
} }
template<class Collection> template<class Collection>
static oatpp::Void deserializeArray2(const Deserializer* _this, const InData& data, const Type* type) { static oatpp::Void deserializeArray(const Deserializer* _this, const InData& data, const Type* type) {
if(data.isNull) { if(data.isNull) {
return oatpp::Void(nullptr, type); return oatpp::Void(nullptr, type);

View File

@ -65,9 +65,9 @@ void Serializer::setSerializerMethods() {
setSerializerMethod(data::mapping::type::__class::AbstractEnum::CLASS_ID, &Serializer::serializeEnum); setSerializerMethod(data::mapping::type::__class::AbstractEnum::CLASS_ID, &Serializer::serializeEnum);
setSerializerMethod(data::mapping::type::__class::AbstractVector::CLASS_ID, &Serializer::serializeArray2<oatpp::AbstractVector>); setSerializerMethod(data::mapping::type::__class::AbstractVector::CLASS_ID, &Serializer::serializeArray<oatpp::AbstractVector>);
setSerializerMethod(data::mapping::type::__class::AbstractList::CLASS_ID, &Serializer::serializeArray2<oatpp::AbstractList>); setSerializerMethod(data::mapping::type::__class::AbstractList::CLASS_ID, &Serializer::serializeArray<oatpp::AbstractList>);
setSerializerMethod(data::mapping::type::__class::AbstractUnorderedSet::CLASS_ID, &Serializer::serializeArray2<oatpp::AbstractUnorderedSet>); setSerializerMethod(data::mapping::type::__class::AbstractUnorderedSet::CLASS_ID, &Serializer::serializeArray<oatpp::AbstractUnorderedSet>);
//// ////

View File

@ -30,6 +30,12 @@
#include <libpq-fe.h> #include <libpq-fe.h>
#if defined(WIN32) || defined(_WIN32)
#include <WinSock2.h>
#else
#include <arpa/inet.h>
#endif
namespace oatpp { namespace postgresql { namespace mapping { namespace oatpp { namespace postgresql { namespace mapping {
/** /**
@ -172,7 +178,7 @@ private:
} }
template<class Collection> template<class Collection>
static void serializeArray2(const Serializer* _this, OutputData& outData, const oatpp::Void& polymorph) { static void serializeArray(const Serializer* _this, OutputData& outData, const oatpp::Void& polymorph) {
if(!polymorph) { if(!polymorph) {
serNull(outData); serNull(outData);
@ -183,7 +189,7 @@ private:
const oatpp::Type* itemType = getArrayItemTypeAndDimensions(polymorph, meta.dimensions); const oatpp::Type* itemType = getArrayItemTypeAndDimensions(polymorph, meta.dimensions);
if(meta.dimensions.empty()) { if(meta.dimensions.empty()) {
throw std::runtime_error("[oatpp::postgresql::mapping::Serializer::serializeArray2()]: Error. " throw std::runtime_error("[oatpp::postgresql::mapping::Serializer::serializeArray()]: Error. "
"Invalid array."); "Invalid array.");
} }