Poco::RemotingNG

class Deserializer

Library: RemotingNG
Package: Serialization
Header: Poco/RemotingNG/Deserializer.h

Description

The Deserializer interface for transports.

Implementations of the Deserializer interface must handle deserialization of various message types (request, response, events), as well as basic types. Deserialization of complex types is implemented by providing specializations of the TypeDeserializer class template.

Note that deserialize*() methods will generally return a bool and have a bool parameter isMandatory. These methods will return true if the respective element or value has been found and deserialized. If the element or value has not been found and isMandatory is true, an exception will be thrown. If isMandatory is false, false will be returned and the value will not be changed.

Inheritance

Direct Base Classes: SerializerBase

All Base Classes: SerializerBase

Known Derived Classes: Poco::RemotingNG::REST::FormDeserializer, Poco::RemotingNG::REST::HeaderDeserializer, Poco::RemotingNG::JSONRPC::Deserializer, Poco::RemotingNG::REST::Deserializer, Poco::RemotingNG::REST::JSONDeserializer, BinaryDeserializer, Poco::RemotingNG::REST::RawDeserializer, Poco::RemotingNG::REST::ScalarDeserializer, Poco::RemotingNG::REST::PathDeserializer, Poco::RemotingNG::SOAP::Deserializer

Member Summary

Member Functions: deserialize, deserializeMessageBegin, deserializeMessageEnd, deserializeNullableBegin, deserializeNullableEnd, deserializeOptionalBegin, deserializeOptionalEnd, deserializeSequenceBegin, deserializeSequenceEnd, deserializeStructBegin, deserializeStructEnd, findMessage, pushAttribute, setup, setupImpl

Inherited Functions: clearProperties, getProperty, hasProperty, popProperty, pushProperty, reset, resetImpl

Constructors

Deserializer

Deserializer();

Creates a Deserializer.

Destructor

~Deserializer virtual

virtual ~Deserializer();

Destroys the Deserializer.

Member Functions

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    Poco::Int8 & value
) = 0;

Deserialize an Int8.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    Poco::UInt8 & value
) = 0;

Deserialize an UInt8.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    Poco::Int16 & value
) = 0;

Deserialize an Int16.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    Poco::UInt16 & value
) = 0;

Deserialize an UInt16.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    Poco::Int32 & value
) = 0;

Deserialize an Int32.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    Poco::UInt32 & value
) = 0;

Deserialize an UInt32.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    long & value
) = 0;

Deserialize a long.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    unsigned long & value
) = 0;

Deserialize an unsigned long.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    float & value
) = 0;

Deserialize a float.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    double & value
) = 0;

Deserialize a double.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    bool & value
) = 0;

Deserialize a boolean.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    char & value
) = 0;

Deserialize a single character.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    std::string & value
) = 0;

Deserialize a std::string.

deserialize virtual

virtual bool deserialize(
    const std::string & name,
    bool isMandatory,
    std::vector < char > & value
) = 0;

Deserializes raw binary data.

deserializeMessageBegin virtual

virtual void deserializeMessageBegin(
    const std::string & name,
    SerializerBase::MessageType type
) = 0;

Begin deserialization of a message.

If the message is a fault, it will be deserialized an an appropriate exception will be thrown.

deserializeMessageEnd virtual

virtual void deserializeMessageEnd(
    const std::string & name,
    SerializerBase::MessageType type
) = 0;

End deserialization of a message.

deserializeNullableBegin virtual

virtual bool deserializeNullableBegin(
    const std::string & name,
    bool isMandatory,
    bool & isNull
) = 0;

Begin deserialization of a Nullable or pointer which may be NULL.

Returns true if the element with the given name was found. If the element was not found and isMandatory is true, an exception may be thrown (depending on whether the serialization format can distinguish between a NULL and a missing value). IsNull will be set accordingly.

Note that if this method returns false or sets isNull to true, deserializeNullableEnd() will not be called.

