Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

args Class Reference
[Inserters]

#include <pantheios/inserters/args.hpp>

List of all members.


Detailed Description

Class for inserting 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
Examples:

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.

Member Enumeration Documentation

enum format_flags

The format flags.

Enumerator:
neverQuoteArgs  arguments are never quoted
quoteArgsWithSpaces  arguments are quoted if they contain spaces
alwaysQuoteArgs  arguments are always quoted
arg0FileOnly  causes only the file part of arg0 to be displayed


Constructor & Destructor Documentation

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.

Parameters:
argc The number of arguments in the argument array.
argv The array of arguments.
flags Flags that control the formatting of the shim.
separator String used to separate multiple arguments; defaults to ", "


Member Function Documentation

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.


The documentation for this class was generated from the following file:

pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo