2014-04-21 02:14:48 +00:00
|
|
|
/* Copyright (c) 2008-2014, Avian Contributors
|
2013-02-17 18:19:07 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#ifndef AVIAN_UTIL_ARG_PARSER_H
|
|
|
|
#define AVIAN_UTIL_ARG_PARSER_H
|
|
|
|
|
|
|
|
namespace avian {
|
|
|
|
namespace util {
|
|
|
|
|
|
|
|
class Arg;
|
|
|
|
|
|
|
|
class ArgParser {
|
2014-05-29 03:34:58 +00:00
|
|
|
public:
|
2013-02-17 18:19:07 +00:00
|
|
|
ArgParser();
|
|
|
|
|
2013-02-18 14:50:37 +00:00
|
|
|
bool parse(int ac, const char* const* av);
|
2013-02-17 18:19:07 +00:00
|
|
|
void printUsage(const char* exe);
|
2014-05-29 03:34:58 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class Arg;
|
|
|
|
|
|
|
|
Arg* first;
|
|
|
|
Arg** last;
|
2013-02-17 18:19:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Arg {
|
2014-07-11 15:50:18 +00:00
|
|
|
public:
|
2013-02-17 18:19:07 +00:00
|
|
|
Arg* next;
|
|
|
|
bool required;
|
|
|
|
const char* name;
|
|
|
|
const char* desc;
|
|
|
|
|
|
|
|
const char* value;
|
|
|
|
|
|
|
|
Arg(ArgParser& parser, bool required, const char* name, const char* desc);
|
|
|
|
};
|
|
|
|
|
2014-07-11 15:50:18 +00:00
|
|
|
} // namespace avian
|
|
|
|
} // namespace util
|
2013-02-17 18:19:07 +00:00
|
|
|
|
2014-07-11 15:47:57 +00:00
|
|
|
#endif // AVIAN_UTIL_ARG_PARSER_H
|