summaryrefslogtreecommitdiff
path: root/config.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-29 03:23:55 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-29 03:23:55 -0400
commit032afa5657bd600476cde256b6d7db84fde7d038 (patch)
tree3d9839f92ce2f99fda85583388dd258f376fdbbb /config.h
parent3034529d54759f0fd3bcc6191f33a5e93a1988ca (diff)
downloadfork-ledger-032afa5657bd600476cde256b6d7db84fde7d038.tar.gz
fork-ledger-032afa5657bd600476cde256b6d7db84fde7d038.tar.bz2
fork-ledger-032afa5657bd600476cde256b6d7db84fde7d038.zip
a bit of a reorg; still much more to go
Diffstat (limited to 'config.h')
-rw-r--r--config.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/config.h b/config.h
index 7da0f73e..2bfee4bd 100644
--- a/config.h
+++ b/config.h
@@ -2,6 +2,10 @@
#define _CONFIG_H
#include "ledger.h"
+#include "option.h"
+#include "valexpr.h"
+#include "datetime.h"
+#include "format.h"
#include <iostream>
#include <memory>
@@ -17,6 +21,8 @@ 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;
@@ -36,6 +42,7 @@ struct config_t
bool show_collapsed;
bool show_subtotal;
bool show_related;
+ bool show_all_related;
bool show_inverted;
bool show_empty;
bool days_of_the_week;
@@ -43,13 +50,44 @@ struct config_t
bool show_revalued_only;
bool download_quotes;
+ // These settings require processing of the above.
+
+ bool use_cache;
+ bool cache_dirty;
+ interval_t report_interval;
+ std::time_t interval_begin;
+ format_t format;
+ format_t nformat;
+
+ std::auto_ptr<value_expr_t> sort_order;
+ std::auto_ptr<std::ostream> output_stream;
+
config_t();
+
+ void process_options(const std::string& command,
+ strings_list::iterator arg,
+ strings_list::iterator args_end);
};
-extern config_t * config;
+extern config_t config;
void option_help(std::ostream& out);
+struct declared_option_handler : public option_handler {
+ declared_option_handler(const std::string& label,
+ const std::string& opt_chars) {
+ register_option(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