This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconfig.hh
155 lines (141 loc) · 3 KB
/
config.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* Copyright © 2007-2019 Jakub Wilk <[email protected]>
* Copyright © 2009 Mateusz Turcza
*
* This file is part of pdf2djvu.
*
* pdf2djvu is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* pdf2djvu is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#ifndef PDF2DJVU_CONFIG_H
#define PDF2DJVU_CONFIG_H
#include <climits>
#include <memory>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
#include "i18n.hh"
#include "string-format.hh"
class Config
{
protected:
static string_format::Template *default_page_id_template(const std::string &page_id_prefix);
public:
class Hyperlinks
{
public:
bool extract;
bool border_always_visible;
std::string border_color;
Hyperlinks()
: extract(true), border_always_visible(false)
{ }
};
enum
{
FG_COLORS_DEFAULT = INT_MIN,
FG_COLORS_WEB = INT_MIN + 1,
FG_COLORS_BLACK = INT_MIN + 2,
};
enum text_t
{
TEXT_NONE = 0,
TEXT_WORDS,
TEXT_LINES
};
enum format_t
{
FORMAT_BUNDLED,
FORMAT_INDIRECT
};
format_t format;
text_t text;
bool text_nfkc;
bool text_crop;
std::string output;
bool output_stdout;
int verbose;
int dpi;
bool guess_dpi;
std::pair<int, int> preferred_page_size;
bool use_media_box;
int bg_subsample;
int fg_colors;
bool monochrome;
int loss_level;
bool antialias;
Hyperlinks hyperlinks;
bool extract_metadata;
bool adjust_metadata;
bool extract_outline;
bool no_render;
char *bg_slices;
std::vector<std::pair<int, int>> pages;
std::vector<const char*> filenames;
std::unique_ptr<string_format::Template> page_id_template;
std::unique_ptr<string_format::Template> page_title_template;
std::string text_filter_command_line;
int n_jobs;
Config();
class NeedVersion
{ };
class Error : public std::runtime_error
{
public:
explicit Error(const std::string &message)
: std::runtime_error(message)
{ }
virtual bool is_quiet() const
{
return false;
}
virtual bool is_already_printed() const
{
return false;
}
};
class NoPagesSelected : public Error
{
public:
NoPagesSelected()
: Error(_("No pages selected"))
{ }
};
class NeedHelp : public Error
{
public:
NeedHelp()
: Error("")
{ }
virtual bool is_quiet() const
{
return true;
}
};
class InvalidOption : public Error
{
public:
InvalidOption()
: Error("")
{ }
virtual bool is_quiet() const
{
return true;
}
virtual bool is_already_printed() const
{
return true;
}
};
void read_config(int argc, char * const argv[]);
void usage(const Error &error) const;
void usage() const;
};
#endif
// vim:ts=2 sts=2 sw=2 et