class SimpleCLParser

Full namefun::SimpleCLParser
Definition#include <fun/SimpleCLParser.h>
Inheritsfun::PropertyList [public ]
List of all Methods
Annotated List

Public Methods

Public Static Methods

Detailed Description

 SimpleCLParser ( int argc, char *argv[], int startAt=0, const char*argpre = 0 )


 SimpleCLParser ()


 ~SimpleCLParser ()



int  setArgs ( int argc, char *argv[], int startAt=0, const char *argpre = 0 )



Makes a half-hearted attempt to parse out any args (begining with "-"). Any args without values passed after them are assigned the value true. Sample valid command lines:

foo -a -b foo -c bar -f (-a & -f == true, -b=="foo" and -c=="bar") foo -a eat -b this -c "you lazy bum" (-a==eat, -b==this, -c=="you lazy bum")

Returns the number of args found. To get the values, call the PropertyList API functions like: int foo = parser.getInt( "-i" ); bool bar = parser.getBool( "-b" );

If argpre = 0 then it uses the existing argument prefix (or default value of Defaults to DEFAULT_ARG_PREFIX). If it is >0 then it is used as a char * prefix for all arguments and calls setArgPrefix( argpre ) to make that the default.

Note that the values are added to this list (or overwrite existing entries), and the list is not cleared by this function.

'startAt' says which element in argv[] to start with. If startAt == 0, then this->getString( "$0" ) will return argv[0], in standard shell/perl fashion. name (argv[0]) in the args list.

int  setArgs ( QString args, QString separators = " " )



Similar to setArgs( int... ) except that this one reads a whole line of options, parses that into an array, then passes it to setArgs(...). Note that this _may_ (but should not, ideally) behave slightly differently from arguments passed to the other form, which typically come in as command-line args (parsed by your shell). This functions uses lib/fun/StringTokenizer.cpp to do it's parsing, so any differences in behaviour should be resolved there.

void  setArgPrefix ( const char *pre )


SimpleCLParser &  commandLineArgs ( int argc, char *argv[] )



If this is set in main(), other objects will have use of them via commandLineArgs(). Only call the argumented version one time from main(), please.

SimpleCLParser &  commandLineArgs ()



bool  isHelpSet ()



isHelpSet() returns true if any of the following properties have been set: -?, --help, -help. It is intended to be used by applications, so they can call dump() and bail out if a user asks for help.

void  describe ( const char *key, const char *type, const char *comments )


Describes arguments, for use with dump()

QString  dump ( QString header = QString() )


Dumps the arg descriptions, plus the current values, if they are set. If header is set it is printed out first. This is intended to be used with --help/-?.

Generated by: stephan on cheyenne on Mon Aug 11 14:06:52 2003, using kdoc 2.0a54.