home *** CD-ROM | disk | FTP | other *** search
- #ifndef _ARGSCONTROL_CLASS_HPP
- #define _ARGSCONTROL_CLASS_HPP 1
-
- /*
- **
- ** ArgsControlClass.hpp
- **
- ** (c) 1998 Didier Levet
- **
- ** $Revision: 1.3 $
- ** $State: Exp $
- ** $Date: 1998/10/21 13:52:58 $
- **
- ** $Log: ArgsControlClass.hpp $
- ** Revision 1.3 1998/10/21 13:52:58 kakace
- ** Use CStrArray class for ToolTypes strings
- **
- ** Revision 1.2 1998/10/17 16:22:05 kakace
- ** *** empty log message ***
- **
- ** Revision 1.1 1998/10/03 14:29:23 kakace
- ** Initial revision
- **
- **
- */
-
- //----------------------------------------------------------------------------------------------------
-
- /// Includes
-
- #ifndef _INCLUDE_STDDEF_H
- #include <stddef.h>
- #endif
-
- #ifndef DOS_RDARGS_H
- #include <dos/rdargs.h>
- #endif
-
- #ifndef UTILITY_TAGITEM_H
- #include <Utility/TagItem.h>
- #endif
-
- #ifndef CLIB_DOS_PROTOS_H
- #include <clib/dos_protos.h>
- #endif
-
- #ifndef CLIB_ICON_PROTOS_H
- #include <clib/icon_protos.h>
- #endif
-
- #ifndef WORKBENCH_WORKBENCH_H
- #include <Workbench/Workbench.h>
- #endif
-
- #ifndef _AMIGAOS_HPP
- #include "AmigaOS.hpp"
- #endif
-
- #ifndef _STRING_CLASS_HPP
- #include "StringClass.hpp"
- #endif
-
- ///
-
-
- //----------------------------------------------------------------------------------------------------
- //=========================================== Args control ===========================================
- //----------------------------------------------------------------------------------------------------
-
- #ifndef STRING
- typedef const char *STRING;
- #endif
-
-
- struct CArgsControl { STRING pcArgName; // Identifier
- STRING pcCLIModifier; // CLI (ReadArgs) modifier
- UWORD wOffset;
- UBYTE bArgType;
- UBYTE bArgFlags;
- LONG iDefaultValue;
- LONG iControl; // Lower bound, or pointer
- LONG iUpperBound;
- };
-
- // Arg types :
-
- enum EArgType {ARG_STRING, ARG_STRING_ARRAY, ARG_NUMBER, ARG_BOOL};
-
-
- // Arg flags :
-
- #define ARGF_CLI 1 // Valid as CLI parameter.
- #define ARGF_WB (1 << 1) // Valid as ToolType
- #define ARGF_DEFAULTVALUE (1 << 2) // Use default value.
- #define ARGF_CHECKLIMITS (1 << 3) // iControl = Lower bound.
- //#define ARGF_CALLFUNC (1 << 6) // iControl = function pointer.
- //#define ARGF_CHECKVALUE (1 << 7) // iControl = pointer to an array.
-
-
- #define ARGF_CLI_WB_DEF (ARGF_CLI | ARGF_WB | ARGF_DEFAULTVALUE)
- #define ARGF_CLI_WB_DEF_CHECK (ARGF_CLI_WB_DEF | ARGF_CHECKLIMITS)
- #define ARGF_WB_DEF (ARGF_WB | ARGF_DEFAULTVALUE)
- #define ARGF_WB_DEF_CHECK (ARGF_WB_DEF | ARGF_CHECKLIMITS)
-
-
- //----------------------------------------------------------------------------------------------------
- // This class is used to read both CLI parameters and ToolTypes using the same
- // CArgsControl array. Thus, this array control everything related to the default
- // setup.
-
- class CStartup
- {
- public:
-
- enum Errors{NO_ERROR, // No error.
- NO_MEMORY, // Not enough memory.
- READARGS_ERROR, // ReadArgs() failed.
- BAD_ARGUMENT // Argument out of range.
- };
-
- CStartup(const CArgsControl control[], LONG array[], STRING extendedHelp = NULL);
- ~CStartup();
-
- Errors ParseArgs(); // Parse both CLI parameterd and ToolTypes
- Errors ParseCLIArgs(); // Parse CLI parameters only.
- Errors ParseToolTypes(STRING progName = NULL);
- // Parse ToolTypes only.
-
- private:
-
- void InitCLITemplate(); // Create pattern for RreadArgs().
- void AllocateNewString(ULONG ctrlIdx, STRING str);
- void InitArrays(); // Allocate the vector to hold ToolTypes strings.
-
- // Global variables.
-
- LONG *piArgsArray;
- const CArgsControl *poArgsControl;
- Errors iStatus;
-
- // CLI related variables.
-
- char *pcCLITemplate;
- CDOSObject oRDArgs;
- RDArgs *pOwnArgs; // Private RDArgs struct needed for extended help.
- CRDArgs DOSArgs; // RDArgs pointer returned by ReadArgs().
-
- // ToolTypes related variables.
-
- CStrArray oTTStrings;
- LONG *piTTNumbers;
- ULONG iMaxNumbers; // Maximum numbers held in iTTNumbers[]
- LONG iCurrentNumIndex; // Current index in iTTNumbers array.
-
- CStartup(const CStartup &); // Not implemented.
- void operator = (const CStartup &); // Ditto.
- };
-
- //----------------------------------------------------------------------------------------------------
-
- #endif // _ARGSCONTROL_CLASS_HPP
-
-