diff options
author | Alan Conway <aconway@apache.org> | 2007-07-20 19:20:01 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-07-20 19:20:01 +0000 |
commit | e7b091abe3cd14764bea988188f843c016d91a19 (patch) | |
tree | 6754e3f4d961a2e35d5681cb380e41e1aa58dd48 /cpp/lib/common/CommonOptions.cpp | |
parent | 83b5d1c769a23982d9fdbfb58ab50cb58e46868a (diff) | |
download | qpid-python-e7b091abe3cd14764bea988188f843c016d91a19.tar.gz |
Ignore QPID_ env variables that don't correspond to known options.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@558099 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/common/CommonOptions.cpp')
-rw-r--r-- | cpp/lib/common/CommonOptions.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/cpp/lib/common/CommonOptions.cpp b/cpp/lib/common/CommonOptions.cpp index ebb3543105..2b6657b4e0 100644 --- a/cpp/lib/common/CommonOptions.cpp +++ b/cpp/lib/common/CommonOptions.cpp @@ -26,20 +26,20 @@ namespace qpid { namespace program_options { -char env2optchar(char env) { - return (env=='_') ? '-' : tolower(env); -} - -const std::string envPrefix("QPID_"); - -std::string env2option(const std::string& env) { - if (env.find(envPrefix) ==0) { - std::string opt = env.substr(envPrefix.size()); - std::transform(opt.begin(), opt.end(), opt.begin(), env2optchar); - return opt; +static const std::string prefix("QPID_"); + +static char env2optchar(char env) { return (env=='_') ? '-' : tolower(env); } + +std::string EnvMapper::operator()(const std::string& env) { + if (env.substr(0, prefix.size()) == prefix) { + std::string opt = env.substr(prefix.size()); + transform(opt.begin(), opt.end(), opt.begin(), env2optchar); + // Ignore env vars that don't match to known options. + if (opts.find_nothrow(opt, false)) + return opt; } return std::string(); -} +} } // namespace program_options |