From ffa270b487c29d02d3faab7120a484309f2f600f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 12 Mar 2012 06:59:48 +0000 Subject: Centralise atom creation in forge object. Aside from being more greppable and making realtime violations more obvious, this is a step towards using LV2 atoms internally (which needs a factory since the type numbers are dynamic). git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4054 a436a847-0d15-0410-975c-d299462d15a1 --- src/Configuration.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Configuration.cpp') diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 88756e7..aa721fe 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -70,7 +70,8 @@ Configuration::print_usage(const std::string& program, std::ostream& os) } int -Configuration::set_value_from_string(Configuration::Option& option, const std::string& value) +Configuration::set_value_from_string(Configuration::Option& option, + const std::string& value) throw (Configuration::CommandLineError) { int intval = 0; @@ -79,14 +80,14 @@ Configuration::set_value_from_string(Configuration::Option& option, const std::s case Atom::INT: intval = static_cast(strtol(value.c_str(), &endptr, 10)); if (endptr && *endptr == '\0') { - option.value = intval; + option.value = _forge->make(intval); } else { throw CommandLineError("option `" + option.name + "' has non-integer value `" + value + "'"); } break; case Atom::STRING: - option.value = Atom(value.c_str()); + option.value = _forge->make(value.c_str()); break; default: throw CommandLineError(string("bad option type `--") + option.name + "'"); @@ -108,7 +109,7 @@ Configuration::parse(int argc, char** argv) throw (Configuration::CommandLineErr throw CommandLineError(string("unrecognized option `--") + name + "'"); } if (o->second.type == Atom::BOOL) { - o->second.value = true; + o->second.value = _forge->make(true); } else { if (++i >= argc) throw CommandLineError("missing value for `--" + name + "'"); @@ -125,10 +126,10 @@ Configuration::parse(int argc, char** argv) throw (Configuration::CommandLineErr if (j < len - 1) { if (o->second.type != Atom::BOOL) throw CommandLineError(string("missing value for `-") + letter + "'"); - o->second.value = true; + o->second.value = _forge->make(true); } else { if (o->second.type == Atom::BOOL) { - o->second.value = true; + o->second.value = _forge->make(true); } else { if (++i >= argc) throw CommandLineError(string("missing value for `-") + letter + "'"); -- cgit v1.2.1