From f691735c6ce89a19356769084449d3f5691ab030 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 9 Nov 2005 07:11:22 +0000 Subject: Restructed the code that it can build and be used as a shared library. The command-line version is still statically bound in the build process by default (for the sake of speed). --- config.h | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'config.h') diff --git a/config.h b/config.h index 14b18a47..434d2e21 100644 --- a/config.h +++ b/config.h @@ -1,12 +1,7 @@ #ifndef _CONFIG_H #define _CONFIG_H -#include "journal.h" -#include "option.h" -#include "valexpr.h" -#include "datetime.h" -#include "format.h" -#include "parser.h" +#include "ledger.h" #include #include @@ -14,8 +9,9 @@ namespace ledger { -struct config_t +class config_t { + public: // These options can all be set used text fields. strings_list price_settings; @@ -70,27 +66,43 @@ struct config_t bool use_cache; bool cache_dirty; - config_t(); + config_t() { + reset(); + } config_t(const config_t&) { assert(0); } + void reset(); + + void regexps_to_predicate(const std::string& command, + std::list::const_iterator begin, + std::list::const_iterator end, + const bool account_regexp = false, + const bool add_account_short_masks = false, + const bool logical_and = true); + + bool process_option(const std::string& opt, const char * arg = NULL); + void process_arguments(int argc, char ** argv, const bool anywhere, + std::list& args); + void process_environment(char ** envp, const std::string& tag); + void process_options(const std::string& command, strings_list::iterator arg, strings_list::iterator args_end); + + item_handler * + chain_xact_handlers(const std::string& command, + item_handler * base_formatter, + journal_t * journal, + account_t * master, + std::list *>& ptrs); }; -extern config_t config; extern std::list 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 * cache_parser = NULL, - parser_t * text_parser = NULL, - parser_t * xml_parser = NULL); - struct declared_option_handler : public option_handler { declared_option_handler(const std::string& label, const std::string& opt_chars) { -- cgit v1.2.3