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

Method EnvVarGuard

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

Source from the content-addressed store, hash-verified

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