http::incoming::Response. Fix readBodyToDto method.

This commit is contained in:
lganzzzo 2020-05-24 00:38:55 +03:00
parent 44b17624b5
commit b32b905723
5 changed files with 18 additions and 18 deletions

View File

@ -59,7 +59,7 @@ public:
typedef C TemplateObjectClass;
public:
OATPP_DEFINE_OBJECT_WRAPPER_DEFAULTS(UnorderedMapObjectWrapper, TemplateObjectType, TemplateObjectClass)
OATPP_DEFINE_OBJECT_WRAPPER_DEFAULTS(UnorderedMapObjectWrapper, TemplateObjectType, TemplateObjectClass)
UnorderedMapObjectWrapper(std::initializer_list<std::pair<const Key, Value>> ilist)
: type::ObjectWrapper<TemplateObjectType, TemplateObjectClass>(std::make_shared<TemplateObjectType>(ilist))

View File

@ -58,7 +58,7 @@ public:
typedef C TemplateObjectClass;
public:
OATPP_DEFINE_OBJECT_WRAPPER_DEFAULTS(UnorderedSetObjectWrapper, TemplateObjectType, TemplateObjectClass)
OATPP_DEFINE_OBJECT_WRAPPER_DEFAULTS(UnorderedSetObjectWrapper, TemplateObjectType, TemplateObjectClass)
UnorderedSetObjectWrapper(std::initializer_list<T> ilist)
: type::ObjectWrapper<TemplateObjectType, TemplateObjectClass>(std::make_shared<TemplateObjectType>(ilist))

View File

@ -161,7 +161,7 @@ oatpp::Void Deserializer::deserializeFloat32(Deserializer* deserializer, parser:
(void) type;
if(caret.isAtText("null", true)){
return oatpp::Void(Float32::ObjectWrapper::Class::getType());
return oatpp::Void(Float32::Class::getType());
} else {
return Float32(caret.parseFloat32());
}
@ -173,7 +173,7 @@ oatpp::Void Deserializer::deserializeFloat64(Deserializer* deserializer, parser:
(void) type;
if(caret.isAtText("null", true)){
return oatpp::Void(Float64::ObjectWrapper::Class::getType());
return oatpp::Void(Float64::Class::getType());
} else {
return Float64(caret.parseFloat64());
}
@ -186,7 +186,7 @@ oatpp::Void Deserializer::deserializeBoolean(Deserializer* deserializer, parser:
(void) type;
if(caret.isAtText("null", true)){
return oatpp::Void(Boolean::ObjectWrapper::Class::getType());
return oatpp::Void(Boolean::Class::getType());
} else {
if(caret.isAtText("true", true)) {
return Boolean(true);
@ -194,7 +194,7 @@ oatpp::Void Deserializer::deserializeBoolean(Deserializer* deserializer, parser:
return Boolean(false);
} else {
caret.setError("[oatpp::parser::json::mapping::Deserializer::readBooleanValue()]: Error. 'true' or 'false' - expected.", ERROR_CODE_VALUE_BOOLEAN);
return oatpp::Void(Boolean::ObjectWrapper::Class::getType());
return oatpp::Void(Boolean::Class::getType());
}
}
@ -224,9 +224,9 @@ const data::mapping::type::Type* Deserializer::guessType(oatpp::parser::Caret& c
case '"':
return String::Class::getType();
case '{':
return oatpp::Fields<Any>::ObjectWrapper::Class::getType();
return oatpp::Fields<Any>::Class::getType();
case '[':
return oatpp::List<Any>::ObjectWrapper::Class::getType();
return oatpp::List<Any>::Class::getType();
case 't':
if(caret.isAtText("true")) return Boolean::Class::getType();
break;

View File

@ -118,17 +118,17 @@ public:
/**
* Read body stream, decode, and deserialize it as DTO Object (see [Data Transfer Object (DTO)](https://oatpp.io/docs/components/dto/)).
* @tparam Type - DTO object type.
* @tparam Wrapper - ObjectWrapper type.
* @param headers - Headers map. &id:oatpp::web::protocol::http::Headers;.
* @param bodyStream - pointer to &id:oatpp::data::stream::InputStream;.
* @param objectMapper - pointer to &id:oatpp::data::mapping::ObjectMapper;.
* @return - deserialized DTO object.
*/
template<class Type>
typename Type::ObjectWrapper decodeToDto(const Headers& headers,
data::stream::InputStream* bodyStream,
data::mapping::ObjectMapper* objectMapper) const {
return objectMapper->readFromString<Type>(decodeToString(headers, bodyStream));
template<class Wrapper>
Wrapper decodeToDto(const Headers& headers,
data::stream::InputStream* bodyStream,
data::mapping::ObjectMapper* objectMapper) const {
return objectMapper->readFromString<Wrapper>(decodeToString(headers, bodyStream));
}
/**

View File

@ -142,13 +142,13 @@ public:
/**
* Read body stream, decode, and deserialize it as DTO Object (see [Data Transfer Object (DTO)](https://oatpp.io/docs/components/dto/)).
* @tparam Type - DTO object type.
* @tparam Wrapper - ObjectWrapper type.
* @param objectMapper - `std::shared_ptr` to &id:oatpp::data::mapping::ObjectMapper;.
* @return - deserialized DTO object.
*/
template<class Type>
typename Type::ObjectWrapper readBodyToDto(oatpp::data::mapping::ObjectMapper* objectMapper) const {
return m_bodyDecoder->decodeToDto<Type>(m_headers, m_bodyStream.get(), objectMapper);
template<class Wrapper>
Wrapper readBodyToDto(oatpp::data::mapping::ObjectMapper* objectMapper) const {
return m_bodyDecoder->decodeToDto<Wrapper>(m_headers, m_bodyStream.get(), objectMapper);
}
// Async