www.LinuxHowtos.org
Tcl_ParseArgsObjv
Section: Tcl Library Procedures (3)Updated: 8.6
Index Return to Main Contents
NAME
Tcl_ParseArgsObjv - parse arguments according to a tabular descriptionSYNOPSIS
#include <tcl.h> int Tcl_ParseArgsObjv(interp, argTable, objcPtr, objv, remObjv)
ARGUMENTS
- Tcl_Interp *interp (out) Where to store error messages.
- const Tcl_ArgvInfo *argTable (in) Pointer to array of option descriptors.
- int *objcPtr (in/out) A pointer to variable holding number of arguments in objv. Will be modified to hold number of arguments left in the unprocessed argument list stored in remObjv.
- Tcl_Obj *const *objv (in) The array of arguments to be parsed.
-
Tcl_Obj ***remObjv (out)
Pointer to a variable that will hold the array of unprocessed arguments.
Should be NULL if no return of unprocessed arguments is required. If
objcPtr is updated to a no-zero value, the array returned through this
must be deallocated using ckfree.
DESCRIPTION
The Tcl_ParseArgsObjv function provides a system for parsing argument
lists of the form
``
The argument array is described by the objcPtr and objv
parameters, and an array of unprocessed arguments is returned through the
objcPtr and remObjv parameters; if no return of unprocessed
arguments is desired, the remObjv parameter should be NULL. If any
problems happen, including if the
``generate help''
option is selected, an error message is left in the interpreter result and
TCL_ERROR is returned. Otherwise, the interpreter result is left unchanged and
TCL_OK is returned.
The collection of arguments to be parsed is described by the argTable
parameter. This points to a table of descriptor structures that is terminated
by an entry with the type field set to TCL_ARGV_END. As convenience, the
following prototypical entries are provided:
Each entry of the argument descriptor table must be a structure of type
Tcl_ArgvInfo. The structure is defined as this:
The keyStr field contains the name of the option; by convention, this
will normally begin with a
``
As noted above, the type field is used to describe the interpretation of
the argument's value. The following values are acceptable values for
type:
The result is a boolean value indicating whether to consume the following
argument. The clientData is the value from the table entry, the
objPtr is the value that represents the following argument or NULL if
there are no following arguments at all, and the dstPtr argument to the
Tcl_ArgvFuncProc is the location to write the parsed value to.
The clientData is the value from the table entry, the interp
is where to store any error messages, objc and objv describe
an array of all the remaining arguments, and dstPtr argument to the
Tcl_ArgvGenFuncProc is the location to write the parsed value
(or values) to.
ARGUMENT DESCRIPTOR ENTRIES
typedef struct {
int type;
const char *keyStr;
void *srcPtr;
void *dstPtr;
const char *helpStr;
ClientData clientData;
} Tcl_ArgvInfo;
typedef int (Tcl_ArgvFuncProc)(
ClientData clientData,
Tcl_Obj *objPtr,
void *dstPtr);
typedef int (Tcl_ArgvGenFuncProc)(
ClientData clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv,
void *dstPtr);
SEE ALSO
Tcl_GetIndexFromObj(3), Tcl_Main(3), Tcl_CreateObjCommand(3)
KEYWORDS
argument, parse
Index