12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #ifndef UTILS_H
- #define UTILS_H
- #include <string>
- #include <regex>
- #include <vector>
- const char *trim_path(const char *filepath);
- bool replace(std::string &str, const std::string &from, const std::string &to);
- bool replace(std::string &str, const char *from, const char *to);
- void ansi_clean(std::string &str);
- void high_ascii(std::string &str);
- void trim(std::string &str);
- std::smatch ansi_newline(const std::string &str);
- std::string clean_string(const std::string &source);
- std::vector<std::string> split(const std::string &line);
- std::vector<std::string> split(const std::string &line, const std::string &by);
- bool startswith(const std::string &line, const std::string &has);
- bool endswith(const std::string &line, const std::string &has);
- bool in(const std::string &line, const std::string &has);
- std::string repr(const std::string &source);
- bool density_clear(int sector, int density, int navhaz=0);
- bool file_exists(const std::string &name);
- bool at_command_prompt(const std::string &prompt);
- bool at_computer_prompt(const std::string &prompt);
- bool at_planet_prompt(const std::string &prompt);
- void str_toupper(std::string &text);
- void str_tolower(std::string &text);
- void remove_telnet_commands(std::string &text);
- /**
- * Safe stoi
- *
- * returns 0 on error/exception.
- *
- * @param text
- * @return int
- */
- int sstoi(const std::string &text, int failure=0);
- time_t time_t_now(void);
- #include "json.hpp"
- using json = nlohmann::json;
- bool json_bool(json j);
- std::string json_str(json j);
- int json_int(json j);
- #endif
|