Sha256: a46bcd50c2dd28a361bdf1f9dff741f0b53685dc92fdf6091dddf79c96e21df2
Contents?: true
Size: 1.1 KB
Versions: 16
Compression:
Stored size: 1.1 KB
Contents
#include <leatherman/util/scoped_env.hpp> #include <leatherman/util/environment.hpp> using namespace std; namespace leatherman { namespace util { scoped_env::scoped_env(string var, string const& val) : scoped_resource() { string oldval; bool was_set = environment::get(var, oldval); environment::set(var, val); _resource = make_tuple(move(var), was_set ? boost::optional<std::string>(move(oldval)) : boost::none); _deleter = scoped_env::restore; } scoped_env::scoped_env(string var) : scoped_resource() { string oldval; bool was_set = environment::get(var, oldval); environment::clear(var); _resource = make_tuple(move(var), was_set ? boost::optional<std::string>(move(oldval)) : boost::none); _deleter = scoped_env::restore; } void scoped_env::restore(tuple<string, boost::optional<std::string>> & old) { if (get<1>(old)) { environment::set(get<0>(old), *get<1>(old)); } else { environment::clear(get<0>(old)); } } }} // namespace leatherman::util
Version data entries
16 entries across 16 versions & 2 rubygems