Poco::Remoting

class Deserializer

Library: Remoting
Package: Serialize
Header: Poco/Remoting/Deserializer.h

Description

Deserializer interface for transports. Handles primitive data types deserialization.

Inheritance

Known Derived Classes: Poco::Netconf::Deserializer, Poco::Remoting::Binary::Deserializer, Poco::Remoting::SoapLite::Deserializer

Member Summary

Member Functions: deserialize, deserializeComplexTypeEnd, deserializeComplexTypeStart, deserializeNullElement, deserializeReplyEnd, deserializeReplyStart, deserializeRequestEnd, deserializeRequestStart, deserializeVectorBegin, deserializeVectorEnd, detectReplyName, detectRequestName, getProperty, hasProperty, popProperty, pushAttribute, pushProperty, reset, resetImpl, setInputStream, setInputStreamImpl

Constructors

Deserializer

Deserializer();

Creates the Deserializer.

Destructor

~Deserializer virtual

virtual ~Deserializer();

Destroys the Deserializer.

Member Functions

deserialize virtual

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

Deserializes an Int8. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an UInt8. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an Int16. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an UInt16. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an Int32. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an UInt32. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes a long. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an unsigned long. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an Int64. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes an UInt64. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes a float. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes a double. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes a boolean. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes a single character. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserialize virtual

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

Deserializes a string. Returns true if the element was found. If no value was present for the element it will also return true but will not change val! If not found and isMandatory is true, an exception is thrown.

deserializeComplexTypeEnd virtual

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

Called to indicate that deserialization of a complex data type is over.

deserializeComplexTypeStart virtual

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

Returns true if the complex type was found. If not found and isMandatory is true, an exception is thrown. Note that if this method returns false, the correspondign deserializeComplexTypeEnd method will never be called.

deserializeNullElement virtual

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

deserializeReplyEnd virtual

virtual void deserializeReplyEnd(
    const std::string & mi
) = 0;

Called to indicate that deserialization of a method is over.

deserializeReplyStart virtual

virtual void deserializeReplyStart(
    const std::string & methodName
) = 0;

Throws an exception if the methodName doesn't match. Used for response deserialization.

deserializeRequestEnd virtual

virtual void deserializeRequestEnd(
    const std::string & mi
) = 0;

Called to indicate that deserialization of a method is over.

deserializeRequestStart virtual

virtual void deserializeRequestStart(
    const std::string & methodName
) = 0;

Throws an exception if the methodName doesn't match. Used for response deserialization.

deserializeVectorBegin virtual

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

Called before the first element of a vector is deserialized. Returns false if no vector is present. In this case deserializeVectorEnd will NOT be called.

deserializeVectorEnd virtual

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

Called after the last name of a vector was deserialized.

detectReplyName virtual

virtual const std::string & detectReplyName() = 0;

Deserializes until the method name is found, then returns the name. Used on the skeleton side to deserialize incoming requests. You still must call deserializeMethodStart when using this method.

detectRequestName virtual

virtual const std::string & detectRequestName() = 0;

Deserializes until the method name is found, then returns the name. Used on the skeleton side to deserialize incoming requests. You still must call deserializeMethodStart when using this method.

getProperty

const std::string & getProperty(
    const std::string & name
) const;

Gets the property with the given name from its stack. Throws an exception if the stack is empty.

hasProperty

bool hasProperty(
    const std::string & name
) const;

Returns true if a property exists.

popProperty

void popProperty(
    const std::string & name
);

Removes the property with the given name from its stack. Throws an exception if the stack is empty.

pushAttribute virtual

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

Note that for XML based transports, one must distinguish between elements and attributes. The rule that serializers follow is to first do pushAttributes, then they will call the serializeRequest/-Reply method that the attributes belong to. The way to resolve this in non-XML serializers is to write the request/reply start element first, then write the attributes as sub-elements of the request/reply, followed by the complex data end element. Thus a deserializer follows the same rule. The pushAttribute method is used to inform the deserializer which attributes it should expect with a complex type (this is pretty much redundant but allows the deserializer to check if the namespace of the attribute matches and throw an error right during element deserialization. Note that non-XML transport that do not support namespaces can safely provide an empty implementation for this method). Apart from that, attributes are treated as normal elements. Example:

<somecomplexdata attr1="val1" attr2="val2"/>

ser.pushAttribute("", "attr1", "val1");
ser.pushAttribute("", "attr2", "val2");
ser.serializeRequestStart("somecomplexdata");
ser.serializeRequestEnd("somecomplexdata");

deser.pushAttribute("", "attr1", true);
deser.pushAttribute("", "attr2", true);
deser.deserializeRequestStart(in, "somecomplexdata");
std::string attr1Val, attr2Val;
deser.deserialize("attr1", true, attr1Val);
deser.deserialize("attr2", true, attr2Val);
deser.deserializeRequestEnd("somecomplexdata");

pushProperty

void pushProperty(
    const std::string & name,
    const std::string & value
);

To better support transports which require additional information, one is allowed to set properties. Especially useful for XML based transports where namespaces, attributes etc must be supported. For each property a stack is maintained.

reset inline

void reset();

Resets the deserializer state to uninitialized.

setInputStream inline

void setInputStream(
    std::istream & inStream
);

Re-/sets the input stream. Calls reset, followed by setInputStreamImpl. Required before one can use any of the other deserializer methods. Call reset to remove the inStream manually or simply call setInputStream again with a new stream.

resetImpl protected virtual

virtual void resetImpl() = 0;

Implements a reset of the deserializer.

setInputStreamImpl protected virtual

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

Implements setInputStream.