optimizations of utils
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#ifndef UTILS_HPP
|
||||
#define UTILS_HPP
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@@ -9,23 +8,23 @@
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <format>
|
||||
#include <log.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#define FILL_CHAR ' '
|
||||
|
||||
std::string pNum(double num, uint8_t decs = 0);
|
||||
std::string pNum(float num, uint8_t decs = 0);
|
||||
// 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); }
|
||||
|
||||
std::string pad(std::string s, uint8_t len, bool ljust = false);
|
||||
std::string center(std::string str, uint8_t len);
|
||||
std::string pBytes(double bytes, bool isKbytes = false);
|
||||
std::string readFile(std::string path, size_t trim = 4096);
|
||||
ssize_t readFile2(std::string path, char *buffer, size_t maxlen);
|
||||
ssize_t readFile2(const char *path, char *buffer, size_t maxlen);
|
||||
int get_val(const std::string &target, const std::string &content);
|
||||
std::string getFirstDir(std::string path);
|
||||
int get_val(std::string_view target, std::string_view content);
|
||||
std::string getFirstDir(std::string_view path);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user