diff options
author | David Robillard <d@drobilla.net> | 2012-11-21 06:28:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-11-21 06:28:25 +0000 |
commit | 480c0e362aec524d992ed7adaccf3c13b71e6f93 (patch) | |
tree | 6999cdf1edea7caaab0d4e22629e86a8f98a7a41 | |
parent | 0583e0b72b6bf7064c2e8af498b18f0bc168485f (diff) | |
download | ingen-480c0e362aec524d992ed7adaccf3c13b71e6f93.tar.gz ingen-480c0e362aec524d992ed7adaccf3c13b71e6f93.tar.bz2 ingen-480c0e362aec524d992ed7adaccf3c13b71e6f93.zip |
Use translatable strings for command line error messages.
Update for Raul Exception namespace change.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4840 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | ingen/Configuration.hpp | 2 | ||||
-rw-r--r-- | src/Configuration.cpp | 24 |
2 files changed, 17 insertions, 9 deletions
diff --git a/ingen/Configuration.hpp b/ingen/Configuration.hpp index fac798d1..bc04ecba 100644 --- a/ingen/Configuration.hpp +++ b/ingen/Configuration.hpp @@ -120,7 +120,7 @@ public: void print_usage(const std::string& program, std::ostream& os); - struct CommandLineError : public Exception { + struct CommandLineError : public Raul::Exception { explicit CommandLineError(const std::string& m) : Exception(m) {} }; diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 9c9402c0..a7f45e7f 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -17,6 +17,7 @@ #include <iostream> #include "ingen/Configuration.hpp" +#include "raul/fmt.hpp" namespace Ingen { @@ -111,8 +112,9 @@ Configuration::set_value_from_string(Configuration::Option& option, if (endptr && *endptr == '\0') { option.value = Value(intval); } else { - throw CommandLineError("option `" + option.name - + "' has non-integer value `" + value + "'"); + throw CommandLineError( + (Raul::fmt("option `%1%' has non-integer value `%2%'") + % option.name % value).str()); } break; case STRING: @@ -120,7 +122,8 @@ Configuration::set_value_from_string(Configuration::Option& option, assert(option.value.type() == STRING); break; default: - throw CommandLineError(std::string("bad option type `--") + option.name + "'"); + throw CommandLineError( + (Raul::fmt("bad option type `%1%'") % option.name).str()); } return EXIT_SUCCESS; } @@ -136,13 +139,15 @@ Configuration::parse(int argc, char** argv) throw (Configuration::CommandLineErr const std::string name = std::string(argv[i]).substr(2); Options::iterator o = _options.find(name); if (o == _options.end()) { - throw CommandLineError(std::string("unrecognized option `--") + name + "'"); + throw CommandLineError( + (Raul::fmt("unrecognized option `%1%'") % name).str()); } if (o->second.type == BOOL) { o->second.value = Value(true); } else { if (++i >= argc) - throw CommandLineError("missing value for `--" + name + "'"); + throw CommandLineError( + (Raul::fmt("missing value for `%1'") % name).str()); set_value_from_string(o->second, argv[i]); } } else { @@ -151,18 +156,21 @@ Configuration::parse(int argc, char** argv) throw (Configuration::CommandLineErr char letter = argv[i][j]; ShortNames::iterator n = _short_names.find(letter); if (n == _short_names.end()) - throw CommandLineError(std::string("unrecognized option `-") + letter + "'"); + throw CommandLineError( + (Raul::fmt("unrecognized option `%1%'") % letter).str()); Options::iterator o = _options.find(n->second); if (j < len - 1) { if (o->second.type != BOOL) - throw CommandLineError(std::string("missing value for `-") + letter + "'"); + throw CommandLineError( + (Raul::fmt("missing value for `%1%'") % letter).str()); o->second.value = Value(true); } else { if (o->second.type == BOOL) { o->second.value = Value(true); } else { if (++i >= argc) - throw CommandLineError(std::string("missing value for `-") + letter + "'"); + throw CommandLineError( + (Raul::fmt("missing value for `%1%'") % letter).str()); set_value_from_string(o->second, argv[i]); } } |