Massive reformating and cleanup
This commit is contained in:
@ -7,49 +7,37 @@
|
||||
|
||||
namespace fsh::util {
|
||||
|
||||
extern const char* tokens[];
|
||||
|
||||
extern const char* tokens[];
|
||||
|
||||
template <class T>
|
||||
static inline std::optional<std::string> mk_optional(T t){
|
||||
if(t){
|
||||
return t->gvalue();
|
||||
template <class T>
|
||||
static inline std::optional<std::string> mk_optional(T t) {
|
||||
if (t) { return t->gvalue(); }
|
||||
return std::optional<std::string>();
|
||||
}
|
||||
return std::optional<std::string>();
|
||||
}
|
||||
|
||||
static inline bool contains(char x, std::string text) {
|
||||
for (const auto& chr : text){
|
||||
if(chr == x) return 1;
|
||||
static inline bool contains(char x, std::string text) {
|
||||
for (const auto& chr : text) {
|
||||
if (chr == x) return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
static inline std::ifstream input(const std::string& x) {
|
||||
std::ifstream in(x, std::ios::in);
|
||||
if (!in) { throw std::runtime_error("Can't open file"); }
|
||||
return in;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
static inline std::ifstream input(const std::string& x) {
|
||||
std::ifstream in(x, std::ios::in);
|
||||
if(!in) {
|
||||
throw std::runtime_error("Can't open file");
|
||||
static inline std::ofstream output(const std::string& x) {
|
||||
std::ofstream out(x, std::ios::out);
|
||||
if (!out.is_open()) { throw std::runtime_error("Can't open file"); }
|
||||
return out;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
static inline std::ofstream output(const std::string& x) {
|
||||
std::ofstream out(x, std::ios::out);
|
||||
if(!out.is_open()) {
|
||||
throw std::runtime_error("Can't open file");
|
||||
static inline std::ofstream output_append(const std::string& x) {
|
||||
std::ofstream out(x, std::ios::app | std::ios::out);
|
||||
if (!out.is_open()) { throw std::runtime_error("Can't open file"); }
|
||||
return out;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
static inline std::ofstream output_append(const std::string& x) {
|
||||
std::ofstream out(x, std::ios::app | std::ios::out);
|
||||
if(!out.is_open()) {
|
||||
throw std::runtime_error("Can't open file");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user