vitastor-disk prepare: WIP second form command of the command

This commit is contained in:
Vitaliy Filippov
2022-08-12 01:58:28 +03:00
parent 5a10d135f3
commit 2e0a2221eb
4 changed files with 129 additions and 19 deletions
+17
View File
@@ -75,6 +75,23 @@ std::string trim(const std::string & in)
return in.substr(begin, end+1-begin);
}
std::string str_replace(const std::string & in, const std::string & needle, const std::string & replacement)
{
std::string res;
int pos = 0, p2;
while ((p2 = in.find(needle, pos)) >= 0)
{
res += in.substr(pos, p2-pos);
res += replacement;
pos = p2 + replacement.size();
}
if (!pos)
{
return in;
}
return res + in.substr(pos);
}
uint64_t stoull_full(const std::string & str, int base)
{
if (isspace(str[0]))