mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-04 18:46:22 +00:00
fixing compil
This commit is contained in:
@@ -58,4 +58,32 @@ namespace BBM
|
||||
return static_cast<int>(numberOfMatches);
|
||||
}
|
||||
|
||||
bool Utils::tryParseInteger(const std::string &s, int &i)
|
||||
{
|
||||
std::istringstream iss(s);
|
||||
|
||||
iss >> std::noskipws >> i;
|
||||
return iss.eof() && !iss.fail();
|
||||
}
|
||||
|
||||
bool Utils::tryParseFloat(const std::string &s, float &f)
|
||||
{
|
||||
std::istringstream iss(s);
|
||||
|
||||
iss >> std::noskipws >> f;
|
||||
return iss.eof() && !iss.fail();
|
||||
}
|
||||
|
||||
std::vector<std::string> Utils::splitStr(const std::string &str, char delim)
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
std::istringstream f(str);
|
||||
std::string buffer;
|
||||
|
||||
while (std::getline(f, buffer, delim)) {;
|
||||
strings.push_back(buffer);
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,11 @@ namespace BBM
|
||||
|
||||
//! @brief find the frequency of a substring in a string
|
||||
static int findFrequency(const std::string &s, const std::string &pattern);
|
||||
|
||||
|
||||
static bool tryParseInteger(const std::string &s, int &i);
|
||||
static bool tryParseFloat(const std::string &s, float &f);
|
||||
static std::vector<std::string> splitStr(const std::string &str, char delim);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user