Created
July 19, 2022 15:44
-
-
Save ark-tik/78e41944cce789493f970ff9cf2370f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool LoadCsvLayerData(const pugi::xml_node &layerNode, const std::string &dataStr, buffers::TreeNode *resNode, | |
const int& tileWidth, const int& tileHeight) { | |
std::vector<unsigned int> globalTileIds; | |
std::istringstream istr(dataStr); | |
std::string line; | |
while(std::getline(istr, line)) { | |
std::stringstream lineStream(line); | |
std::string globalId; | |
while(std::getline(lineStream, globalId, ',')) { | |
// get the global tile ids into unsigned long, as stoui does not exist(it is guranteed to not overflow uint) | |
unsigned long gidULong = std::stoul(globalId); | |
if(gidULong > std::numeric_limits<unsigned int>::max()) { | |
errStream << "Error laoding tiles, global id out of range." << std::endl; | |
return false; | |
} | |
unsigned int gidUInt = static_cast<unsigned int>(gidULong); | |
globalTileIds.push_back(gidUInt); | |
} | |
} | |
// code truncated... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment