Restructure into umbrella modules (~55 -> 16 targets)

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>
This commit is contained in:
faumarayandClaude Fable 5 committed 2026-06-12 18:50:02 +03:00
1 parent da2e93c405
commit 28b94883fd
156 files changed
+278 -220

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
#pragma once
#include <Void/System/Path.hpp>
#include <Void/Log/Log.hpp>
#include <atomic>
#include <chrono>
#include <cstdint>
#include <filesystem>
#include <format>
#include <string>
#include <string_view>
#include <system_error>
#include <thread>
#include <utility>
namespace Void::FileSystem
{
/// RAII scoped directory under `std::filesystem::temp_directory_path()`.
///
/// The directory is created with a unique name on construction and
/// recursively removed on destruction. Useful in tests that need a
/// scratch area without manual cleanup.
///
/// Construction throws `std::system_error` if the directory cannot
/// be created. Use `TempDir::open(prefix)` for a non-throwing
/// `Result`-returning factory.
class TempDir
{
public:
explicit TempDir(std::string_view prefix = "void_test_")
: m_path(make_unique_dir(prefix))
{
}
~TempDir() noexcept
{
if (!m_path.empty()) {
Void::Log::log(
Void::Log::Level::Debug, "FileSystem",
std::format("TempDir: removed '{}'", m_path.string()));
std::error_code ignore;
std::filesystem::remove_all(m_path, ignore);
}
}
TempDir(const TempDir&) = delete;
TempDir& operator=(const TempDir&) = delete;
TempDir(TempDir&& other) noexcept
: m_path(std::exchange(other.m_path, {}))
{
}
TempDir& operator=(TempDir&& other) noexcept
{
if (this != &other) {
if (!m_path.empty()) {
std::error_code ignore;
std::filesystem::remove_all(m_path, ignore);
}
m_path = std::exchange(other.m_path, {});
}
return *this;
}
[[nodiscard]] const std::filesystem::path& path() const noexcept
{
return m_path;
}
/// Build a path inside the temp dir.
/// Example: `auto log_path = tmp / "test.log";`
[[nodiscard]] std::filesystem::path
operator/(std::string_view relative) const
{
return m_path / relative;
}
/// Non-throwing factory.
[[nodiscard]] static Void::Result::Result<TempDir,
Void::Result::Error>
open(std::string_view prefix = "void_test_")
{
try {
return Void::Result::ok(TempDir{prefix});
} catch (const std::exception& e) {
return Void::Result::fail(std::string{e.what()});
}
}
private:
std::filesystem::path m_path;
static std::filesystem::path
make_unique_dir(std::string_view prefix)
{
static std::atomic<std::uint64_t> counter{0};
const auto base = std::filesystem::temp_directory_path();
for (int attempt = 0; attempt < 16; ++attempt) {
const auto seed =
static_cast<std::uint64_t>(
std::chrono::steady_clock::now()
.time_since_epoch()
.count()) ^
(counter.fetch_add(1, std::memory_order_relaxed)
<< 16) ^
static_cast<std::uint64_t>(std::hash<std::thread::id>{}(
std::this_thread::get_id()));
auto candidate =
base / std::format("{}{:016x}", prefix, seed);
std::error_code ec;
if (std::filesystem::create_directory(candidate, ec)) {
Void::Log::log(Void::Log::Level::Debug, "FileSystem",
std::format("TempDir: created '{}'",
candidate.string()));
return candidate;
}
}
throw std::system_error(
std::make_error_code(std::errc::file_exists),
"TempDir: failed to create unique directory after 16 "
"attempts");
}
};
} // namespace Void::FileSystem