#include "pixelGameEngine.h" #include using namespace olc; struct XMLTag{ std::string tag; std::map data; const std::string FormatTagData(std::maptiles) { std::string displayStr=""; for (std::map::iterator it=data.begin();it!=data.end();it++) { displayStr+=" "+it->first+": "+it->second+"\n"; } return displayStr; } friend std::ostream& operator << (std::ostream& os, XMLTag& rhs) { os << rhs.tag <<"\n"<< 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{ XMLTag tag; std::vector> tiles; std::string str() { std::string displayStr=tag.tag+"\n"+tag.FormatTagData(tag.data); displayStr+=" DATA ("+std::to_string(tiles[0].size())+"x"+std::to_string(tiles.size())+")\n"; return displayStr; } }; struct Map{ XMLTag MapData; XMLTag TilesetData; std::vector LayerData; std::string FormatLayerData(std::ostream& os, std::vectortiles) { std::string displayStr; for (int i=0;i>data; if (newTag.tag.length()==0) { //Tag's empty, so first line is the tag. newTag.tag=data; std::cout<<"Tag: "<>data; if (data.empty()) continue; if (accumulator.length()>0) { //We're accumulating strings until we find '>' accumulator+=" "+data; //Check if it ends with '>' if (data[data.length()-1]=='>') { ParseTag(accumulator); accumulator=""; } } else if (data[0]=='<') { //Beginning of XML tag. accumulator=data; } else { //Start reading in data for this layer. std::vectorrowData; while (data.find(",")!=std::string::npos) { std::string datapiece = data.substr(0,data.find(",")); data = data.substr(data.find(",")+1,std::string::npos); rowData.push_back(stoi(datapiece)); } if (data.length()) { rowData.push_back(stoi(data)); } parsedMapInfo.LayerData[parsedMapInfo.LayerData.size()-1].tiles.push_back(rowData); } } std::cout<<"Parsed Map Data:\n"<