#include <vector>
#include <list>
+using namespace std;
+
#include "pdf-tools.h"
typedef unsigned int uint;
#define NONRET __attribute__((noreturn))
+#define UNUSED __attribute__((unused))
struct pipeline;
-
-union arg_val {
- string *s;
- double d;
- pipeline *p;
-};
+struct cmd;
enum arg_type {
AT_STRING,
+ AT_INT,
AT_DOUBLE,
AT_DIMEN,
- AT_PIPELINE, // Pipeline has an empty name
AT_TYPE_MASK = 0xffff,
AT_MANDATORY = 0x10000,
AT_POSITIONAL = 0x20000,
uint type;
};
+class arg_val {
+public:
+ virtual bool given() { return false; }
+ int as_int(int def) { return def; }
+ double as_double(double def) { return def; }
+ const string as_string(const string def) { return def; }
+ virtual string dump() { return "<undef>"; }
+};
+
struct page_out {
+ QPDFObjectHandle resources;
+ QPDFObjectHandle xobjects;
+ string contents;
+ int res_cnt;
+ string new_resource(const string type);
};
struct page {
+ int index;
double width;
double height;
- void render(page_out *out, pdf_matrix xform);
-};
-
-struct cmd {
+ virtual void render(page_out *out UNUSED, pdf_matrix xform UNUSED) { abort(); }
+ page(double _w=0, double _h=0) : width(_w), height(_h) { }
};
-struct cmd_args {
- vector<arg_val> arg;
- vector<bool> arg_given;
+struct cmd_exec {
+ virtual vector<page *> process(vector <page *> &pages UNUSED) { abort(); }
};
struct cmd_def {
const char *name;
const arg_def *arg_defs;
- cmd (*constructor)(cmd_args *args);
+ bool has_pipeline;
+ cmd_exec *(*constructor)(cmd *cmd);
+};
+
+struct cmd {
+ const cmd_def *def;
+ vector<arg_val *> args;
+ pipeline *pipe;
+ cmd_exec *exec;
};
struct pipeline_selector {
struct pipeline_branch {
vector<pipeline_selector> selectors;
- list<cmd> commands;
+ list<cmd *> commands;
};
struct pipeline {
vector<pipeline_branch *> branches;
};
+
+// parse.cc
+
+void parse(const char *in, list<cmd *> &cmds);
+
+// cmds.cc
+
+extern const cmd_def cmd_table[];