forked from named-data/ndnSIM
-
Notifications
You must be signed in to change notification settings - Fork 7
/
strategy-helper.cpp
39 lines (29 loc) · 1.1 KB
/
strategy-helper.cpp
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
32
33
34
35
36
37
38
39
#include "strategy-helper.hpp"
#include "core/logger.hpp"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/detail/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
namespace nfd {
namespace fw {
NFD_LOG_INIT("StrategyHelper");
std::map<std::string, std::string> StrategyHelper::getParameterMap(std::string parameters)
{
NFD_LOG_INFO("Parsing parameters!");
std::map < std::string, std::string > outputMap;
// Replace ASCII elements
boost::replace_all(parameters, "%2C", ",");
boost::replace_all(parameters, "%3D", "=");
std::vector < std::string > paramVector;
boost::split(paramVector, parameters, boost::is_any_of(","));
for (auto substring : paramVector) {
std::vector < std::string > substringVector;
boost::split(substringVector, substring, boost::is_any_of("="));
std::string key = substringVector.front();
std::string value = substringVector.back();
outputMap[substringVector.front()] = substringVector.back();
}
return outputMap;
}
} // namespace nfd
} // namespace fw