Object stastistics (first part)

This commit is contained in:
Jakub Melka
2021-06-18 19:06:11 +02:00
parent 7264a45e30
commit b8464ed4fa
18 changed files with 530 additions and 26 deletions

View File

@ -24,6 +24,7 @@
#include <set>
#include <vector>
#include <atomic>
namespace pdf
{
@ -148,6 +149,31 @@ public:
/// \param type Type
std::vector<PDFObjectReference> getObjectsByType(Type type) const;
struct StatisticsItem
{
inline StatisticsItem() :
count(0),
bytes(0)
{
}
std::atomic<qint64> count;
std::atomic<qint64> bytes;
};
struct Statistics
{
std::array<qint64, size_t(PDFObject::Type::LastType)> objectCountByType = { };
std::map<Type, StatisticsItem> statistics;
};
/// Calculate document statistics. Document classification must be
/// performed before this function is called, otherwise result is undefined.
/// \param document Document
/// \returns Calculated statistics of each object type
Statistics calculateStatistics(const PDFDocument* document) const;
private:
struct Classification
{