MCPcopy Create free account
hub / github.com/apache/arrow / EnvVarGuard

Method EnvVarGuard

cpp/src/arrow/testing/gtest_util.cc:671–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

669LocaleGuard::~LocaleGuard() {}
670
671EnvVarGuard::EnvVarGuard(std::string name, std::optional<std::string> value)
672 : name_(std::move(name)) {
673 auto maybe_value = arrow::internal::GetEnvVar(name_);
674 if (maybe_value.ok()) {
675 old_value_ = *std::move(maybe_value);
676 } else {
677 old_value_ = std::nullopt;
678 }
679 if (value.has_value()) {
680 ARROW_CHECK_OK(arrow::internal::SetEnvVar(name_, *value));
681 } else {
682 ARROW_CHECK_OK(arrow::internal::DelEnvVar(name_));
683 }
684}
685
686EnvVarGuard::~EnvVarGuard() {
687 if (old_value_.has_value()) {

Callers

nothing calls this directly

Calls 4

GetEnvVarFunction · 0.85
SetEnvVarFunction · 0.85
DelEnvVarFunction · 0.85
okMethod · 0.45

Tested by

no test coverage detected