util/environment.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #include "chrono_batch_render/util/environment.h" | ||
| 3 | |||
| 4 | #include <cstdlib> | ||
| 5 | |||
| 6 | #include "chrono_batch_render/util/error.h" | ||
| 7 | |||
| 8 | namespace chrono::batch_render { | ||
| 9 | |||
| 10 | 592 | std::string Environment(const char* name) { | |
| 11 | 592 | const char* value = std::getenv(name); | |
| 12 | 1148 | return value != nullptr ? value : ""; | |
| 13 | } | ||
| 14 | |||
| 15 | 3 | void ThrowUnknownChoice(const char* name, std::string_view value, | |
| 16 | const std::vector<std::string>& names) { | ||
| 17 | 3 | const std::string alternatives = | |
| 18 | 3 | names.size() < 2 ? Join(names) | |
| 19 | 9 | : Join({names.begin(), names.end() - 1}) + " or " + names.back(); | |
| 20 | 3 | throw Error("{} is \"{}\"; it may be {}", name, value, alternatives); | |
| 21 | 3 | } | |
| 22 | |||
| 23 | } | ||
| 24 |