Google

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

GetLongOpt.h

00001 /* $Id: GetLongOpt.h,v 2.1 2002/04/03 06:44:39 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 namespace sc {
00015 
00016 class GetLongOpt {
00017 public:
00018    enum OptType { 
00019       NoValue, OptionalValue, MandatoryValue
00020    };
00021 private:
00022    struct Cell {
00023       const char *option;       // option name
00024       OptType type;             // option type
00025       const char *description;  // a description of option
00026       const char *value;        // value of option (string)
00027       Cell *next;               // pointer to the next cell
00028 
00029       Cell() { option = description = value = 0; next = 0; }
00030    };
00031 private:
00032   Cell *table;                          // option table
00033   const char *ustring;                  // usage message
00034   char *pname;                          // program basename
00035   char optmarker;                       // option marker
00036 
00037   int enroll_done;                      // finished enrolling
00038   Cell *last;                           // last entry in option table 
00039 
00040 private:
00041   char *basename(char * const p) const;
00042   int setcell(Cell *c, const char *valtoken, const char *nexttoken, const char *p);
00043 public:
00044    GetLongOpt(const char optmark = '-');
00045    ~GetLongOpt();
00046 
00047    int parse(int argc, char * const *argv);
00048    int parse(char * const str, char * const p);
00049 
00050    int enroll(const char * const opt, const OptType t,
00051       const char * const desc, const char * const val);
00052    const char *retrieve(const char * const opt) const;
00053 
00054    void usage(std::ostream &outfile = std::cout) const;
00055    void usage(const char *str)          { ustring = str; }
00056 };
00057 
00058 }
00059 
00060 #endif /* _GetLongOpt_h_ */

Generated at Fri Jan 10 08:14:08 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.