File Information
Library: RemotingNG
Package: Serialization
Header: Poco/RemotingNG/Serializer.h
Description
The Serializer interface for transports.
Implementations of the Serializer interface must handle serialization of various message types (request, response, events), as well as basic types. Serialization of complex types is implemented by providing specializations of the TypeSerializer class template.
Inheritance
Direct Base Classes: SerializerBase
All Base Classes: SerializerBase
Known Derived Classes: Poco::RemotingNG::REST::RawSerializer, Poco::RemotingNG::REST::HeaderSerializer, Poco::RemotingNG::SOAP::Serializer, Poco::RemotingNG::REST::ScalarSerializer, Poco::RemotingNG::REST::FormSerializer, Poco::RemotingNG::REST::Serializer, BinarySerializer, Poco::RemotingNG::REST::PathSerializer, Poco::RemotingNG::JSONRPC::Serializer, Poco::RemotingNG::REST::JSONSerializer
Member Summary
Member Functions: pushAttribute, registerNamespace, serialize, serializeFaultMessage, serializeMessageBegin, serializeMessageEnd, serializeNullableBegin, serializeNullableEnd, serializeOptionalBegin, serializeOptionalEnd, serializeSequenceBegin, serializeSequenceEnd, serializeStructBegin, serializeStructEnd, setup, setupImpl
Inherited Functions: clearProperties, getProperty, hasProperty, popProperty, pushProperty, reset, resetImpl
Constructors
Serializer
Serializer();
Creates a Serializer.
Destructor
~Serializer
virtual ~Serializer();
Destroys the Serializer.
Member Functions
pushAttribute
virtual void pushAttribute(
const std::string & attrNamespace,
const std::string & attrName
);
For XML-based transports, this method allows for serialization of data either as element content (default) or attribute value.
The rule that serializers follow is to first call pushAttribute() for every variable to be serialized as attribute, then call serializeMessageBegin() or serializeStructBegin() for the element containing the attributes.
Example: The following code:
ser.pushAttribute("", "attr1"); ser.pushAttribute("", "attr2"); ser.serializeStructBegin("complexType"); ser.serialize("attr1", "foo"); ser.serialize("attr2", "bar"); ser.serialize("variable", 42); ser.serializeStructEnd("complexType");
will produce this XML fragment:
<complexType attr1="foo" attr2="bar"><variable>42</variable>...</complexType>
Should be overridden by subclasses supporting attributes. The default implementation does nothing.
registerNamespace
virtual void registerNamespace(
const std::string & namespc
);
For XML-based transports, this method allows for registration of a namespace which will be used by multiple following elements. This allows the Serializer to generate a namespace prefix declaration on an outer element, preventing the Serializer from generating a prefix declaration on any element in a sequence.
serialize
virtual void serialize(
const std::string & name,
Poco::Int8 value
) = 0;
Serialize an Int8.
serialize
virtual void serialize(
const std::string & name,
Poco::UInt8 value
) = 0;
Serialize an UInt8.
serialize
virtual void serialize(
const std::string & name,
Poco::Int16 value
) = 0;
Serialize an Int16.
serialize
virtual void serialize(
const std::string & name,
Poco::UInt16 value
) = 0;
Serialize an UInt16.
serialize
virtual void serialize(
const std::string & name,
Poco::Int32 value
) = 0;
Serialize an Int32.
serialize
virtual void serialize(
const std::string & name,
Poco::UInt32 value
) = 0;
Serialize an UInt32.
serialize
virtual void serialize(
const std::string & name,
long value
) = 0;
Serialize a long.
serialize
virtual void serialize(
const std::string & name,
unsigned long value
) = 0;
Serialize an unsigned long.
serialize
virtual void serialize(
const std::string & name,
Poco::Int64 value
) = 0;
Serialize an Int64.
serialize
virtual void serialize(
const std::string & name,
Poco::UInt64 value
) = 0;
Serialize an UInt64.
serialize
virtual void serialize(
const std::string & name,
bool value
) = 0;
Serialize a boolean.
serialize
virtual void serialize(
const std::string & name,
float value
) = 0;
Serialize a float.
serialize
virtual void serialize(
const std::string & name,
double value
) = 0;
Serialize a double.
serialize
virtual void serialize(
const std::string & name,
char value
) = 0;
Serialize a single character.
serialize
virtual void serialize(
const std::string & name,
const std::string & value
) = 0;
Serialize a std::string.
serialize
virtual void serialize(
const std::string & name,
const std::vector < char > & value
) = 0;
Serialize binary data.
serialize
virtual void serialize(
const std::string & name,
const Poco::DateTime & value
);
Serialize a Poco::DateTime.
The default implementation serializes to an ISO8601 string.
serialize
virtual void serialize(
const std::string & name,
const Poco::LocalDateTime & value
);
Serialize a Poco::LocalDateTime.
The default implementation serializes to an ISO8601 string.
serialize
virtual void serialize(
const std::string & name,
const Poco::Timestamp & value
);
Serialize a Poco::Timestamp.
The default implementation serializes to an ISO8601 string.
serialize
virtual void serialize(
const std::string & name,
const Poco::Timespan & value
);
Serialize a Poco::Timespan.
The default implementation serializes to a 64-bit integer containing the timespan in microseconds.
serialize
virtual void serialize(
const std::string & name,
const Poco::URI & value
);
Serialize a Poco::URI.
The default implementation serializes to string.
serialize
virtual void serialize(
const std::string & name,
const Poco::UUID & value
);
Serialize a Poco::URI.
The default implementation serializes to string.
serializeFaultMessage
virtual void serializeFaultMessage(
const std::string & name,
const Poco::Exception & exc
) = 0;
Serialize an exception message.
serializeMessageBegin
virtual void serializeMessageBegin(
const std::string & name,
SerializerBase::MessageType type
) = 0;
Begin serialization of a message.
serializeMessageEnd
virtual void serializeMessageEnd(
const std::string & name,
SerializerBase::MessageType type
) = 0;
End serialization of a message.
serializeNullableBegin
virtual void serializeNullableBegin(
const std::string & name,
bool isNull
) = 0;
Begin serialization of a Nullable or pointer which may be NULL.
If isNull is true, the call to serializeNullableBegin() must be immediately followed by a call to serializeNullableEnd().
serializeNullableEnd
virtual void serializeNullableEnd(
const std::string & name
) = 0;
End serialization of a Nullable or pointer which may be NULL.
serializeOptionalBegin
virtual void serializeOptionalBegin(
const std::string & name,
bool isSpecified
);
Begin serialization of an Optional.
If isSpecified is false, the call to serializeOptionalBegin() must be immediately followed by a call to serializeOptionalEnd().
The default implementation calls serializeNullableBegin().
serializeOptionalEnd
virtual void serializeOptionalEnd(
const std::string & name
);
End serialization of an Optional.
The default implementation calls serializeNullableEnd().
serializeSequenceBegin
virtual void serializeSequenceBegin(
const std::string & name,
Poco::UInt32 length
) = 0;
Begin serialization of a vector or other sequence.
Length contains the number of elements in the sequence.
serializeSequenceEnd
virtual void serializeSequenceEnd(
const std::string & name
) = 0;
End serialization of a vector.
serializeStructBegin
virtual void serializeStructBegin(
const std::string & name
) = 0;
Begin serialization of a complex (structured) object.
serializeStructEnd
virtual void serializeStructEnd(
const std::string & name
) = 0;
End serialization of a complex (structured) object.
setup
void setup(
std::ostream & ostr
);
Set up the Serializer for writing to the given output stream.
This must be called before any of the serialize*() methods.
setupImpl
virtual void setupImpl(
std::ostream & ostr
) = 0;
Set up the Serializer for writing to the given output stream.
It is guaranteed that reset was called prior to calling this method so the Serializer is in a clean state.