45 lines
906 B
C++
45 lines
906 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
namespace pdfengine {
|
|
|
|
enum class AstNodeType {
|
|
Number,
|
|
Name,
|
|
String,
|
|
HexString,
|
|
Boolean,
|
|
Null,
|
|
Array,
|
|
Dictionary
|
|
};
|
|
|
|
class AstNode {
|
|
public:
|
|
AstNodeType type;
|
|
std::string stringValue;
|
|
std::vector<uint8_t> bytesValue;
|
|
double numberValue = 0.0;
|
|
bool boolValue = false;
|
|
|
|
// We use a vector of shared_ptr for recursive data structures so the node is easily copyable/movable
|
|
std::vector<std::shared_ptr<AstNode>> arrayItems;
|
|
std::unordered_map<std::string, std::shared_ptr<AstNode>> dictItems;
|
|
|
|
// Constructors for convenience
|
|
AstNode() = default;
|
|
explicit AstNode(AstNodeType t) : type(t) {}
|
|
};
|
|
|
|
struct Operation {
|
|
std::string op;
|
|
std::vector<std::shared_ptr<AstNode>> operands;
|
|
};
|
|
|
|
} // namespace pdfengine
|