get rid of macro, use inline func

This commit is contained in:
2025-12-28 19:06:23 +01:00
parent 12d7ab9b0f
commit 2d3a481638
5 changed files with 44 additions and 38 deletions

View File

@@ -7,16 +7,7 @@
#define FILL_CHAR ' '
// wrapper around readFile func
#define fastReadNum(path, val) readFile(path, buf, sizeof(buf)); val = std::strtoll(buf, NULL, 10)
enum JUST {
RIGHT,
LEFT
};
// pretty prints num with given decs, 0 by default. its basically a macro so we inline it
inline std::string pNum(auto num, uint8_t decs = 0) { return std::format("{:.{}f}", num, decs); }
enum JUST { RIGHT, LEFT };
std::string pad(std::string s, uint8_t len, JUST j = JUST::RIGHT);
std::string center(std::string str, uint8_t len);
@@ -25,4 +16,15 @@ ssize_t readFile(std::string path, char* buffer, size_t maxlen);
ssize_t readFile(const char* path, char* buffer, size_t maxlen);
std::string getFirstDir(std::string_view path);
template <size_t N>
inline long long fastReadNum(const std::string& path, char (&buf)[N]) {
readFile(path, buf, N);
return std::strtoll(buf, nullptr, 10);
}
// pretty prints num with given decs, 0 by default. its basically a macro so we inline it
inline std::string pNum(auto num, uint8_t decs = 0) {
return std::format("{:.{}f}", num, decs);
}
#endif