-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
31 lines (23 loc) · 759 Bytes
/
utils.cpp
File metadata and controls
31 lines (23 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "utils.hpp"
std::string replace(std::string source, std::string target, std::string replacement) {
size_t start = source.find(target);
if (start != std::string::npos) {
size_t end = start + target.size();
std::string left = source.substr(0, start);
std::string right = source.substr(end, source.size() - end);
return left + replacement + right;
}
return source;
}
std::string params(std::vector<std::string> params_) {
if (params_.size() == 0)
return "";
std::string source = params_[0];
for (size_t i = 1; i < params_.size(); ++i) {
source += ", " + params_[i];
}
return source;
}
std::string braces(std::string inner) {
return "{" + inner + "}";
}