From 661b73df47caae2cc62a9a2f7b85eb925ff1f80b Mon Sep 17 00:00:00 2001 From: auth12 <67507608+auth12@users.noreply.github.com> Date: Sun, 4 Jul 2021 01:15:09 +0100 Subject: initial commit --- sysmap/src/io.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sysmap/src/io.h (limited to 'sysmap/src/io.h') diff --git a/sysmap/src/io.h b/sysmap/src/io.h new file mode 100644 index 0000000..b498065 --- /dev/null +++ b/sysmap/src/io.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include +#include + +enum log_lvl { + trace = 0, + debug, + info, + warn, + error, + critical +}; + +namespace io { + template + void log(std::string_view msg, Args... params) { + spdlog::log(static_cast(T), msg.data(), std::forward(params)...); + } + + static std::vector read_file(std::string_view name) { + std::ifstream file(name.data(), std::ios::binary); + if (!file.good()) { + return {}; + } + + std::vector out; + + file.seekg(0, std::ios::end); + std::streampos length = file.tellg(); + file.seekg(0, std::ios::beg); + + out.resize(length); + + file.read((char*)out.data(), length); + + return out; + } +}; \ No newline at end of file -- cgit v1.2.3