From 60ccc62f4934e44ad5b905fdbcf458302b8d8a09 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Fri, 3 Jun 2022 23:26:44 -0700 Subject: Changeset: 63 [WIP] Rename directories --- source/10-common/Utils.hpp | 65 ---------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 source/10-common/Utils.hpp (limited to 'source/10-common/Utils.hpp') diff --git a/source/10-common/Utils.hpp b/source/10-common/Utils.hpp deleted file mode 100644 index 9560b57..0000000 --- a/source/10-common/Utils.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -namespace Utils { - -enum IoMode { - Read, - WriteTruncate, - WriteAppend, -}; - -FILE* OpenCstdioFile(const std::filesystem::path& path, IoMode mode, bool binary = false); -FILE* OpenCstdioFile(const char* path, IoMode mode, bool binary = false); - -std::string ReadFileAsString(const std::filesystem::path& path); - -constexpr float Abs(float v) noexcept { - return v < 0.0f ? -v : v; -} - -bool InRangeInclusive(int n, int lower, int upper); -bool LineContains(glm::ivec2 p1, glm::ivec2 p2, glm::ivec2 candidate); - -bool IsColinear(glm::ivec2 p1, glm::ivec2 p2); - -template -void HashCombine(std::size_t& seed, const T& v) { - seed ^= std::hash{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); -} - -std::string MakeRandomNumberedName(const char* tag); - -} // namespace Utils - -struct StringHash { - using is_transparent = void; - - std::size_t operator()(const std::string& key) const { return robin_hood::hash_bytes(key.c_str(), key.size()); } - std::size_t operator()(std::string_view key) const { return robin_hood::hash_bytes(key.data(), key.size()); } - std::size_t operator()(const char* key) const { return robin_hood::hash_bytes(key, std::strlen(key)); } -}; - -struct StringEqual { - using is_transparent = int; - - bool operator()(std::string_view lhs, const std::string& rhs) const { - const std::string_view view = rhs; - return lhs == view; - } - - bool operator()(const char* lhs, const std::string& rhs) const { - return std::strcmp(lhs, rhs.c_str()) == 0; - } - - bool operator()(const std::string& lhs, const std::string& rhs) const { - return lhs == rhs; - } -}; -- cgit v1.2.3-70-g09d2