2024-02-18 01:42:47 +00:00
|
|
|
#include <qpdf/ObjTable.hh>
|
|
|
|
|
|
|
|
struct Test
|
|
|
|
{
|
2024-08-31 19:15:19 +00:00
|
|
|
Test() = default;
|
|
|
|
Test(int value) :
|
|
|
|
value(value)
|
|
|
|
{
|
|
|
|
}
|
2024-02-18 01:42:47 +00:00
|
|
|
int value{0};
|
|
|
|
};
|
|
|
|
|
|
|
|
class Table: public ObjTable<Test>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Table()
|
|
|
|
{
|
2024-08-31 13:29:15 +00:00
|
|
|
resize(5);
|
2024-02-18 01:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
test()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 10; ++i) {
|
|
|
|
(*this)[i].value = 2 * i;
|
|
|
|
(*this)[1000 + i].value = 2 * (1000 + i);
|
|
|
|
}
|
2024-08-31 13:29:15 +00:00
|
|
|
for (int i: {50, 60, 70, 98, 99, 100, 101, 150, 198, 199, 200, 201}) {
|
|
|
|
(*this)[i].value = 2 * i;
|
|
|
|
}
|
|
|
|
resize(100);
|
2024-08-31 19:15:19 +00:00
|
|
|
for (int i: {1, 99, 100, 105, 110, 120, 205, 206, 207, 210}) {
|
2024-08-31 13:29:15 +00:00
|
|
|
(*this)[i].value = 3 * i;
|
|
|
|
}
|
|
|
|
resize(200);
|
2024-02-18 01:42:47 +00:00
|
|
|
|
2024-08-31 19:15:19 +00:00
|
|
|
for (int i = 1; i < 10; ++i) {
|
|
|
|
emplace_back(i);
|
|
|
|
}
|
|
|
|
|
2024-02-18 01:42:47 +00:00
|
|
|
forEach([](auto i, auto const& item) -> void {
|
2024-08-31 13:29:15 +00:00
|
|
|
if (item.value) {
|
|
|
|
std::cout << std::to_string(i) << " : " << std::to_string(item.value) << "\n";
|
|
|
|
}
|
2024-02-18 01:42:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
std::cout << "2000 : " << std::to_string((*this)[2000].value) << "\n";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
Table().test();
|
|
|
|
|
|
|
|
std::cout << "object table tests done\n";
|
|
|
|
return 0;
|
|
|
|
}
|