Created
June 27, 2013 19:13
-
-
Save DennisOSRM/5879466 to your computer and use it in GitHub Desktop.
Load street names of the planet file
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
std::vector<std::string> names; | |
std::ifstream namesInStream(namesPath.c_str(), std::ios::binary); | |
if(!namesInStream) { return -1; } | |
unsigned size(0); | |
namesInStream.read((char *)&size, sizeof(unsigned)); | |
char buf[1024]; | |
for(unsigned i = 0; i < size; ++i) { | |
unsigned sizeOfString = 0; | |
namesInStream.read((char *)&sizeOfString, sizeof(unsigned)); | |
buf[sizeOfString] = '\0'; // instead of memset | |
namesInStream.read(buf, sizeOfString); | |
names.push_back(buf); | |
} | |
std::vector<std::string>(names).swap(names); | |
namesInStream.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment