From a6913f7c4664a07b9de3f194cd4013313a1e8b96 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 11 Feb 2016 15:49:19 -0500 Subject: [PATCH] Environment::get --- environment.cpp | 5 +++++ environment.h | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/environment.cpp b/environment.cpp index e546ace..04a3ba8 100644 --- a/environment.cpp +++ b/environment.cpp @@ -20,6 +20,11 @@ namespace { } } + std::string Environment::get(const std::string & key) const { + auto iter = find(key); + if (iter == end()) return ""; + return iter->second; + } Environment::iterator Environment::find( const std::string & key ) { std::string k(key); diff --git a/environment.h b/environment.h index ad45eca..41545d9 100644 --- a/environment.h +++ b/environment.h @@ -56,13 +56,13 @@ public: void unset(const std::string &k); void unset(); + std::string get(const std::string &k) const; + constexpr bool echo() const noexcept { return _echo; } constexpr bool test() const noexcept { return _test; } - constexpr bool exit() const noexcept { return _and_or ? false : _exit; } + constexpr bool exit() const noexcept { return _exit; } constexpr int status() const noexcept { return _status; } - bool and_or(bool v) { std::swap(v, _and_or); return v; } - int status(int i, bool throw_up = true); int status(int i, const std::nothrow_t &); @@ -108,8 +108,6 @@ private: bool _exit = false; bool _test = false; - bool _and_or = false; - bool _echo = false; int _status = 0; bool _startup = false;