blob: 7f2a77071a56e0f17c829dc86537a5328620be30 (
plain)
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
|
#ifndef _CONFIG_H
#define _CONFIG_H
#include "ledger.h"
#include "option.h"
#include "valexpr.h"
#include "datetime.h"
#include "format.h"
#include "parser.h"
#include <iostream>
#include <memory>
#include <list>
namespace ledger {
extern std::string bal_fmt;
extern std::string reg_fmt;
extern std::string plot_value_fmt;
extern std::string plot_total_fmt;
extern std::string print_fmt;
extern std::string equity_fmt;
struct config_t
{
// These options can all be set used text fields.
strings_list price_settings;
std::string init_file;
std::string data_file;
std::string cache_file;
std::string price_db;
std::string output_file;
std::string account;
std::string predicate;
std::string display_predicate;
std::string interval_text;
std::string format_string;
std::string date_format;
std::string sort_string;
std::string value_expr;
std::string total_expr;
unsigned long pricing_leeway;
bool show_collapsed;
bool show_subtotal;
bool show_related;
bool show_all_related;
bool show_inverted;
bool show_empty;
bool days_of_the_week;
bool show_revalued;
bool show_revalued_only;
bool download_quotes;
// These settings require processing of the above.
bool use_cache;
bool cache_dirty;
interval_t report_interval;
format_t format;
format_t nformat;
value_expr_t * sort_order;
std::ostream * output_stream;
config_t();
config_t(const config_t&) {
assert(0);
}
~config_t() {
if (sort_order)
delete sort_order;
if (output_stream)
delete output_stream;
}
void process_options(const std::string& command,
strings_list::iterator arg,
strings_list::iterator args_end);
};
extern config_t config;
extern std::list<option_t> config_options;
void option_help(std::ostream& out);
// Parse what ledger data can be determined from the config settings
void parse_ledger_data(journal_t * journal,
parser_t * text_parser,
parser_t * cache_parser = NULL);
struct declared_option_handler : public option_handler {
declared_option_handler(const std::string& label,
const std::string& opt_chars) {
add_option_handler(config_options, label, opt_chars, *this);
}
};
#define OPT_BEGIN(tag, chars) \
static struct opt_ ## tag ## _handler \
: public declared_option_handler { \
opt_ ## tag ## _handler() : declared_option_handler(#tag, chars) {} \
virtual void operator()(const char * optarg)
#define OPT_END(tag) } opt_ ## tag ## _handler_obj
} // namespace ledger
#endif // _CONFIG_H
|