2018-08-12 18:07:22 +00:00
|
|
|
#ifndef QPDF_DICTIONARY_HH
|
|
|
|
#define QPDF_DICTIONARY_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
#include <qpdf/QPDFValue.hh>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include <qpdf/QPDFObjectHandle.hh>
|
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
class QPDF_Dictionary: public QPDFValue
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-06-01 14:21:32 +00:00
|
|
|
~QPDF_Dictionary() override = default;
|
2022-06-27 16:50:35 +00:00
|
|
|
static std::shared_ptr<QPDFObject> create(std::map<std::string, QPDFObjectHandle> const& items);
|
2022-12-19 19:20:36 +00:00
|
|
|
static std::shared_ptr<QPDFObject> create(std::map<std::string, QPDFObjectHandle>&& items);
|
2023-06-01 14:21:32 +00:00
|
|
|
std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
|
|
|
|
std::string unparse() override;
|
2024-02-09 13:09:08 +00:00
|
|
|
void writeJSON(int json_version, JSON::Writer& p) override;
|
2023-06-01 14:21:32 +00:00
|
|
|
void disconnect() override;
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
// hasKey() and getKeys() treat keys with null values as if they aren't there. getKey() returns
|
|
|
|
// null for the value of a non-existent key. This is as per the PDF spec.
|
|
|
|
bool hasKey(std::string const&);
|
|
|
|
QPDFObjectHandle getKey(std::string const&);
|
|
|
|
std::set<std::string> getKeys();
|
2011-08-10 17:33:58 +00:00
|
|
|
std::map<std::string, QPDFObjectHandle> const& getAsMap() const;
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2022-04-24 13:31:32 +00:00
|
|
|
// If value is null, remove key; otherwise, replace the value of key, adding it if it does not
|
|
|
|
// exist.
|
|
|
|
void replaceKey(std::string const& key, QPDFObjectHandle value);
|
2008-04-29 12:55:25 +00:00
|
|
|
// Remove key, doing nothing if key does not exist
|
|
|
|
void removeKey(std::string const& key);
|
|
|
|
|
|
|
|
private:
|
2022-06-16 16:45:04 +00:00
|
|
|
QPDF_Dictionary(std::map<std::string, QPDFObjectHandle> const& items);
|
2022-12-19 19:20:36 +00:00
|
|
|
QPDF_Dictionary(std::map<std::string, QPDFObjectHandle>&& items);
|
2008-04-29 12:55:25 +00:00
|
|
|
std::map<std::string, QPDFObjectHandle> items;
|
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // QPDF_DICTIONARY_HH
|