mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 15:17:29 +00:00
Change JSONHandler::m to std::unique_ptr and declare Members in implementation file
This commit is contained in:
parent
8b05c550b3
commit
62f00b6d9c
@ -4,11 +4,29 @@
|
|||||||
#include <qpdf/QTC.hh>
|
#include <qpdf/QTC.hh>
|
||||||
#include <qpdf/QUtil.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() :
|
JSONHandler::JSONHandler() :
|
||||||
m(new Members())
|
m(new Members())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONHandler::~JSONHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JSONHandler::usage(std::string const& msg)
|
JSONHandler::usage(std::string const& msg)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ class JSONHandler
|
|||||||
public:
|
public:
|
||||||
// A QPDFUsage exception is thrown if there are any errors validating the JSON object.
|
// A QPDFUsage exception is thrown if there are any errors validating the JSON object.
|
||||||
JSONHandler();
|
JSONHandler();
|
||||||
~JSONHandler() = default;
|
~JSONHandler();
|
||||||
|
|
||||||
// Based on the type of handler, expect the object to be of a certain type. QPDFUsage is thrown
|
// 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
|
// otherwise. Multiple handlers may be registered, which allows the object to be of various
|
||||||
@ -55,49 +55,26 @@ class JSONHandler
|
|||||||
|
|
||||||
struct Handlers
|
struct Handlers
|
||||||
{
|
{
|
||||||
Handlers() :
|
Handlers() = default;
|
||||||
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)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
json_handler_t any_handler;
|
json_handler_t any_handler{nullptr};
|
||||||
void_handler_t null_handler;
|
void_handler_t null_handler{nullptr};
|
||||||
string_handler_t string_handler;
|
string_handler_t string_handler{nullptr};
|
||||||
string_handler_t number_handler;
|
string_handler_t number_handler{nullptr};
|
||||||
bool_handler_t bool_handler;
|
bool_handler_t bool_handler{nullptr};
|
||||||
json_handler_t dict_start_handler;
|
json_handler_t dict_start_handler{nullptr};
|
||||||
void_handler_t dict_end_handler;
|
void_handler_t dict_end_handler{nullptr};
|
||||||
json_handler_t array_start_handler;
|
json_handler_t array_start_handler{nullptr};
|
||||||
void_handler_t array_end_handler;
|
void_handler_t array_end_handler{nullptr};
|
||||||
void_handler_t final_handler;
|
void_handler_t final_handler{nullptr};
|
||||||
std::map<std::string, std::shared_ptr<JSONHandler>> dict_handlers;
|
std::map<std::string, std::shared_ptr<JSONHandler>> dict_handlers;
|
||||||
std::shared_ptr<JSONHandler> fallback_dict_handler;
|
std::shared_ptr<JSONHandler> fallback_dict_handler;
|
||||||
std::shared_ptr<JSONHandler> array_item_handler;
|
std::shared_ptr<JSONHandler> array_item_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Members
|
class Members;
|
||||||
{
|
|
||||||
friend class JSONHandler;
|
|
||||||
|
|
||||||
public:
|
std::unique_ptr<Members> m;
|
||||||
~Members() = default;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Members() = default;
|
|
||||||
Members(Members const&) = delete;
|
|
||||||
|
|
||||||
Handlers h;
|
|
||||||
};
|
|
||||||
std::shared_ptr<Members> m;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JSONHANDLER_HH
|
#endif // JSONHANDLER_HH
|
||||||
|
Loading…
Reference in New Issue
Block a user