X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fdeserializer.cc;h=929c3c12183fdf3c5f10ccee3cbb6e09a7a065ea;hp=4c3f8f2caab6a69cc049dc5e79affd8341c04cf6;hb=e1a8eee026993b860c557c87ec559c902a4b6a11;hpb=6dfcfbd4a612230f2037cf891dd98520cb80c997 diff --git a/src/deserializer.cc b/src/deserializer.cc index 4c3f8f2..929c3c1 100644 --- a/src/deserializer.cc +++ b/src/deserializer.cc @@ -38,7 +38,7 @@ namespace dc { -class deserializer_impl +class deserializer::deserializer_impl { public: deserializer_impl(const std::string& filePath, bool comments = false, @@ -72,9 +72,9 @@ public: void throwError() { unsigned char* errorMsg = yajl_get_error(hand, 0, 0, 0); - deserializer::exception error((char*)errorMsg); + deserializer::exception problem((char*)errorMsg); yajl_free_error(hand, errorMsg); - throw error; + throw problem; } @@ -114,11 +114,13 @@ public: static int parsedBeginMap(void* ctx) { ((deserializer_impl*)ctx)->parsed.push(new wrapped_dictionary); + return 1; } static int parsedMapKey(void* ctx, const unsigned char* value, unsigned length) { + // same thing as a string return parsedString(ctx, value, length); } @@ -180,7 +182,9 @@ public: private: void init(std::istream& input, bool deleteIn, bool comments, bool check) { - const yajl_callbacks callbacks = + // this has to be static because yajl actually does not copy it into its + // internal data structures but rather keeps a pointer to this + static const yajl_callbacks callbacks = { deserializer_impl::parsedNull, deserializer_impl::parsedBoolean, @@ -205,10 +209,13 @@ private: deserializer::deserializer(const std::string& filePath, bool comments, - bool check) : impl(new deserializer_impl(filePath, comments, check)) {} + bool check) : + // pass through + impl(new deserializer::deserializer_impl(filePath, comments, check)) {} deserializer::deserializer(std::istream& input, bool comments, bool check) : - impl(new deserializer_impl(input, comments, check)) {} + // pass through + impl(new deserializer::deserializer_impl(input, comments, check)) {} serializable_ptr deserializer::deserialize() @@ -235,9 +242,12 @@ serializable* deserializer::pullNext() void deserializer::pop() { + // pass through impl->parsed.pop(); } } // namespace dc +/** vim: set ts=4 sw=4 tw=80: *************************************************/ +