|
#include <pantheios/inserters/args.hpp>
argc+argv
arguments into Pantheios diagnostic logging statements.
This class formats an argc+argv
pair into a string to be inserted into a logging statement.
By default, arguments that contain spaces (TAB or space character) will be enclosed in double quotes, and those that do not will not. This behaviour can be moderated by use of the args::neverQuoteArgs and args::alwaysQuoteArgs member constants.
Consider the following statement:
int main(int argc, char* argv[]) { pantheios::log_DEBUG("main(", args(argc, argv), ")"); . . .
Suppose the program is /test/myprog
and the command-line arguments are abc
, -123
and Billy Jean
. This will produce the output:
/test/myprog, abc, -123, "Billy Jean"
We may specify different flags from the default (args::quoteArgsWithSpaces) in the third constructor argument, as in:
int main(int argc, char* argv[]) { pantheios::log_DEBUG("main(", pantheios::args(argc, argv, pantheios::args::neverQuoteArgs), ")"); . . .
Using the same arguments, this will produce the output:
/test/myprog, abc, -123, Billy Jean
cpp/backends/example.cpp.backends.file.callback/example.cpp.backends.file.callback.cpp, cpp/backends/example.cpp.backends.file.lrsplit/example.cpp.backends.file.lrsplit.cpp, cpp/backends/example.cpp.backends.file/example.cpp.backends.file.cpp, cpp/backends/example.cpp.backends.mx.1/example.cpp.backends.mx.1.cpp, cpp/backends/example.cpp.backends.mx.2/example.cpp.backends.mx.2.cpp, cpp/inserters/example.cpp.inserter.args/example.cpp.inserter.args.cpp, cpp/inserters/example.cpp.inserter.m2w/example.cpp.inserter.m2w.cpp, and cpp/inserters/example.cpp.inserter.w2m/example.cpp.inserter.w2m.cpp.
Public Types | |
Member Constants | |
enum | format_flags { neverQuoteArgs = 0x0000, quoteArgsWithSpaces = 0x0001, alwaysQuoteArgs = 0x0002, arg0FileOnly = 0x0004 } |
The format flags. More... | |
Member Types | |
typedef args | class_type |
Public Member Functions | |
Construction | |
args (int argc, pan_char_t const *const *argv, int flags=quoteArgsWithSpaces, pan_char_t const *separator=PANTHEIOS_LITERAL_STRING(", ")) | |
Constructs an args inserter that will display the command-line arguments. | |
Accessors | |
pan_char_t const * | data () const |
A possibly non-nul-terminated non-null pointer to the c-style string representation of the integer. | |
pan_char_t const * | c_str () const |
A nul-terminated non-null pointer to the c-style string representation of the integer. | |
size_t | size () const |
The size of the c-style string representation of the integer. |
enum format_flags |
args | ( | int | argc, | |
pan_char_t const *const * | argv, | |||
int | flags = quoteArgsWithSpaces , |
|||
pan_char_t const * | separator = PANTHEIOS_LITERAL_STRING(", ") | |||
) |
pan_char_t const* data | ( | ) | const |
pan_char_t const* c_str | ( | ) | const |
size_t size | ( | ) | const |
The size of the c-style string representation of the integer.
|
|
pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 |