A.I.M.S


getopt.h File Reference
Include dependency graph for getopt.h:

Go to the source code of this file.

Classes

struct  AimsOption
 

Macros

#define AIMS_OPT_CALLFUNC   1
 
Description of the command line : usage.

Those 2 defines create a char double pointer that you can fill with the description of the command line syntax.

This text is then sent to the stderr stream whenever a problem appears. It can also be sent by using the AimsUsage function ( see below).\ \Here is an example to show you the way to use\ \BEGIN_USAGE(usage) \"----------------------------------------------------------------", \"AimsCurvature2D [-h[elp]] -i[nput] <filein> -o[utput] <fileout>", \"----------------------------------------------------------------", \"2D curvature of an intensity image f(x,y) = I", \"----------------------------------------------------------------", \" filein : source matrix", \" fileout : destination float matrix", \"----------------------------------------------------------------", \END_USAGE\ \ Include file : getopt.h

#define BEGIN_USAGE(usage)   static const char *usage[]={
 Starts the command line description. More...
 
#define END_USAGE   0 };
 Ends the command line description. More...
 

Enumerations

enum  AimsArgType {
  AIMS_OPT_END, AIMS_OPT_FLAG, AIMS_OPT_STRING, AIMS_OPT_CHAR,
  AIMS_OPT_BYTE, AIMS_OPT_SHORT, AIMS_OPT_USHORT, AIMS_OPT_INT,
  AIMS_OPT_WORD, AIMS_OPT_LONG, AIMS_OPT_ULONG, AIMS_OPT_FLOAT,
  AIMS_OPT_DOUBLE
}
 The different option types. More...
 

Functions

AIMSDATA_API void AimsOptionSetFatalFunc (void(*f)(const char *,...))
 
Functions.

In your main, you must give an AimsOption structure which gives the program the way to process the options.

Here is an example of use :\ \BEGIN_USAGE(usage) \"----------------------------------------------------------------", \"AimsCurvature2D [-h[elp]] -i[nput] <filein> -o[utput] <fileout>", \"----------------------------------------------------------------", \"2D curvature of an intensity image f(x,y) = I", \"----------------------------------------------------------------", \" filein : source matrix", \" fileout : destination float matrix", \"----------------------------------------------------------------", \END_USAGE\ \ \ \void Usage(void) \{ AimsUsage(usage); \} \ \void main(int argc,char **argv) \{ char *filein="none",*fileout="none"; \long format; \long type; \float number = 15; \ \AimsOption opt[] = { \{ 'h',"help" ,AIMS_OPT_FLAG ,Usage ,AIMS_OPT_CALLFUNC,0,}, \{ 'i',"input" ,AIMS_OPT_STRING,&filein ,0 ,1}, \{ 'o',"output",AIMS_OPT_STRING,&fileout,0 ,1}, \{ 0 ,0 ,AIMS_OPT_END ,0 ,0 ,0}}; \ \AimsParseOptions(&argc,argv,opt,usage);\ \ ... \} \ \ In option structure, the first element gives a short name of the \ option; the second element gives a long name of the option; the third \ element gives the type of the option; the fourth element gives a \ pointer to the data to be filled or a pointer to the function to \ run if the option is valid; the fifth element tells the parser \ wether the given pointer points a data or a function; and the last \ element tells the parser wether the option is required or not.

AIMSDATA_API void AimsParseOptions (int *argc, char **argv, const AimsOption *opt, const char **usage, int allowNegNum=1)
 Parse all the options and returns eventually an error message. More...
 
AIMSDATA_API void AimsUsage (const char **usage_text) __attribute__((__noreturn__))
 Return usage on stderr stream and exit. More...
 

Macro Definition Documentation

#define AIMS_OPT_CALLFUNC   1

Definition at line 109 of file getopt.h.

#define BEGIN_USAGE (   usage)    static const char *usage[]={

Starts the command line description.

Definition at line 68 of file getopt.h.

#define END_USAGE   0 };

Ends the command line description.

Definition at line 70 of file getopt.h.

Enumeration Type Documentation

The different option types.

Eleven base types are recognized on the command line ( char, byte, short, ushort, int, word, long, ulong, float,double, and char*). The option AIMS_OPT_FLAG means that is a single option without parameter.

Enumerator
AIMS_OPT_END 
AIMS_OPT_FLAG 
AIMS_OPT_STRING 
AIMS_OPT_CHAR 
AIMS_OPT_BYTE 
AIMS_OPT_SHORT 
AIMS_OPT_USHORT 
AIMS_OPT_INT 
AIMS_OPT_WORD 
AIMS_OPT_LONG 
AIMS_OPT_ULONG 
AIMS_OPT_FLOAT 
AIMS_OPT_DOUBLE 

Definition at line 79 of file getopt.h.

Function Documentation

AIMSDATA_API void AimsOptionSetFatalFunc ( void(*)(const char *,...)  f)
AIMSDATA_API void AimsParseOptions ( int *  argc,
char **  argv,
const AimsOption opt,
const char **  usage,
int  allowNegNum = 1 
)

Parse all the options and returns eventually an error message.

AIMSDATA_API void AimsUsage ( const char **  usage_text)

Return usage on stderr stream and exit.