aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/qpdf/QPDF_Dictionary.hh
blob: 5f3e54faad6559cc58202b0c2926a5291e0742f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef QPDF_DICTIONARY_HH
#define QPDF_DICTIONARY_HH

#include <qpdf/QPDFValue.hh>

#include <map>
#include <set>

#include <qpdf/QPDFObjectHandle.hh>

class QPDF_Dictionary: public QPDFValue
{
  public:
    virtual ~QPDF_Dictionary() = default;
    static std::shared_ptr<QPDFValueProxy>
    create(std::map<std::string, QPDFObjectHandle> const& items);
    virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
    virtual std::string unparse();
    virtual JSON getJSON(int json_version);
    virtual void reset();

    // 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();
    std::map<std::string, QPDFObjectHandle> const& getAsMap() const;

    // 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);
    // Remove key, doing nothing if key does not exist
    void removeKey(std::string const& key);

  private:
    QPDF_Dictionary(std::map<std::string, QPDFObjectHandle> const& items);
    std::map<std::string, QPDFObjectHandle> items;
};

#endif // QPDF_DICTIONARY_HH