From 6d43028973387f6750a29ee59d566c83c92b45a4 Mon Sep 17 00:00:00 2001 From: mes5k Date: Thu, 25 Nov 2004 03:45:13 +0000 Subject: [PATCH] updates for using stuff and new output --- docs/manual.html | 66 +++++++++++++++++++++++++++++++++++++++------- docs/manual.xml | 68 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 119 insertions(+), 15 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index 07ac00e..fe3bc1e 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -2,7 +2,7 @@ Templatized C++ Command Line Parser Manual

Templatized C++ Command Line Parser Manual

Michael E Smoot


Chapter 1. Basic Usage

TCLAP has a few key classes to be aware of. The first is the CmdLine (command line) class. This class parses @@ -163,13 +163,15 @@ argument is required to be present (SwitchArgs can't be required, as that would defeat the purpose).

  • Next, the default value the arg should assume if the arg isn't required or entered on the command line.
  • Last, for ValueArgs is a short description of the type -that the argument expects (yes its an ugly Note that the order of +that the argument expects (yes its an ugly + hack). +Note that the order of arguments on the command line (so far) doesn't matter. Any argument not matching an Arg added to the command line will cause an exception to be thrown ( for the most part, with some exceptions). - hack).
  • +

    Types of Arguments

    There are two primary types of arguments:

    @@ -226,12 +228,12 @@ to work on Windows, Sun and Alpha platforms. We've made every effort to keep the library compliant with the ANSI C++ standard so if your compiler meets the standard, then this library should work for you. Please let us know if this is not the case! -

    Windows Note

    +

    Windows Note

    As we understand things, Visual C++ does not have the file config.h which is used to make platform specific definitions. In this situation, we assume that you -have access to sstream. Our understanding is that, -this should not be a problem for VC 7.x. However, if this +have access to sstream. Our understanding is that +this should not be a problem for VC++ 7.x. However, if this is not the case and you need to use strstream, then simply tell your compiler to define the variable HAVE_STRSTREAM and undefine @@ -239,9 +241,20 @@ then simply tell your compiler to define the variable should work. We think. Alternatively, just edit the files ValueArg.h and MultiArg.h.

    +

    Random Note

    +If your compiler doesn't support the using syntax used +in UnlabeledValueArg and +UnlabeledMultiArg to support two stage name lookup, +then you have two options. Either comment out the statements if you don't +need two stage name lookup, or do a bunch of search and replace and use +the this pointer syntax: e.g. +this->_ignoreable instead +of just _ignorable (do this for each variable +or method referenced by using). +

    Chapter 2. Complications

    +argument...

    I want the Args to add themselves to the CmdLine...
    I want different output than what is provided...

    Naturally, what we have seen to this point doesn't satisfy all of our needs.

    I want to combine multiple switches into one argument...

    @@ -546,6 +559,39 @@ is an example: cmd.parse(argc,argv);

    +

    I want different output than what is provided...

    +It is straightforward to change the output generated by +TCLAP. Either subclass the +StdOutput class and re-implement the methods you choose, +or write your own class that implements the +CmdLineOutput interface. Once you have done this, +then use the CmdLine setOutput +method to tell the CmdLine to use your new output +class. Here is a simple example: +

    +class MyOutput : public StdOutput
    +{
    +	public:
    +		virtual void failure(CmdLineInterface& c, ArgException& e)
    +		{ 
    +			cerr << "My special failure message for: " << endl
    +				 << e.what() << endl;
    +		}
    +};
    +
    +int main(int argc, char** argv)
    +{
    +	    CmdLine cmd("this is a message", ' ', "0.99" );
    +
    +	    // set the output
    +	    MyOutput my;
    +	    cmd.setOutput( &my );
    +
    +		// proceed normally ...
    +

    + +See test4.cpp in the examples directory for the full +example.

    Chapter 3. Exceptions to the Rules

    Like all good rules, there are many exceptions....

    Ignoring arguments

    @@ -584,9 +630,11 @@ of the type declared for a particular argument. Unfortunately, at least for g++, the names returned aren't particularly useful.

    Chapter 4. Visitors

    -Disclaimer: Almost no one will have any use for Visitors, they were +Disclaimer: Almost no one will have any use for +Visitors, they were added to provide special handling for default arguments. Nothing -that Visitors do couldn't be accomplished by the user after the +that Visitors do couldn't be accomplished +by the user after the command line has been parsed. If you're still interested, keep reading...

    diff --git a/docs/manual.xml b/docs/manual.xml index 70dbfc0..9592f31 100644 --- a/docs/manual.xml +++ b/docs/manual.xml @@ -230,13 +230,15 @@ required or entered on the command line. Last, for ValueArgs is a short description of the type -that the argument expects (yes its an ugly Note that the order of +that the argument expects (yes its an ugly + hack). +Note that the order of arguments on the command line (so far) doesn't matter. Any argument not matching an Arg added to the command line will cause an exception to be thrown ( for the most part, with some exceptions). - hack). + @@ -320,8 +322,8 @@ for you. Please let us know if this is not the case! As we understand things, Visual C++ does not have the file config.h which is used to make platform specific definitions. In this situation, we assume that you -have access to sstream. Our understanding is that, -this should not be a problem for VC 7.x. However, if this +have access to sstream. Our understanding is that +this should not be a problem for VC++ 7.x. However, if this is not the case and you need to use strstream, then simply tell your compiler to define the variable HAVE_STRSTREAM and undefine @@ -330,6 +332,20 @@ then simply tell your compiler to define the variable the files ValueArg.h and MultiArg.h. + +Random Note + +If your compiler doesn't support the using syntax used +in UnlabeledValueArg and +UnlabeledMultiArg to support two stage name lookup, +then you have two options. Either comment out the statements if you don't +need two stage name lookup, or do a bunch of search and replace and use +the this pointer syntax: e.g. +this->_ignoreable instead +of just _ignorable (do this for each variable +or method referenced by using). + + @@ -699,6 +715,44 @@ is an example: + + +I want different output than what is provided... + +It is straightforward to change the output generated by +TCLAP. Either subclass the +StdOutput class and re-implement the methods you choose, +or write your own class that implements the +CmdLineOutput interface. Once you have done this, +then use the CmdLine setOutput +method to tell the CmdLine to use your new output +class. Here is a simple example: + +class MyOutput : public StdOutput +{ + public: + virtual void failure(CmdLineInterface& c, ArgException& e) + { + cerr << "My special failure message for: " << endl + << e.what() << endl; + } +}; + +int main(int argc, char** argv) +{ + CmdLine cmd("this is a message", ' ', "0.99" ); + + // set the output + MyOutput my; + cmd.setOutput( &my ); + + // proceed normally ... + + +See test4.cpp in the examples directory for the full +example. + + @@ -765,9 +819,11 @@ particularly useful. Visitors -Disclaimer: Almost no one will have any use for Visitors, they were +Disclaimer: Almost no one will have any use for +Visitors, they were added to provide special handling for default arguments. Nothing -that Visitors do couldn't be accomplished by the user after the +that Visitors do couldn't be accomplished +by the user after the command line has been parsed. If you're still interested, keep reading...