diff --git a/libqpdf/JSONHandler.cc b/libqpdf/JSONHandler.cc index b5c7c35d..d6021935 100644 --- a/libqpdf/JSONHandler.cc +++ b/libqpdf/JSONHandler.cc @@ -4,11 +4,29 @@ #include #include +class JSONHandler::Members +{ + friend class JSONHandler; + + public: + ~Members() = default; + + private: + Members() = default; + Members(Members const&) = delete; + + Handlers h; +}; + JSONHandler::JSONHandler() : m(new Members()) { } +JSONHandler::~JSONHandler() +{ +} + void JSONHandler::usage(std::string const& msg) { diff --git a/libqpdf/qpdf/JSONHandler.hh b/libqpdf/qpdf/JSONHandler.hh index 8fdcaee6..6439ff12 100644 --- a/libqpdf/qpdf/JSONHandler.hh +++ b/libqpdf/qpdf/JSONHandler.hh @@ -16,7 +16,7 @@ class JSONHandler public: // A QPDFUsage exception is thrown if there are any errors validating the JSON object. JSONHandler(); - ~JSONHandler() = default; + ~JSONHandler(); // Based on the type of handler, expect the object to be of a certain type. QPDFUsage is thrown // otherwise. Multiple handlers may be registered, which allows the object to be of various @@ -55,49 +55,26 @@ class JSONHandler struct Handlers { - Handlers() : - any_handler(nullptr), - null_handler(nullptr), - string_handler(nullptr), - number_handler(nullptr), - bool_handler(nullptr), - dict_start_handler(nullptr), - dict_end_handler(nullptr), - array_start_handler(nullptr), - array_end_handler(nullptr), - final_handler(nullptr) - { - } + Handlers() = default; - json_handler_t any_handler; - void_handler_t null_handler; - string_handler_t string_handler; - string_handler_t number_handler; - bool_handler_t bool_handler; - json_handler_t dict_start_handler; - void_handler_t dict_end_handler; - json_handler_t array_start_handler; - void_handler_t array_end_handler; - void_handler_t final_handler; + json_handler_t any_handler{nullptr}; + void_handler_t null_handler{nullptr}; + string_handler_t string_handler{nullptr}; + string_handler_t number_handler{nullptr}; + bool_handler_t bool_handler{nullptr}; + json_handler_t dict_start_handler{nullptr}; + void_handler_t dict_end_handler{nullptr}; + json_handler_t array_start_handler{nullptr}; + void_handler_t array_end_handler{nullptr}; + void_handler_t final_handler{nullptr}; std::map> dict_handlers; std::shared_ptr fallback_dict_handler; std::shared_ptr array_item_handler; }; - class Members - { - friend class JSONHandler; + class Members; - public: - ~Members() = default; - - private: - Members() = default; - Members(Members const&) = delete; - - Handlers h; - }; - std::shared_ptr m; + std::unique_ptr m; }; #endif // JSONHANDLER_HH