From 5c7af98e3a8a3e7f1462e389c273566d7cdaa5d4 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Wed, 4 Oct 2023 04:55:42 -0400 Subject: Add static `Dataloader::search_for_game_path(fs::path)` Searches for Victoria 2 according to the supplied path If supplied path is empty, presumes Steam install according to platform environment variables If invalid supplied path, falls back to empty path behavior Supports Steam install on Windows, Mac, Linux, and FreeBSD Supports Windows registry Update .clang-format categories to include lexy-vdf Add Utility/ConstexprIntToStr.hpp --- .../utility/ConstexprIntToStr.hpp | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/openvic-simulation/utility/ConstexprIntToStr.hpp (limited to 'src/openvic-simulation/utility/ConstexprIntToStr.hpp') diff --git a/src/openvic-simulation/utility/ConstexprIntToStr.hpp b/src/openvic-simulation/utility/ConstexprIntToStr.hpp new file mode 100644 index 0000000..e383365 --- /dev/null +++ b/src/openvic-simulation/utility/ConstexprIntToStr.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include +#include + +namespace OpenVic::ConstexprIntToStr { + template + constexpr decltype(auto) append_sequence(std::integer_sequence, std::integer_sequence) { + return std::integer_sequence {}; + } + + template + struct string_sequence_to_view; + + template + struct string_sequence_to_view> { + static constexpr decltype(auto) get() { + return std::string_view { c_str }; + } + + static constexpr const char c_str[] { chars..., char {} }; + }; + + template + constexpr decltype(auto) integer_to_string_sequence() { + constexpr auto digits = []() { + return "0123456789abcdefghijklmnopqrstuvwxyz"; + }; + + constexpr std::size_t remainder = value % 10; + constexpr std::size_t next_value = value / 10; + + if constexpr (next_value != 0) { + return append_sequence(integer_to_string_sequence(), std::integer_sequence {}); + } else { + return std::integer_sequence {}; + } + } + template + constexpr std::string_view make_string() { + return string_sequence_to_view())> {}.c_str; + } + + template + constexpr auto generate_itosv_array(std::integer_sequence) { + return std::array { make_string()... }; + } + + // Make array of N string views, countings up from 0 to N - 1 + template + constexpr auto make_itosv_array() { + return generate_itosv_array(std::make_integer_sequence()); + } +} \ No newline at end of file -- cgit v1.2.3-56-ga3b1