Constness corrected
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2004/11/25 18:26:04 marc
|
||||
Constness corrected
|
||||
|
||||
Revision 1.1 2004/08/28 16:13:42 marc
|
||||
mrw-c++-0.92 (mrw)
|
||||
- new file: version.cpp
|
||||
@@ -72,7 +75,7 @@ namespace mrw {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Args& Args::operator<<(const char *const*const argv) throw(std::exception) {
|
||||
Args& Args::operator<<(char const*const*const argv) throw(std::exception) {
|
||||
if (_argc<0)
|
||||
throw mrw::invalid_argument("argc was not set when shifting argv");
|
||||
return parse(_argc, argv);
|
||||
@@ -90,7 +93,7 @@ namespace mrw {
|
||||
return *it->second;
|
||||
}
|
||||
|
||||
Args& Args::parse(int argc, const char*const*const argv)
|
||||
Args& Args::parse(int argc, char const*const*const argv)
|
||||
throw(std::exception) {
|
||||
if (argc>0) _filename = argv[0];
|
||||
for (int i(1); i<argc; ++i) {
|
||||
|
25
mrw/arg.hpp
25
mrw/arg.hpp
@@ -9,6 +9,9 @@
|
||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||
|
||||
$Log$
|
||||
Revision 1.5 2004/11/25 18:26:04 marc
|
||||
Constness corrected
|
||||
|
||||
Revision 1.4 2004/10/07 09:23:39 marc
|
||||
bugs in documentation
|
||||
|
||||
@@ -84,7 +87,7 @@ namespace mrw {
|
||||
@code
|
||||
// this program may be called e.g. with the following arguments:
|
||||
// ./a.out --coordinates 13 1 -vo out.txt -n MyName
|
||||
int main(int argv, const char * const * const argv) {
|
||||
int main(int argv, char const*const*const argv) {
|
||||
try {
|
||||
mrw::Args::instance()
|
||||
// setup the possible options
|
||||
@@ -104,8 +107,12 @@ namespace mrw {
|
||||
// example usage of simple option
|
||||
if (mrw::Args::instance().find('v')) // be verbose here
|
||||
...
|
||||
// example usage of option with (one) parameter
|
||||
ifstream file(mrw::Args::instance().find('o').toString().c_str());
|
||||
// example usage of option with one parameter
|
||||
ifstream file(mrw::Args::instance().find('o')[0]->toString().c_str());
|
||||
...
|
||||
// example usage of option with two parameter
|
||||
int x = mrw::Args::instance().find('c')[0]->toInt().c_str());
|
||||
int y = mrw::Args::instance().find('c')[1]->toInt().c_str());
|
||||
...
|
||||
return 0
|
||||
}
|
||||
@@ -182,7 +189,7 @@ namespace mrw {
|
||||
Do the same for all other parts Then the @c main() function reduces to:
|
||||
|
||||
@code
|
||||
int main(int argc, const char * const * const argv) {
|
||||
int main(int argc, char const*const*const argv) {
|
||||
// set the help and evaluate the user given arguments
|
||||
mrw::Args::instance()
|
||||
<<mrw::Opt('h', "--help", "Show this help text")
|
||||
@@ -323,7 +330,7 @@ namespace mrw {
|
||||
}
|
||||
|
||||
/// @brief add one more mandatory string parameter
|
||||
Param& operator<<(const char* const s) throw(std::bad_exception) {
|
||||
Param& operator<<(char const*const s) throw(std::bad_exception) {
|
||||
_params.push_back(new StringValue(s));
|
||||
return *this;
|
||||
}
|
||||
@@ -508,7 +515,7 @@ namespace mrw {
|
||||
Example:
|
||||
|
||||
@code
|
||||
int main(int argv, const char * const * const argv) {
|
||||
int main(int argv, char const*const*const argv) {
|
||||
mrw::Args::instance()<<argc<<argv;
|
||||
...
|
||||
}
|
||||
@@ -527,13 +534,13 @@ namespace mrw {
|
||||
Example:
|
||||
|
||||
@code
|
||||
int main(int argv, const char * const * const argv) {
|
||||
int main(int argv, char const*const*const argv) {
|
||||
mrw::Args::instance()<<argc<<argv;
|
||||
...
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
Args& operator<<(const char *const*const argv) throw(std::exception);
|
||||
Args& operator<<(char const*const*const argv) throw(std::exception);
|
||||
|
||||
/** @brief add a description text
|
||||
|
||||
@@ -625,7 +632,7 @@ namespace mrw {
|
||||
private:
|
||||
Args(): _argc(-1), _help(0) {} // singleton
|
||||
Args& operator=(const Args&); // singleton, not implemented
|
||||
Args& parse(int argc, const char*const*const argv) throw(std::exception);
|
||||
Args& parse(int argc, char const*const*const argv) throw(std::exception);
|
||||
typedef std::list<Opt> Options;
|
||||
typedef std::map<char, Options::iterator> ShortOpts;
|
||||
typedef std::map<std::string, Options::iterator> LongOpts;
|
||||
|
Reference in New Issue
Block a user