Proper handling of names with spaces in parsing.
This commit is contained in:
parent
b0cdab41f5
commit
635f580ba6
@ -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==' '&"ationMarkCount%2==0){
|
||||
valid=true;
|
||||
break;
|
||||
}
|
||||
data+=character;
|
||||
if(pastEquals&"ationMarkCount%2==0){
|
||||
valid=true;
|
||||
break;
|
||||
}
|
||||
if(character=='='&"ationMarkCount%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);
|
||||
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()-2);
|
||||
//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";
|
||||
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…
x
Reference in New Issue
Block a user