aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/qpdf/QPDF_Array.hh
blob: 8fb227da5c531511ad989a67ab4678cf05490475 (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
42
43
#ifndef QPDF_ARRAY_HH
#define QPDF_ARRAY_HH

#include <qpdf/QPDFValue.hh>

#include <qpdf/SparseOHArray.hh>
#include <list>
#include <vector>

class QPDF_Array: public QPDFValue
{
  public:
    virtual ~QPDF_Array() = default;
    static std::shared_ptr<QPDFValueProxy>
    create(std::vector<QPDFObjectHandle> const& items);
    static std::shared_ptr<QPDFValueProxy> create(SparseOHArray const& items);
    virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
    virtual std::string unparse();
    virtual JSON getJSON(int json_version);
    virtual void disconnect();

    int getNItems() const;
    QPDFObjectHandle getItem(int n) const;
    void getAsVector(std::vector<QPDFObjectHandle>&) const;

    void setItem(int, QPDFObjectHandle const&);
    void setFromVector(std::vector<QPDFObjectHandle> const& items);
    void insertItem(int at, QPDFObjectHandle const& item);
    void appendItem(QPDFObjectHandle const& item);
    void eraseItem(int at);

    // Helper methods for QPDF and QPDFObjectHandle -- these are
    // public methods since the whole class is not part of the public
    // API. Otherwise, these would be wrapped in accessor classes.
    void addExplicitElementsToList(std::list<QPDFObjectHandle>&) const;

  private:
    QPDF_Array(std::vector<QPDFObjectHandle> const& items);
    QPDF_Array(SparseOHArray const& items);
    SparseOHArray elements;
};

#endif // QPDF_ARRAY_HH