deserializeNullableEnd virtual

virtual void deserializeNullableEnd(
    const std::string & name
) = 0;

End deserialization of a Nullable or pointer which may be NULL.

deserializeOptionalBegin virtual

virtual bool deserializeOptionalBegin(
    const std::string & name,
    bool isMandatory,
    bool & isSpecified
);

Begin deserialization of an Optional.

Returns true if the element with the given name was found. If the element was not found and isMandatory is true, an exception may be thrown (depending on whether the serialization format can distinguish between a NULL and a missing value). IsSpecified will be set accordingly.

Note that if this method returns false or sets isSpecified to false, deserializeOptionalEnd() will not be called.

The default implementation calls deserializeNullableBegin().

deserializeOptionalEnd virtual

virtual void deserializeOptionalEnd(
    const std::string & name
);

End deserialization of an Optional.

The default implementation calls deserializeNullableEnd().

deserializeSequenceBegin virtual

virtual bool deserializeSequenceBegin(
    const std::string & name,
    bool isMandatory,
    Poco::UInt32 & lengthHint
) = 0;

Begin deserialization of a vector or other sequence.

Returns true if the element with the given name was found. If the element was not found and isMandatory is true, an exception may be thrown (depending on whether the serialization format can distinguish between an empty and a missing sequence).

Note that if this method returns false, deserializeVectorBegin() will not be called. If sizeHint is greater than 0, it will be used to reserve space in the result vector.

deserializeSequenceEnd virtual

virtual void deserializeSequenceEnd(
    const std::string & name
) = 0;

End deserialization of a vector or other sequence.

deserializeStructBegin virtual

virtual bool deserializeStructBegin(
    const std::string & name,
    bool isMandatory
) = 0;

Begin deserialization of a complex (structured) object.

Returns true if the element with the given name was found. If the element was not found and isMandatory is true, an exception will be thrown.

Note that if this method returns false, deserializeComplexTypeEnd() will not be called.

deserializeStructEnd virtual

virtual void deserializeStructEnd(
    const std::string & name
) = 0;

End deserialization of a complex (structured) object.

findMessage virtual

virtual SerializerBase::MessageType findMessage(
    std::string & name
) = 0;

Reads from the stream until the message has been found. Returns the type of the message and the name of the found message.

Used on the skeleton side to deserialize incoming requests. Will not be called by a Proxy when deserializing a reply.

The name returned by this method must be passed to deserializeMessageBegin().

This method must be implemented in such a way that it can be called multiple times in succession, until deserializeMessageBegin() is called.

pushAttribute virtual

virtual void pushAttribute(
    const std::string & attrNamespace,
    const std::string & attrName,
    bool isMandatory
);

For XML-based transports, this method allows for deserialization of data either as element content (default) or attribute value.

The rule that deserializers follow is to first call pushAttribute() for every variable to be deserialized as attribute, then call deserializeMessageBegin() or deserializeStructStart() for the element containing the attributes.

Example: The following code:

ser.pushAttribute("", "attr1", true);
ser.pushAttribute("", "attr2", true);
ser.deserializeStructBegin("complexType", true);
ser.deserialize("attr1", attr1, true); 
ser.deserialize("attr2", attr2, true); 
ser.deserialize("variable", variable, true); 
ser.deserializeStructEnd("complexType"); 

will read this XML fragment:

<complexType attr1="foo" attr2="bar"><variable>42</variable>...</complexType> 

Should be overridden by subclasses supporting attributes. The default implementation does nothing.

setup inline

void setup(
    std::istream & istr
);

Set up the Deserializer for reading from the given input stream.

This must be called before any of the deserialize*() methods.

setupImpl protected virtual

virtual void setupImpl(
    std::istream & inStream
) = 0;

Set up the Deserializer for reading from the given input stream.

It is guaranteed that reset was called prior to calling this method so the Serializer is in a clean state.