Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
clp.h
Go to the documentation of this file.00001 #ifndef CLP_H
00002 #define CLP_H
00003 #ifdef __cplusplus
00004 extern "C" {
00005 #endif
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #define Clp_NoArg               0
00019 #define Clp_ArgString           1
00020 #define Clp_ArgStringNotOption  2
00021 #define Clp_ArgBool             3
00022 #define Clp_ArgInt              4
00023 #define Clp_ArgUnsigned         5
00024 #define Clp_ArgDouble           6
00025 
00026 #define Clp_MaxDefaultType      Clp_ArgDouble
00027 
00028 
00029 #define Clp_DisallowOptions     (1<<0)
00030 
00031 
00032 #define Clp_Mandatory           (1<<0)
00033 #define Clp_Optional            (1<<1)
00034 #define Clp_Negate              (1<<2)
00035 #define Clp_AllowDash           (1<<3)
00036 #define Clp_OnlyNegated         (1<<4)
00037 
00038 
00039 
00040 #define Clp_Short               (1<<0)
00041 #define Clp_Long                (1<<1)
00042 #define Clp_ShortNegated        (1<<2)
00043 #define Clp_LongNegated         (1<<3)
00044 #define Clp_LongImplicit        (1<<4)
00045 
00046 
00047 #define Clp_AllowNumbers        (1<<0)
00048 
00049 
00050 #define Clp_NotOption           0
00051 #define Clp_Done                -1
00052 #define Clp_BadOption           -2
00053 #define Clp_Error               -3
00054 
00055 
00056 typedef struct Clp_Option Clp_Option;
00057 typedef struct Clp_Parser Clp_Parser;
00058 typedef struct Clp_Internal Clp_Internal;
00059 typedef struct Clp_ParserState Clp_ParserState;
00060 
00061 typedef int (*Clp_ArgParseFunc)(Clp_Parser *, const char *, int, void *);
00062 typedef void (*Clp_ErrorHandler)(char *);
00063 
00064 
00065 struct Clp_Option {
00066   
00067   char *long_name;
00068   int short_name;
00069   
00070   int option_id;
00071   
00072   int arg_type;
00073   int flags;
00074   
00075 };
00076 
00077 
00078 struct Clp_Parser {
00079   
00080   int negated;
00081   
00082   int have_arg;
00083   char *arg;
00084   
00085   union {
00086     int i;
00087     unsigned u;
00088     double d;
00089     char *s;
00090     void *pv;
00091   } val;
00092   
00093   Clp_Internal *internal;
00094   
00095 };
00096 
00097 
00098 Clp_Parser *    Clp_NewParser(int argc, char * const argv[],
00099                               int nopt, Clp_Option *opt);
00100 void            Clp_DeleteParser(Clp_Parser *);
00101 
00102 Clp_ErrorHandler Clp_SetErrorHandler(Clp_Parser *, Clp_ErrorHandler);
00103 int             Clp_SetOptionChar(Clp_Parser *, int c, int option_type);
00104 
00105 int             Clp_AddType
00106                         (Clp_Parser *, int type_id, int flags,
00107                          Clp_ArgParseFunc func, void *user_data);
00108 int             Clp_AddStringListType
00109                         (Clp_Parser *, int type_id, int flags, ...);
00110 int             Clp_AddStringListTypeVec
00111                         (Clp_Parser *, int type_id, int flags,
00112                          int n, char **str, int *val);
00113 
00114 char *          Clp_ProgramName(Clp_Parser *);
00115 
00116 int             Clp_Next(Clp_Parser *);
00117 char *          Clp_Shift(Clp_Parser *, int allow_dashes);
00118 int             Clp_SetOptionProcessing(Clp_Parser *, int option_processing);
00119 
00120 Clp_ParserState *Clp_NewParserState(void);
00121 void            Clp_DeleteParserState(Clp_ParserState *);
00122 void            Clp_SaveParser(Clp_Parser *, Clp_ParserState *);
00123 void            Clp_RestoreParser(Clp_Parser *, Clp_ParserState *);
00124 
00125 int             Clp_OptionError(Clp_Parser *, const char *, ...);
00126 
00127 #ifdef __cplusplus
00128 }
00129 #endif
00130 #endif