]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Serializer.hh
converted json sequences to lua
[chaz/yoink] / src / Moof / Serializer.hh
index 7d54834fb01fb4a1e3773ef26afdfe1a8ee30511..4329e6f9a0c99b615ad25c67d727379d1b41af46 100644 (file)
 
 #include <boost/shared_ptr.hpp>
 
+#include <Moof/Exception.hh>
+
 
 namespace Mf {
 
 
 class Serializer
 {
+       class Impl;
+       boost::shared_ptr<Impl> impl_;
+
 public:
 
        /**
@@ -95,19 +100,45 @@ public:
 
        void flush();
 
+
        /**
         * This exception is thrown for serializer-related exceptional errors.
         */
 
-       struct Exception : std::runtime_error
+       struct Exception : public Mf::Exception
        {
-               explicit Exception(const std::string& what_arg) :
-                       std::runtime_error(what_arg) {}
+               enum
+               {
+                       ARCHIVE_TERMINATED              = 1024,
+                       KEYS_MUST_BE_STRINGS    = 1025,
+                       RECURSION_TOO_DEEP              = 1026,
+                       ALREADY_FAILED                  = 1027,
+               };
+
+               explicit Exception(unsigned error) :
+                       Mf::Exception(error) {}
+
+               void raise()
+               {
+                       throw *this;
+               }
+
+               const char* what() const throw()
+               {
+                       switch (code)
+                       {
+                               case ARCHIVE_TERMINATED:
+                                       return "archive is already terminated";
+                               case KEYS_MUST_BE_STRINGS:
+                                       return "map keys must be strings";
+                               case RECURSION_TOO_DEEP:
+                                       return "generator recursion too deep";
+                               case ALREADY_FAILED:
+                                       return "generator already errored out";
+                       }
+                       return Mf::Exception::what();
+               }
        };
-
-private:
-       class SerializerImpl;
-       boost::shared_ptr<SerializerImpl> impl_;
 };
 
 } // namespace Mf
This page took 0.024281 seconds and 4 git commands to generate.