# Serializer.hpp
This File On Github
Ask A Question
API: latest
module: oatpp-mongo
#include "oatpp-mongo/bson/mapping/Serializer.hpp"
# Serializer
BSON Serializer. Serializes oatpp DTO object to bson. See Data Transfer Object(DTO) component.
namespace oatpp { namespace mongo { namespace bson { namespace mapping {
class Serializer {}
}}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | Serializer | Constructor. |
void | setSerializerMethod | Set serializer method for type. |
void | serializeToStream | Serialize object to stream. |
const std::shared_ptr<Config>& | getConfig | Get serializer config. |
# Serializer::Serializer
Constructor.
- @param config - serializer config.
Serializer(const std::shared_ptr<Config>& config = std::make_shared<Config>())
# Serializer::setSerializerMethod
Set serializer method for type.
- @param classId - oatpp::data::mapping::type::ClassId.
- @param method -
typedef void (*SerializerMethod)(Serializer*, data::stream::ConsistentOutputStream*, const oatpp::Void)
.
void setSerializerMethod(const data::mapping::type::ClassId& classId, SerializerMethod method)
# Serializer::serializeToStream
Serialize object to stream.
- @param stream - oatpp::data::stream::ConsistentOutputStream.
- @param polymorph - DTO as oatpp::Void.
void serializeToStream(data::stream::ConsistentOutputStream* stream, const oatpp::Void& polymorph)
# Serializer::getConfig
Get serializer config.
- @return
const std::shared_ptr<Config>& getConfig()
# Serializer::Config
Serializer config.
namespace oatpp { namespace mongo { namespace bson { namespace mapping {
class Serializer {
class Config : public oatpp::base::Countable {}
};
}}}}
# Fields
Type | Name | Summary |
---|---|---|
bool | includeNullFields | Include fields with value == nullptr into serialized bson. |
bool | throwOnUnknownTypes | If true - insert string "<unknown-type>" in bson field value in case unknown field found. Fail if false . Known types for this serializer are:(String, Int8, Int16, Int32, Int64, Float32, Float64, Boolean, DTOs, List, Fields). |
std::vector<std::string> | enableInterpretations | Enable type interpretations. |
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | Config | Constructor. |
std::shared_ptr<Config> | createShared | Create shared config. |
# Serializer::Config::includeNullFields
Include fields with value == nullptr into serialized bson.
bool includeNullFields = true
# Serializer::Config::throwOnUnknownTypes
If true
- insert string "<unknown-type>"
in bson field value in case unknown field found. Fail if false
. Known types for this serializer are:
(String, Int8, Int16, Int32, Int64, Float32, Float64, Boolean, DTOs, List, Fields).
bool throwOnUnknownTypes = true
# Serializer::Config::enableInterpretations
Enable type interpretations.
std::vector<std::string> enableInterpretations =
# Serializer::Config::Config
Constructor.
Config()
# Serializer::Config::createShared
Create shared config.
- @return -
std::shared_ptr
to Config.
static std::shared_ptr<Config> createShared()