ObjectMapper.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/data/mapping/ObjectMapper.hpp"

ObjectMapper

Abstract ObjectMapper class.

namespace oatpp { namespace data { namespace mapping { 
  class ObjectMapper {}
}}}

Methods

Return Type Name Summary
[none] ObjectMapper Constructor.
const Info& getInfo Get ObjectMapper metadata.
void write Serialize object to stream. Implement this method.
mapping::type::AbstractObjectWrapper read Deserialize object. Implement this method.
oatpp::String writeToString Serialize object to String.
Class::ObjectWrapper readFromCaret Deserialize object.
Class::ObjectWrapper readFromString Deserialize object.

ObjectMapper::ObjectMapper

Constructor.

  • @param info - Metadata for ObjectMapper.

ObjectMapper(const Info& info)

ObjectMapper::getInfo

Get ObjectMapper metadata.

  • @return - ObjectMapper metadata.

const Info& getInfo() const

ObjectMapper::write

Serialize object to stream. Implement this method.

virtual void write(const std::shared_ptr<oatpp::data::stream::OutputStream>& stream,
                   const type::AbstractObjectWrapper& variant) const = 0

ObjectMapper::read

Deserialize object. Implement this method.

virtual mapping::type::AbstractObjectWrapper read(oatpp::parser::Caret& caret,
                                                  const mapping::type::Type* const type) const = 0

ObjectMapper::writeToString

Serialize object to String.

  • @param variant - Object to serialize.
  • @return - serialized object as oatpp::String.

oatpp::String writeToString(const type::AbstractObjectWrapper& variant) const

ObjectMapper::readFromCaret

Deserialize object. If nullptr is returned - check caret.getError()

  • @tparam Class - object class.
  • @param caret - oatpp::parser::Caret over serialized buffer.
  • @return - deserialized Object.
  • @throws - depends on implementation.

template<class Class>
typename Class::ObjectWrapper readFromCaret(oatpp::parser::Caret& caret) const

ObjectMapper::readFromString

Deserialize object.

  • @tparam Class - object class.
  • @param str - serialized data.
  • @return - deserialized Object.
  • @throws - oatpp::parser::ParsingError
  • @throws - depends on implementation.

template<class Class>
typename Class::ObjectWrapper readFromString(const oatpp::String& str) const

ObjectMapper::Info

Metadata for ObjectMapper.

namespace oatpp { namespace data { namespace mapping { 
  class ObjectMapper {
    class Info {}
  };
}}}

Fields

Type Name Summary
const char* const http_content_type Value for Content-Type http header when DTO is serialized via specified ObjectMapper.

Methods

Return Type Name Summary
[none] Info Constructor.

ObjectMapper::Info::http_content_type

Value for Content-Type http header when DTO is serialized via specified ObjectMapper.

const char* const http_content_type

ObjectMapper::Info::Info

Constructor.

  • @param _http_content_type

Info(const char* _http_content_type)
  : http_content_type(_http_content_type)