jubilant-funicular
utils.cpp
1 #include "nta/utils.h"
2 
3 namespace nta {
4  namespace utils {
5  bool starts_with(crstring str, crstring prefix) {
6  return ::utils::starts_with(str, prefix);
7  }
8  bool ends_with(crstring str, crstring suffix) {
9  return ::utils::ends_with(str, suffix);
10  }
11  std::string replace_all(crstring str, crstring o, crstring n) {
12  return ::utils::replace_all(str, o, n);
13  }
14  std::string replace_all(crstring str, const std::vector<std::vector<std::string>>& os, const std::vector<std::string>& ns) {
15  return ::utils::replace_all(str, os, ns);
16  }
17  std::string trim(crstring str, crstring back_trash, crstring front_trash) {
18  return ::utils::trim(str, back_trash, front_trash);
19  }
20  std::vector<std::string> split(crstring str, char delim) {
21  return ::utils::split(str, delim);
22  }
23  std::string read_file(const std::string_view path) {
24  return ::utils::read_file(path);
25  }
26  std::size_t hash_combine(std::size_t lhs, std::size_t rhs) {
27  return ::utils::hash_combine(lhs, rhs);
28  }
29  glm::vec2 rotate(crvec2 pt, float angle) {
30  return glm::vec2(glm::cos(angle)*pt.x - glm::sin(angle)*pt.y,
31  glm::sin(angle)*pt.x + glm::cos(angle)*pt.y);
32  }
33  }
34 }
nta::utils::hash_combine
std::size_t hash_combine(std::size_t lhs, std::size_t rhs)
Stolen from Boost.
Definition: utils.cpp:26
nta::utils::read_file
std::string read_file(const std::string_view path)
Reads the contents of a file into a string.
Definition: utils.cpp:23
nta
Definition: Animation2D.h:6
nta::utils::rotate
glm::vec2 rotate(crvec2 pt, float angle)
Rotates a point (about the origin) by the given angle.
Definition: utils.cpp:29
nta::utils::trim
std::string trim(crstring str, crstring back_trash=" \t\n\v\f\r\0", crstring front_trash=" \t\n\v\f\r\0")
Removes leading and trailing whitespace.
Definition: utils.cpp:17
nta::utils::split
std::vector< std::string > split(crstring str, char delim)
Splits a string into substrings separated by delim.
Definition: utils.cpp:20
nta::utils::replace_all
std::string replace_all(crstring str, crstring o, crstring n)
Replaces all occurences of o in str with n.
Definition: utils.cpp:11
nta::utils::starts_with
bool starts_with(crstring str, crstring prefix)
Checks if str starts with prefix.
Definition: utils.cpp:5
nta::utils::ends_with
bool ends_with(crstring str, crstring suffix)
Checks if str ends with suffix.
Definition: utils.cpp:8