utils.h 919 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef UTILS_H
  2. #define UTILS_H
  3. #include <fstream>
  4. #include <functional>
  5. #include <string.h>
  6. #include <string>
  7. #include <utility> // pair
  8. #include <vector>
  9. // utility functions go here
  10. bool replace(std::string &str, const std::string &from, const std::string &to);
  11. bool replace(std::string &str, const char *from, const char *to);
  12. bool file_exists(const std::string &name);
  13. bool file_exists(const char *name);
  14. void string_toupper(std::string &str);
  15. bool iequals(const std::string &a, const std::string &b);
  16. std::vector<std::pair<int, int>> find_words(const std::string &text);
  17. std::vector<std::string> split(const std::string &text, char sep);
  18. // logger access
  19. extern std::function<std::ofstream &(void)> get_logger;
  20. extern std::function<void(void)> cls_display_starfield;
  21. extern std::function<int(void)> press_a_key;
  22. // configuration settings access
  23. #include "yaml-cpp/yaml.h"
  24. extern YAML::Node config;
  25. #endif