CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
|
A class to represent the application. More...
#include <application.hpp>
Public Member Functions | |
application (int &argc, char **&argv) | |
Constructor. | |
virtual | ~application () |
Destructor. | |
virtual int | run ()=0 |
Protected Attributes | |
arguments_table | m_arguments |
The arguments passed by the system. |
A class to represent the application.
The claw::application understand the following command line arguments :
Definition at line 60 of file application.hpp.
claw::application::application | ( | int & | argc, |
char **& | argv | ||
) |
Constructor.
argc | Number of arguments to the program. |
argv | The arguments of the program. |
The constructor removes from argv all supported arguments, and updates the value of argc.
Definition at line 46 of file application.cpp.
References claw::arguments_table::add_long(), claw_gettext, claw::arguments_table::get_bool(), claw::arguments_table::get_integer(), claw::arguments_table::get_string(), claw::arguments_table::has_value(), claw::log_error, claw::log_verbose, claw::log_warning, claw::logger, m_arguments, claw::arguments_table::only_integer_values(), claw::arguments_table::parse(), claw::log_system::set(), and claw::log_system::set_level().
: m_arguments( argc, argv ) { setlocale( LC_ALL, "" ); bind_textdomain_codeset( "libclaw", "UTF-8" ); textdomain("libclaw"); m_arguments.add_long ("--log-file", claw_gettext("The file to use to store log informations."), true, claw_gettext("file") ); m_arguments.add_long ("--log-level", claw_gettext("Level of log informations:\n" "\t\terror: error messages,\n" "\t\twarning: warning and error messages,\n" "\t\tverbose: all messages."), true, claw_gettext("string") ); m_arguments.add_long ("--log-uniq", claw_gettext ("Use a logger that does not output successively the same message."), true ); m_arguments.add_long ("--log-concise", claw_gettext ("Use a logger that does not output messages that have been recently" " output."), true, claw_gettext("integer") ); m_arguments.parse( argc, argv ); log_stream* log; if ( m_arguments.has_value("--log-file") ) log = new file_logger( m_arguments.get_string("--log-file") ); else log = new console_logger; if ( m_arguments.get_bool("--log-uniq") ) log = new log_stream_uniq(log); else if ( m_arguments.has_value("--log-concise") && m_arguments.only_integer_values("--log-concise") && m_arguments.get_integer("--log-concise") > 0 ) log = new log_stream_concise(log, m_arguments.get_integer("--log-concise")); else if ( m_arguments.get_bool("--log-concise") ) log = new log_stream_concise(log); logger.set( log ); if ( m_arguments.has_value( "--log-level" ) ) { std::string level = m_arguments.get_string("--log-level"); if ( (level == "error") || (level == claw_gettext("error")) ) logger.set_level( log_error ); else if ( (level == "warning") || (level == claw_gettext("warning")) ) logger.set_level( log_warning ); else if ( (level == "verbose") || (level == claw_gettext("verbose")) ) logger.set_level( log_verbose ); else logger.set_level( m_arguments.get_integer("--log-level") ); } } // application::application()
claw::application::~application | ( | ) | [virtual] |
Destructor.
Definition at line 113 of file application.cpp.
References claw::log_system::clear(), and claw::logger.
{ logger.clear(); } // application::~application()
virtual int claw::application::run | ( | ) | [pure virtual] |
arguments_table claw::application::m_arguments [protected] |
The arguments passed by the system.
Definition at line 70 of file application.hpp.
Referenced by application().