#include <boost/shared_ptr.hpp>
+#include <Moof/Exception.hh>
+
namespace Mf {
class Serializable; // forward declaration
-typedef boost::shared_ptr<Serializable> SerializablePtr;
+typedef boost::shared_ptr<Serializable> SerializableP;
+
class Deserializer
{
+ class Impl;
+ boost::shared_ptr<Impl> impl_;
+
public:
/**
* deserializer.
*/
- SerializablePtr deserialize();
+ SerializableP deserialize();
/**
* Used by serializable objects to parse themselves. These methods should
* This exception is thrown upon deserialization errors.
*/
- struct Exception : std::runtime_error
+ struct Exception : public Mf::Exception
{
- explicit Exception(const std::string& what_arg) :
- std::runtime_error(what_arg) {}
+ enum
+ {
+ PARSING_FAILED = 1024
+ };
+
+ explicit Exception(unsigned error) :
+ Mf::Exception(error) {}
+
+ void raise()
+ {
+ throw *this;
+ }
+
+ const char* what() const throw()
+ {
+ switch (code)
+ {
+ case PARSING_FAILED:
+ return "parsing failed";
+ }
+ return Mf::Exception::what();
+ }
};
-
-private:
- class DeserializerImpl;
- boost::shared_ptr<DeserializerImpl> impl_;
};