diff --git a/include/tclap/CmdLine.h b/include/tclap/CmdLine.h index 3aca7b2..03d8840 100644 --- a/include/tclap/CmdLine.h +++ b/include/tclap/CmdLine.h @@ -31,5 +31,6 @@ #include #include #include +#include #endif diff --git a/include/tclap/CommandLine.h b/include/tclap/CommandLine.h index fe0b9b0..a87e6ba 100644 --- a/include/tclap/CommandLine.h +++ b/include/tclap/CommandLine.h @@ -33,10 +33,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -101,6 +103,19 @@ class CmdLine */ bool _emptyCombined(const string& s); + /** + * Writes a brief usage message with short args. + * \param os - The stream to write the message to. + */ + void _shortUsage( ostream& os ); + + /** + * Writes a longer usage message with long and short args, + * provides descriptions and prints message. + * \param os - The stream to write the message to. + */ + void _longUsage( ostream& os ); + private: /** diff --git a/include/tclap/Makefile.am b/include/tclap/Makefile.am index da66a2a..e6876a3 100644 --- a/include/tclap/Makefile.am +++ b/include/tclap/Makefile.am @@ -13,5 +13,6 @@ libtclapinclude_HEADERS = ArgException.h \ HelpVisitor.h \ SwitchArg.h \ VersionVisitor.h \ - IgnoreRestVisitor.h + IgnoreRestVisitor.h \ + PrintSensibly.h diff --git a/include/tclap/PrintSensibly.h b/include/tclap/PrintSensibly.h new file mode 100644 index 0000000..f9623b5 --- /dev/null +++ b/include/tclap/PrintSensibly.h @@ -0,0 +1,51 @@ + +/****************************************************************************** + * + * file: PrintSensibly.h + * + * Copyright (c) 2004, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef __PRINTSENSIBLY_HH__ +#define __PRINTSENSIBLY_HH__ + +#include +#include +#include + +using namespace std; + +namespace TCLAP { + +/** + * This function inserts line breaks and indents long strings according the + * params input. It will only break lines at spaces, commas and pipes. + * \param os - The stream to be printed to. + * \param s - The string to be printed. + * \param maxWidth - The maxWidth allowed for the output line. + * \param indentSpaces - The number of spaces to indent the first line. + * \param secondLineOffset - The number of spaces to indent the second + * and all subsequent lines in addition to indentSpaces. + */ +void spacePrint( ostream& os, + const string& s, + int maxWidth, + int indentSpaces=0, + int secondLineOffset=0 ); + +} + +#endif diff --git a/include/tclap/XorHandler.h b/include/tclap/XorHandler.h index 9e566ed..ef4f3e9 100644 --- a/include/tclap/XorHandler.h +++ b/include/tclap/XorHandler.h @@ -23,9 +23,11 @@ #define __ORHANDLER_HH__ #include +#include #include #include #include +#include using namespace std; @@ -67,14 +69,15 @@ class XorHandler int check( const Arg* a ); /** - * Prints the XOR specific short usage. + * Returns the XOR specific short usage. */ - void shortUsage(); + string shortUsage(); /** * Prints the XOR specific long usage. + * \param os - Stream to print to. */ - void longUsage(); + void printLongUsage(ostream& os); /** * Simply checks whether the Arg is contained in one of the arg