Bomberman
Utils.hpp
Go to the documentation of this file.
1 //
2 // Created by cbihan on 17/06/2021.
3 //
4 
5 #pragma once
6 
7 namespace BBM
8 {
9  struct Utils
10  {
12  static void lTrim(std::string &s);
13 
15  static void rTrim(std::string &s);
16 
18  static void trim(std::string &s);
19 
21  static std::string lTrimCopy(std::string s);
22 
24  static std::string rTrimCopy(std::string s);
25 
27  static std::string trimCopy(std::string s);
28 
30  static int findFrequency(const std::string &s, const std::string &pattern);
31 
33  template<typename T>
34  static bool tryParse(const std::string &s, T &f)
35  {
36  std::istringstream iss(s);
37 
38  iss >> std::noskipws >> f;
39  return iss.eof() && !iss.fail();
40  }
41 
43  static std::vector<std::string> splitStr(const std::string &str, char delim);
44  };
45 
46 
47 }
BBM::Utils::rTrim
static void rTrim(std::string &s)
trim right end
Definition: Utils.cpp:23
BBM::Utils::splitStr
static std::vector< std::string > splitStr(const std::string &str, char delim)
split a string with a delim char
Definition: Utils.cpp:63
BBM
Definition: AnimationsComponent.cpp:9
BBM::Utils::trim
static void trim(std::string &s)
trim from both ends
Definition: Utils.cpp:30
BBM::Utils::trimCopy
static std::string trimCopy(std::string s)
trim from both ends (copying)
Definition: Utils.cpp:48
BBM::Utils::tryParse
static bool tryParse(const std::string &s, T &f)
return true if parsing has been successful result ill be in i
Definition: Utils.hpp:34
BBM::Utils::findFrequency
static int findFrequency(const std::string &s, const std::string &pattern)
find the frequency of a substring in a string
Definition: Utils.cpp:54
BBM::Utils::lTrim
static void lTrim(std::string &s)
trim left end
Definition: Utils.cpp:16
BBM::Utils::lTrimCopy
static std::string lTrimCopy(std::string s)
trim left end (copying)
Definition: Utils.cpp:36
BBM::Utils::rTrimCopy
static std::string rTrimCopy(std::string s)
trim right end (copying)
Definition: Utils.cpp:42
BBM::Utils
Definition: Utils.hpp:9