资 源 简 介
This project has moved to GitHub (https://github.com/fredyw/cpp-argparser)
A small argument parser written in C++. This parser has been tested on Linux and Windows. It supports both short and long POSIX arguments, e.g.
-f foo --file=foo
Example:
```
class PortNumberValidator : public Validator {
public:
bool validate(const vector& values) {
for (vector::const_iterator i = values.begin(); i != values.end(); ++i) {
istringstream iss(*i);
int port;
try {
iss >> port;
if (port < 0 || port > 65535) {
return false;
}
} catch (...) {
return false;
}
}
return true;
}
~PortNumberValidator() {}
};
ArgumentParser argParser;
argParser.addArgument(Argument("-a", "-a arg", Argument::SHORT, 1, true));
argParser.addArgument(Argument("-b", "-b arg1 arg2", Argument::SHORT, 2, true));
argParser.addArgument(Argument("-c", "-c", Argument::S