|
NAMETcl_ParseArgsObjv - parse arguments according to a tabular descriptionSYNOPSIS#include <tcl.h> int Tcl_ParseArgsObjv(interp, argTable, objcPtr, objv, remObjv) ARGUMENTS
DESCRIPTIONThe Tcl_ParseArgsObjv function provides a system for parsing argument lists of the form “-someName someValue ...”. Such argument lists are commonly found both in the arguments to a program and in the arguments to an individual Tcl command. This parser assumes that the order of the arguments does not matter, other than in so far as later copies of a duplicated option overriding earlier ones.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:
ARGUMENT DESCRIPTOR ENTRIESEach entry of the argument descriptor table must be a structure of type Tcl_ArgvInfo. The structure is defined as this:typedef struct { int type; const char *keyStr; void *srcPtr; void *dstPtr; const char *helpStr; ClientData clientData; } Tcl_ArgvInfo; The keyStr field contains the name of the option; by convention, this will normally begin with a “-” character. The type, srcPtr, dstPtr and clientData fields describe the interpretation of the value of the argument, as described below. The helpStr field gives some text that is used to provide help to users when they request it. 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:
typedef int (Tcl_ArgvFuncProc)( ClientData clientData, Tcl_Obj *objPtr, void *dstPtr); 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.
typedef int (Tcl_ArgvGenFuncProc)( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv, void *dstPtr); The clientData is the value from the table entry, the interp is where to store any error messages, the keyStr is the name of the argument, 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.
SEE ALSOTcl_GetIndexFromObj(3), Tcl_Main(3), Tcl_CreateObjCommand(3)KEYWORDSargument, parse
Visit the GSP FreeBSD Man Page Interface. |