#ifndef CMD_LINE_OPTION_DESCRIPTIONS_H_INCLUDED
#define CMD_LINE_OPTION_DESCRIPTIONS_H_INCLUDED
/*****************************************************************************/
/* HEADER FILE */
/*****************************************************************************/
/*
$Archive: $
$Revision: $
$Date: $
$Author: $
Description: Contains information about a command option, its full name,
abbreviations, description, etc. For detailed explanation,
see constructor with parameters.
TOOL And XML FORMS License
==========================
Except where otherwise noted, all of the documentation
and software included in the TOOL package is
copyrighted by Michael Swartzendruber.
Copyright (C) 2005 Michael John Swartzendruber.
All rights reserved.
Access to this code, whether intentional or accidental,
does NOT IMPLY any transfer of rights.
This software is provided "as-is," without any express
or implied warranty. In no event shall the author be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for
any purpose, including commercial applications, and to
alter and redistribute it, provided that the following
conditions are met:
1. All redistributions of source code files must retain
all copyright notices that are currently in place,
and this list of conditions without modification.
2. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
3. If you use this software in another product, an acknowledgment
in the product documentation would be appreciated but is
not required.
4. Modified versions in source or binary form must be plainly
marked as such, and must not be misrepresented as being
the original software.
Remark: The option descriptor class, each instance of this class represents
a valid option to the program and some properties about that option.
Can be used by CmdOptions to produce a usage message as well as to
parse valid options.
Example:
void CMyApp::CreateValidOptions()
{
CmdLineArg codHelp ( "HELP", NULL, "Prints a help message" );
CmdLineArg codRun ( "RUN", NULL, "Automatically execute a testcase" );
CmdLineArg codEmf ( "EMF", CMDLINE_LASTARG, "MetaFile which specified GDI calls to make" );
CmdLineArg codVerify( "VERIFY", CMDLINE_ARGOK, "Verification option" );
CmdLineArg codDiff ( "DIFFERENCE", CMDLINE_FIRSTARG, "File to write screen differences to" );
CmdLineArg codCmpScr( "CMPSCR", CMDLINE_FIRSTARG, "File to compare screen to" );
CmdLineArg codOutScr( "OUTSCR", CMDLINE_FIRSTARG, "File to write actual screen to" );
CmdLineArg codMask ( "MASK", CMDLINE_FIRSTARG, "File to mask screen differences with" );
CmdLineArg codCrc ( "CRC", CMDLINE_FIRSTARG, "File to read/write CRC code from/to" );
CmdLineArg codGen ( "GENERATE", NULL, "Interactive session for generating EMF file" );
CmdLineArg codRes ( "RES", CMDLINE_ARRAY, "Resources available" );
CmdLineArg codXList ( "X", CMDLINE_ASSOCARRAY, "Variable/Value pairs" );
}
*/
/*****************************************************************************/
// Currently allows for CMDLINE_REP_FIRST && CMDLINE_REP_LAST, and other nonsense combinations.
// This is not correct so pay attention to which flags you are combining !!!!!
//
const int CMDLINE_ARGOK = 0x1; // Does option take argument?
const int CMDLINE_REPEATOK = 0x2; // Is option valid more than once?
const int CMDLINE_REP_FIRST = 0x4; // Use first if option is repeated
const int CMDLINE_REP_LAST = 0x8; // Use last if option is repeated
const int CMDLINE_REP_ARRAY = 0x10; // Build array if option is repeated
const int CMDLINE_ASSOCIATIVE = 0x20; // Takes two arguments i.e. /X=variable=value
const int CMDLINE_FIRSTARG = CMDLINE_ARGOK | CMDLINE_REPEATOK | CMDLINE_REP_FIRST;
const int CMDLINE_LASTARG = CMDLINE_ARGOK | CMDLINE_REPEATOK | CMDLINE_REP_LAST;
const int CMDLINE_ARRAY = CMDLINE_ARGOK | CMDLINE_REPEATOK | CMDLINE_REP_ARRAY;
const int CMDLINE_ASSOCARRAY = CMDLINE_ARGOK | CMDLINE_REPEATOK | CMDLINE_ASSOCIATIVE;
class CmdLineArg
{
public:
// ctors and dtor
//
CmdLineArg();
CmdLineArg( const char* psczOptionName, const int iFlags, const char* psczDescription, const char* psczAbbr = "" );
CmdLineArg( const CmdLineArg& roOther );
virtual ~CmdLineArg();
const CmdLineArg& operator=( const CmdLineArg& roOther );
// does this option takes arguments or not
//
inline int TakesArg() const { return m_nFlags & CMDLINE_ARGOK; };
// can this option appear more than once on a command line
//
inline int IsRepeatable() const { return m_nFlags & CMDLINE_REPEATOK; };
// will only the first occurrence of this option be recorded or not
//
inline int ReturnsFirstRep() const { return m_nFlags & CMDLINE_REP_FIRST; };
// will only the last occurrence of this option be recorded or not
//
inline int ReturnsLastRep() const { return m_nFlags & CMDLINE_REP_LAST; };
// will the occurrences of this option build an array or not
//
inline int ReturnsArray() const { return m_nFlags & CMDLINE_REP_ARRAY; };
// will the occurrences of this option build an associative array or not
//
inline int ReturnsAssociative() const { return m_nFlags & CMDLINE_ASSOCIATIVE; };
// the description of this option
//
inline std::string GetDescription() const { return m_oDescription; };
// the name of this option
//
inline std::string GetOptName() const { return m_oOptionName; };
// the DEFINITE abbreviation of this option
//
inline std::string GetOptAbbr() const { return m_oAbbr; };
protected:
std::string m_oOptionName;
int m_nFlags;
std::string m_oDescription;
std::string m_oAbbr;
};
#endif
/*****************************************************************************/
/* Check-in history */
/*
*$Log: $
*/
/*****************************************************************************/