version 1.27, 2006/01/30 16:18:39
|
version 1.28, 2007/06/19 17:58:04
|
|
|
// A LONGFLAG means that the value is bound to a long-named option name | // A LONGFLAG means that the value is bound to a long-named option name |
// REGULAR means that the argument value is not preceded by a flag | // REGULAR means that the argument value is not preceded by a flag |
// | // |
class PEGASUS_GETOOPT_LINKAGE Optarg { |
class PEGASUS_GETOOPT_LINKAGE Optarg |
|
{ |
public: | public: |
enum opttype {FLAG, LONGFLAG, REGULAR}; | enum opttype {FLAG, LONGFLAG, REGULAR}; |
|
|
private: | private: |
String _name; | String _name; |
opttype _opttype; | opttype _opttype; |
String _value; | String _value; |
|
|
public: | public: |
// Constructors and Destructor. Default copying is OK for this class. | // Constructors and Destructor. Default copying is OK for this class. |
Optarg(); | Optarg(); |
Optarg(const String &name, opttype type, const String &value); |
Optarg( |
|
const String& name, |
|
opttype type, |
|
const String& value); |
~Optarg(); | ~Optarg(); |
|
|
// Methods to set or reset the properties | // Methods to set or reset the properties |
void setName(const String &name); | void setName(const String &name); |
void setType(opttype type); | void setType(opttype type); |
void setValue(const String &value); | void setValue(const String &value); |
|
|
// Methods to get information about the object | // Methods to get information about the object |
const String &getName() const; | const String &getName() const; |
const String &getopt() const; | const String &getopt() const; |
|
|
// getoopt cmdline(optstring); | // getoopt cmdline(optstring); |
// for (getoopt::const_iterator it = cmdline.begin(); | // for (getoopt::const_iterator it = cmdline.begin(); |
// it != cmdline.end(); | // it != cmdline.end(); |
// it++) { |
// it++) |
// . . . (process an Optarg represented by *it. |
// { |
|
// . . . (process an Optarg represented by *it.) |
// | // |
// There are three steps in using this class: | // There are three steps in using this class: |
// 1. Initialization -- specifying the command line options | // 1. Initialization -- specifying the command line options |
|
|
// and | // and |
// value(flagName); | // value(flagName); |
// | // |
class PEGASUS_GETOOPT_LINKAGE getoopt { |
class PEGASUS_GETOOPT_LINKAGE getoopt |
|
{ |
public: | public: |
typedef Array<flagspec> Flagspec_List; | typedef Array<flagspec> Flagspec_List; |
typedef Array<String> Error_List; | typedef Array<String> Error_List; |
|
|
flagspec *getFlagspecForUpdate(const String &s); | flagspec *getFlagspecForUpdate(const String &s); |
String emptystring; | String emptystring; |
Optarg _emptyopt; | Optarg _emptyopt; |
|
|
public: | public: |
enum argtype {NOARG, MUSTHAVEARG, OPTIONALARG}; | enum argtype {NOARG, MUSTHAVEARG, OPTIONALARG}; |
// Constructor and destructor. You can initialize an instance with | // Constructor and destructor. You can initialize an instance with |