2018-08-12 18:07:22 +00:00
|
|
|
#ifndef QPDF_ARRAY_HH
|
|
|
|
#define QPDF_ARRAY_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
|
|
|
|
2023-03-29 18:52:03 +00:00
|
|
|
#include <map>
|
2008-04-29 12:55:25 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
class QPDF_Array: public QPDFValue
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
2024-01-09 15:19:48 +00:00
|
|
|
private:
|
|
|
|
struct Sparse
|
|
|
|
{
|
|
|
|
int size{0};
|
|
|
|
std::map<int, std::shared_ptr<QPDFObject>> elements;
|
|
|
|
};
|
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
public:
|
2023-06-01 14:21:32 +00:00
|
|
|
~QPDF_Array() override = default;
|
2022-06-27 16:50:35 +00:00
|
|
|
static std::shared_ptr<QPDFObject> create(std::vector<QPDFObjectHandle> const& items);
|
2022-12-19 11:41:09 +00:00
|
|
|
static std::shared_ptr<QPDFObject>
|
2023-03-26 19:02:49 +00:00
|
|
|
create(std::vector<std::shared_ptr<QPDFObject>>&& items, bool sparse);
|
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;
|
2012-06-18 20:38:59 +00:00
|
|
|
|
2023-03-24 12:58:36 +00:00
|
|
|
int
|
|
|
|
size() const noexcept
|
|
|
|
{
|
2024-01-09 15:19:48 +00:00
|
|
|
return sp ? sp->size : int(elements.size());
|
2023-03-24 12:58:36 +00:00
|
|
|
}
|
2023-03-24 15:01:40 +00:00
|
|
|
QPDFObjectHandle at(int n) const noexcept;
|
2023-01-01 12:47:03 +00:00
|
|
|
bool setAt(int n, QPDFObjectHandle const& oh);
|
2023-01-02 19:49:42 +00:00
|
|
|
std::vector<QPDFObjectHandle> getAsVector() const;
|
2012-06-18 20:38:59 +00:00
|
|
|
void setFromVector(std::vector<QPDFObjectHandle> const& items);
|
2022-12-10 19:48:07 +00:00
|
|
|
bool insert(int at, QPDFObjectHandle const& item);
|
2022-12-10 19:05:12 +00:00
|
|
|
void push_back(QPDFObjectHandle const& item);
|
2022-12-12 13:29:52 +00:00
|
|
|
bool erase(int at);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
private:
|
2023-03-29 18:52:03 +00:00
|
|
|
QPDF_Array();
|
|
|
|
QPDF_Array(QPDF_Array const&);
|
2022-06-16 16:45:04 +00:00
|
|
|
QPDF_Array(std::vector<QPDFObjectHandle> const& items);
|
2023-03-26 19:02:49 +00:00
|
|
|
QPDF_Array(std::vector<std::shared_ptr<QPDFObject>>&& items, bool sparse);
|
2022-11-17 17:35:13 +00:00
|
|
|
|
|
|
|
void checkOwnership(QPDFObjectHandle const& item) const;
|
|
|
|
|
2024-01-09 15:19:48 +00:00
|
|
|
std::unique_ptr<Sparse> sp;
|
2023-03-25 18:23:39 +00:00
|
|
|
std::vector<std::shared_ptr<QPDFObject>> elements;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // QPDF_ARRAY_HH
|