X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FDeserializer.hh;h=cf99c2de3c966bc22d1ac8da7c95846c27ffaa7d;hp=8a771e86594db802ec04761090ebb6165517bca1;hb=f72400af4fa3e7b54dab154b5a2b6503a6f9af18;hpb=c2321281bf12a7efaedde930422c7ddbc92080d4 diff --git a/src/Moof/Deserializer.hh b/src/Moof/Deserializer.hh index 8a771e8..cf99c2d 100644 --- a/src/Moof/Deserializer.hh +++ b/src/Moof/Deserializer.hh @@ -40,15 +40,21 @@ #include +#include + namespace Mf { class Serializable; // forward declaration -typedef boost::shared_ptr SerializablePtr; +typedef boost::shared_ptr SerializableP; + class Deserializer { + class Impl; + boost::shared_ptr impl_; + public: /** @@ -77,7 +83,7 @@ public: * deserializer. */ - SerializablePtr deserialize(); + SerializableP deserialize(); /** * Used by serializable objects to parse themselves. These methods should @@ -110,15 +116,31 @@ public: * 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 impl_; };