|
|
|
@ -20,6 +20,21 @@ struct XMLTag{ |
|
|
|
|
rhs.FormatTagData(rhs.data) <<"\n"; |
|
|
|
|
|
|
|
|
|
return os; } |
|
|
|
|
|
|
|
|
|
int GetInteger(std::string dataTag) { |
|
|
|
|
return std::stoi(data[dataTag]); |
|
|
|
|
} |
|
|
|
|
double GetDouble(std::string dataTag) { |
|
|
|
|
return std::stod(data[dataTag]); |
|
|
|
|
} |
|
|
|
|
bool GetBool(std::string dataTag) { |
|
|
|
|
if (data[dataTag]=="0") { |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct LayerTag{ |
|
|
|
@ -53,6 +68,13 @@ struct Map{ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class TMXParser{ |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
Map GetData() { |
|
|
|
|
return parsedMapInfo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
Map parsedMapInfo; |
|
|
|
@ -71,6 +93,11 @@ class TMXParser{ |
|
|
|
|
} 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"; |
|
|
|
|
} |
|
|
|
@ -92,8 +119,8 @@ class TMXParser{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
TMXParser(){ |
|
|
|
|
std::ifstream f("00_test_room.tmx",std::ios::in); |
|
|
|
|
TMXParser(std::string file){ |
|
|
|
|
std::ifstream f(file,std::ios::in); |
|
|
|
|
|
|
|
|
|
std::string accumulator=""; |
|
|
|
|
|
|
|
|
|