#ifndef UTILS_H #define UTILS_H #include #include #include 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 split(const std::string &line); std::vector 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); #endif