Add get function to tree, and implement basic tree in router

This commit is contained in:
Pablu23
2024-11-13 13:23:56 +01:00
parent e0d1ac42f7
commit 1797b3c0ef
6 changed files with 116 additions and 137 deletions

27
util.hpp Normal file
View File

@@ -0,0 +1,27 @@
#ifndef UTIL_H
#define UTIL_H
#include <string>
#include <vector>
inline std::vector<std::string> split(std::string s, std::string delimiter) {
size_t pos_start = 0, pos_end, delim_len = delimiter.length();
std::string token;
std::vector<std::string> res;
while ((pos_end = s.find(delimiter, pos_start)) != std::string::npos) {
token = s.substr(pos_start, pos_end - pos_start);
pos_start = pos_end + delim_len;
if (token != "") {
res.push_back(token);
}
}
token = s.substr(pos_start);
if (token != "") {
res.push_back(token);
}
return res;
}
#endif