#include <vector>
#include <map>
#include <string>
-#include <regex>
+//#include <regex>
#include "datamap.h"
#ifdef WIN32
static char *clean_line(char *s);
-static std::vector<std::pair<std::regex, std::string>> dmap;
+//static std::vector<std::pair<std::regex, std::string>> dmap;
+static std::vector<std::pair<std::string, std::string>> dmap;
static std::map<std::string, std::string> cache;
static std::string root;
void datamap_reset()
{
- root.clear();
dmap.clear();
cache.clear();
}
}
*colon = 0;
- std::pair<std::regex, std::string> pair;
- pair.first = std::regex(line);
+ //std::pair<std::regex, std::string> pair;
+ //pair.first = std::regex(line);
+ std::pair<std::string, std::string> pair;
+ pair.first = std::string(line);
char *value = clean_line(colon + 1);
if(!value || !*value) {
void datamap_map(const char *re, const char *path)
{
- std::pair<std::regex, std::string> mapping;
- mapping.first = std::regex(re);
+ //std::pair<std::regex, std::string> mapping;
+ //mapping.first = std::regex(re);
+ std::pair<std::string, std::string> mapping;
+ mapping.first = std::string(re);
mapping.second = std::string(path);
dmap.push_back(std::move(mapping));
}
res = it->second;
} else {
// try matching with the available mappings
+ res = std::string(in);
+
int num = dmap.size();
for(int i=0; i<num; i++) {
- if(std::regex_match(in, dmap[i].first)) {
+ //if(std::regex_search(in, dmap[i].first)) {
+ if(strstr(in, dmap[i].first.c_str())) {
res = root.empty() ? dmap[i].second : root + "/" + dmap[i].second;
cache[in] = res; // add it to the cache
break;
}
}
- return 0;
}
// copy result in buf, truncating if necessary and return the size of the