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

Method EnvVarGuard

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

Source from the content-addressed store, hash-verified

665LocaleGuard::~LocaleGuard() {}
666
667EnvVarGuard::EnvVarGuard(std::string name, std::optional<std::string> value)
668 : name_(std::move(name)) {
669 auto maybe_value = arrow::internal::GetEnvVar(name_);
670 if (maybe_value.ok()) {
671 old_value_ = *std::move(maybe_value);
672 } else {
673 old_value_ = std::nullopt;
674 }
675 if (value.has_value()) {
676 ARROW_CHECK_OK(arrow::internal::SetEnvVar(name_, *value));
677 } else {
678 ARROW_CHECK_OK(arrow::internal::DelEnvVar(name_));
679 }
680}
681
682EnvVarGuard::~EnvVarGuard() {
683 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