2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Change JSONHandler::m to std::unique_ptr and declare Members in implementation file

This commit is contained in:
m-holger 2023-05-29 14:35:45 +01:00
parent 8b05c550b3
commit 62f00b6d9c
2 changed files with 32 additions and 37 deletions

View File

@ -4,11 +4,29 @@
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
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)
{

View File

@ -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<std::string, std::shared_ptr<JSONHandler>> dict_handlers;
std::shared_ptr<JSONHandler> fallback_dict_handler;
std::shared_ptr<JSONHandler> 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<Members> m;
std::unique_ptr<Members> m;
};
#endif // JSONHANDLER_HH