Add misc.cpp

This commit is contained in:
blankie 2023-01-16 11:05:25 +07:00
parent 79e816e105
commit 381b34f731
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
5 changed files with 16 additions and 10 deletions

View File

@ -9,6 +9,7 @@
#include <system_error>
#include "log.h"
#include "misc.h"
#include "config.h"
static FILE* fopen_or_raise(const char* path, const char* mode, bool ignore_enoent) {

View File

@ -1,9 +1,6 @@
#include <ctime>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <exception>
#include <system_error>
@ -40,9 +37,3 @@ void log(std::string action, const std::exception& e, time_t time) {
void log(std::string action, const std::exception& e) {
log(std::move(action), e, time(nullptr));
}
std::string quote(const std::string& str) {
std::stringstream ss;
ss << std::quoted(str);
return ss.str();
}

1
log.h
View File

@ -10,4 +10,3 @@ void log(std::string entry, time_t time);
void log(std::string entry);
void log(std::string action, const std::exception& e, time_t time);
void log(std::string action, const std::exception& e);
std::string quote(const std::string& str);

10
misc.cpp Normal file
View File

@ -0,0 +1,10 @@
#include <iomanip>
#include <sstream>
#include "misc.h"
std::string quote(const std::string& str) {
std::stringstream ss;
ss << std::quoted(str);
return ss.str();
}

5
misc.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <string>
std::string quote(const std::string& str);