Proper handling of names with spaces in parsing.

pull/28/head
sigonasr2 1 year ago
parent b0cdab41f5
commit 635f580ba6
  1. 2
      Crawler/Crawler.cpp
  2. 40
      Crawler/TMXParser.h
  3. 2
      Crawler/Version.h

@ -26,7 +26,7 @@ Crawler::Crawler()
}
bool Crawler::OnUserCreate(){
TMXParser("assets/maps/Level1.tmx");
TMXParser level1("assets/maps/Level1.tmx");
//Initialize Camera.
camera=Camera2D{WINDOW_SIZE};

@ -87,30 +87,42 @@ private:
std::string data;
while (s.good()) {
int quotationMarkCount=0;
bool pastEquals=false;
data="";
bool valid=false;
while(s.good()){
int character=s.get();
if(character=='"'){
quotationMarkCount++;
}
data+=character;
if(character==' '&&quotationMarkCount%2==0){
valid=true;
break;
}
data+=character;
if(pastEquals&&quotationMarkCount%2==0){
valid=true;
break;
}
if(character=='='&&quotationMarkCount%2==0){
pastEquals=true;
}
}
if (newTag.tag.length()==0) { //Tag's empty, so first line is the tag.
newTag.tag=data;
std::cout<<"Tag: "<<newTag.tag<<"\n";
} else {
std::string key = data.substr(0,data.find("="));
std::string value = data.substr(data.find("=")+1,std::string::npos);
//Strip Quotation marks.
value = value.substr(1,std::string::npos);
value = value.substr(0,value.length()-2);
newTag.data[key]=value;
std::cout<<" "<<key<<":"<<newTag.data[key]<<"\n";
if(valid&&data.length()>0){
if (newTag.tag.length()==0) { //Tag's empty, so first line is the tag.
newTag.tag=data;
std::cout<<"Tag: "<<newTag.tag<<"\n";
} else {
std::string key = data.substr(0,data.find("="));
std::string value = data.substr(data.find("=")+1,std::string::npos);
//Strip Quotation marks.
value = value.substr(1,std::string::npos);
value = value.substr(0,value.length()-1);
newTag.data[key]=value;
std::cout<<" "<<key<<":"<<newTag.data[key]<<"\n";
}
}
}

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 86
#define VERSION_BUILD 98
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save