Headers move, CMake targets merge, C++ namespaces stay unchanged: - Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant - Functional: Pipeline, Either, Result, Retry - Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval - Math: +Matrix, Numeric, Random, Histogram - Text: Str, Format, Tokenizer, Diff, Encoding, Semver - Data: Json, Csv, Ini - Async: Coro, Concurrency, EventBus, Observable - Time: +Bench - Log: Log facade + Logging framework (facade now header-only, breaking the Stacktrace<->Log link cycle the merge would have created) - System: FileSystem + Process - Configuration: +Argparse - Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail Module system fixes: - OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no longer depends on the alphabetical discovery order of src/ subdirs (Testing -> Text would have been silently dropped). - Every header-only module now has a tracked module.cmake; previously the empty src/<Name> marker dirs were untracked, so a fresh clone would have silently skipped those modules. - VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT. Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files prefixed: ResultBasic etc.). Test count verified identical (831) before and after. README/CLAUDE.md module tables updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <Void/Functional/Error.hpp>
|
|
#include <Void/Functional/Result.hpp>
|
|
|
|
#include <cstdlib>
|
|
#include <format>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace Void::Configuration
|
|
{
|
|
|
|
/// Look up a single environment variable by name.
|
|
/// Returns an error if the variable is not set.
|
|
[[nodiscard]] inline Void::Result::Result<std::string, Void::Result::Error>
|
|
get_env(std::string_view name)
|
|
{
|
|
std::string name_str{name};
|
|
const char* val = std::getenv(name_str.c_str()); // NOLINT(concurrency-mt-unsafe)
|
|
if (!val) {
|
|
return Void::Result::fail(
|
|
std::format("Configuration::get_env: '{}' is not set", name));
|
|
}
|
|
return Void::Result::ok(std::string{val});
|
|
}
|
|
|
|
/// Look up a single environment variable, returning `fallback` if not set.
|
|
[[nodiscard]] inline std::string
|
|
get_env_or(std::string_view name, std::string_view fallback = {})
|
|
{
|
|
std::string name_str{name};
|
|
const char* val = std::getenv(name_str.c_str()); // NOLINT(concurrency-mt-unsafe)
|
|
return val ? std::string{val} : std::string{fallback};
|
|
}
|
|
|
|
} // namespace Void::Configuration
|