Library: Remoting
Package: Serialize
Header: Poco/Remoting/Deserializer.h
Deserializer interface for transports. Handles primitive data types deserialization.
Known Derived Classes: Poco::Remoting::Binary::Deserializer, Poco::Remoting::JSON::Deserializer, Poco::Remoting::SoapLite::Deserializer
Member Functions: deserialize, deserializeComplexTypeEnd, deserializeComplexTypeStart, deserializeNullElement, deserializeReplyEnd, deserializeReplyStart, deserializeRequestEnd, deserializeRequestStart, deserializeVectorBegin, deserializeVectorEnd, detectReplyName, detectRequestName, getProperty, hasProperty, popProperty, pushAttribute, pushProperty, reset, resetImpl, setInputStream, setInputStreamImpl
Deserializer();
Creates the Deserializer.
virtual ~Deserializer();
Destroys the Deserializer.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
virtual bool deserialize(
const std::string & name,
bool isMandatory,
std::vector < char > & val
) = 0;
Deserializes raw binary data. 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.
virtual void deserializeComplexTypeEnd(
const std::string & name
) = 0;
Called to indicate that deserialization of a complex data type is over.
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.
virtual void deserializeNullElement(
const std::string & name
) = 0;
virtual void deserializeReplyEnd(
const std::string & mi
) = 0;
Called to indicate that deserialization of a method is over.
virtual void deserializeReplyStart(
const std::string & methodName
) = 0;
Throws an exception if the methodName doesn't match. Used for response deserialization.
virtual void deserializeRequestEnd(
const std::string & mi
) = 0;
Called to indicate that deserialization of a method is over.
virtual void deserializeRequestStart(
const std::string & methodName
) = 0;
Throws an exception if the methodName doesn't match. Used for response deserialization.
virtual bool deserializeVectorBegin(
const std::string & name,
bool isMandatory,
Poco::UInt32 & sizeHint
) = 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.
If sizeHint is greater than 0, it will be used to reserve space in the result vector.
virtual void deserializeVectorEnd(
const std::string & name
) = 0;
Called after the last name of a vector was deserialized.
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.
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.
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.
std::string getProperty(
const std::string & name,
const std::string & deflt
);
Gets the property with the given name from its stack. Returns the default value if the stack is empty.
bool hasProperty(
const std::string & name
) const;
Returns true if a property exists.
void popProperty(
const std::string & name
);
Removes the property with the given name from its stack. Throws an exception if the stack is empty.
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");
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.
void reset();
Resets the deserializer state to uninitialized.
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.
virtual void resetImpl() = 0;
Implements a reset of the deserializer.
virtual void setInputStreamImpl(
std::istream & inStream
) = 0;
Implements setInputStream.