Okay, so I have a function that takes a string and converts it into a vector in a specific way. The code is:
std::vector<std::string> delimit_string(std::string s, std::string delimiter) {
std::vector<std::string> outVector;
size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) { //thx http://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c
token = s.substr(0, pos);
outVector.push_back(token);
s.erase(0, pos + delimiter.length());
}
return outVector;
}
std::vector<std::string> parse_map(std::string map, SDL_Renderer* ren) {
std::vector<std::string> mapString = delimit_string(map, "^");
for (int i = 0; i < mapString.size(); ++i) {
size_t pos;
while ((pos = mapString[i].find("|")) != std::string::npos){ //search for a string "|" or exit if it isnt found
mapString[i].erase(pos, pos);
std::string string1 = mapString[i].substr(0, pos); //from pos to beginning
std::string string2 = mapString[i].substr(pos + 1, std::string::npos); //from pos+1 to end
mapString.erase(mapString.begin() + i);
mapString.insert(mapString.begin() + i, string2);
mapString.insert(mapString.begin() + i, "|");
mapString.insert(mapString.begin() + i, string1);
}
}
//now mapstring looks somewhat like this:
//[commoner.bmp, commoner.bmp, |, commoner.bmp, commoner.bmp]
return mapString;
}
If I were to pass it something like "hello.bmp^hello.bmp|hello.bmp"
it should return a vector that looks somewhat like ["hello.bmp", "hello.bmp", "|", "hello.bmp"]
Though, instead of returning this, the function errors at compile time with this (rather unreadable) error:
Error 1 error LNK2019: unresolved external symbol "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl parse_map(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?parse_map@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) referenced in function _SDL_main C:\Users\spng453\documents\visual studio 2013\Projects\loot\loot\main.obj loot
I know, through process of elimination, that the parse_map
function is the function that is causing errors at compile time, and it is probably due to me not knowing how vectors work at all. Any help would be appreciated