From c1cb06e00922ba5c15c128bab05c71220077fdce Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 2 Feb 2009 15:54:28 -0400 Subject: Updated some internal documentation. --- src/ledger.h | 31 ++++++++++++++++- src/main.cc | 107 +++++++++++++++++++++++++++++---------------------------- src/report.h | 12 +++---- src/session.cc | 8 ++--- src/session.h | 15 ++++---- src/work.cc | 4 +-- tools/push | 2 +- 7 files changed, 104 insertions(+), 75 deletions(-) diff --git a/src/ledger.h b/src/ledger.h index 66fa2c8f..3051dad2 100644 --- a/src/ledger.h +++ b/src/ledger.h @@ -35,7 +35,36 @@ * * @mainpage Ledger Accounting Tool * - * A command-line tool for general double-entry accounting. + * There are essentially nine steps involved in realizing a ledger reporting + * session, with steps 5 and 8 -- which relate to the user's journal file -- + * being optional in the case of "pre-commands", since they do not require the + * user's data to be read. + * + * \section global_init Initialize the global environment + * + * \section create_objs Create session and report objects + * + * jww (2009-02-02): Set the "session context". + * + * \section process_opts Process user options + * + * This configures session and report objects + * + * - environment + * - initialization file + * - command-line options + * + * \section lookup_cmd Locate object relating to command verb + * + * \section parse_data Parse the user's journal files + * + * \section create_out Create the output stream + * + * \section invoke_cmd Invoke the command object + * + * \section write_cache Write out binary cache file, if necessary + * + * \section shutdown Wrap up, closing everything and releasing memory */ #ifndef _LEDGER_H #define _LEDGER_H diff --git a/src/main.cc b/src/main.cc index 06bb2339..736893a4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -29,73 +29,68 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include // Read this file for a top-level overview -#include "work.h" // this is where the top-level code is +#include "work.h" // This is where the meat of main() is, which + // was moved there for the sake of clarity int main(int argc, char * argv[], char * envp[]) { using namespace ledger; - // The very first thing we do is handle some very special command-line - // options, since they affect how the whole environment is setup: - // - // --verify ; turns on memory tracing - // --verbose ; turns on logging - // --debug CATEGORY ; turns on debug logging - // --trace LEVEL ; turns on trace logging - handle_debug_options(argc, argv); - - IF_VERIFY() - initialize_memory_tracing(); - - // Initialize the global C++ environment - std::ios::sync_with_stdio(false); - filesystem::path::default_name_check(filesystem::portable_posix_name); - - // Initialization of Ledger can now begin. The whole series of operations - // is contained in a try block, so we can report errors in a nicer fashion. - INFO("Ledger starting"); - session_t * session = NULL; int status = 1; try { + // The very first thing we do is handle some very special command-line + // options, since they affect how the environment is setup: + // + // --verify ; turns on memory tracing + // --verbose ; turns on logging + // --debug CATEGORY ; turns on debug logging + // --trace LEVEL ; turns on trace logging + handle_debug_options(argc, argv); + IF_VERIFY() initialize_memory_tracing(); + + INFO("Ledger starting"); + + // Initialize global Boost/C++ environment + std::ios::sync_with_stdio(false); + filesystem::path::default_name_check(filesystem::portable_posix_name); + // Create the session object, which maintains nearly all state relating to - // this invocation of Ledger. + // this invocation of Ledger; and register all known journal parsers. session = new LEDGER_SESSION_T; - set_session_context(session); - - // Register all known journal parsers. The order of these is important. register_journal_parsers(*session); + set_session_context(session); // Create the report object, which maintains state relating to each - // command invocation. Because we're running this from main() the - // distinction between session and report doesn't matter, but if a GUI - // were calling into Ledger, it would have one session object, with a - // separate report object for each report it generated. + // command invocation. Because we're running from main(), the distinction + // between session and report doesn't really matter, but if a GUI were + // calling into Ledger it would have one session object per open document, + // with a separate report_t object for each report it generated. session->report.reset(new report_t(*session)); report_t& report(*session->report.get()); - // Read user option settings, first in the environment, then from the - // user's initialization file and then from the command-line. The first - // non-option argument thereafter is the "command verb". + // Read the user's options, in the following order: + // + // 1. environment variables (LEDGER_