Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

GetLongOpt.h

00001 /* $Id: GetLongOpt.h,v 2.0 2001/08/06 22:29:58 cljanss Exp $ */
00002 /* S Manoharan. Advanced Computer Research Institute. Lyon. France */
00003 
00004 #ifdef __GNUC__
00005 #pragma interface
00006 #endif
00007 
00008 #ifndef _GetLongOpt_h_
00009 #define _GetLongOpt_h_
00010 
00011 #include <iostream>
00012 #include <string.h>
00013 
00014 class GetLongOpt {
00015 public:
00016    enum OptType { 
00017       NoValue, OptionalValue, MandatoryValue
00018    };
00019 private:
00020    struct Cell {
00021       const char *option;       // option name
00022       OptType type;             // option type
00023       const char *description;  // a description of option
00024       const char *value;        // value of option (string)
00025       Cell *next;               // pointer to the next cell
00026 
00027       Cell() { option = description = value = 0; next = 0; }
00028    };
00029 private:
00030   Cell *table;                          // option table
00031   const char *ustring;                  // usage message
00032   char *pname;                          // program basename
00033   char optmarker;                       // option marker
00034 
00035   int enroll_done;                      // finished enrolling
00036   Cell *last;                           // last entry in option table 
00037 
00038 private:
00039   char *basename(char * const p) const;
00040   int setcell(Cell *c, const char *valtoken, const char *nexttoken, const char *p);
00041 public:
00042    GetLongOpt(const char optmark = '-');
00043    ~GetLongOpt();
00044 
00045    int parse(int argc, char * const *argv);
00046    int parse(char * const str, char * const p);
00047 
00048    int enroll(const char * const opt, const OptType t,
00049       const char * const desc, const char * const val);
00050    const char *retrieve(const char * const opt) const;
00051 
00052    void usage(std::ostream &outfile = std::cout) const;
00053    void usage(const char *str)          { ustring = str; }
00054 };
00055 
00056 #endif /* _GetLongOpt_h_ */

Generated at Thu Oct 4 18:08:44 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.