112 std::cout <<
"Pass correct parameters. Usage: " << argv[0]
113 <<
" <folder of compressed bit files" << std::endl;
119 if(!boost::filesystem::exists(libPath)) {
120 std::cout <<
"The folder " << libPath.string().c_str() <<
" does not exist" << std::endl;
125 std::vector<ConfigBitMap> configMapVector;
126 std::vector<ElementConfigMap> elementMapVector;
132 std::ofstream dbFile(dbFilePath.string().c_str(), std::ofstream::binary);
134 std::cout <<
"Could not open file " << dbFilePath.string() <<
" to write" << std::endl;
139 PopulateMaps(libPath, tileMap, elementMapVector, configMapVector);
141 std::cout <<
"Opened file " << dbFilePath.string() <<
" to store library database" << std::endl;
142 dbFile.write(
"<<<<BITLIBDB>>>>", 16);
145 dataSize = tileMap.size();
146 dbFile.write((
char *) (&dataSize),
sizeof(dataSize));
151 TiletypeElementMap::const_iterator pTiletypes = tileMap.begin();
152 TiletypeElementMap::const_iterator eTiletypes = tileMap.end();
153 while(pTiletypes != eTiletypes) {
156 dataSize = pTiletypes->first.size();
157 dbFile.write((
const char *) &dataSize,
sizeof(dataSize));
158 dbFile.write((
const char *) pTiletypes->first.c_str(), pTiletypes->first.size());
159 dataSize = pTiletypes->second.size();
160 dbFile.write((
const char*) &dataSize,
sizeof(dataSize));
161 std::cout <<
"Tile type " << pTiletypes->first <<
" has " << pTiletypes->second.size()
162 <<
" elements." << std::endl;
165 ElementConfigMap::const_iterator pElements = pTiletypes->second.begin();
166 ElementConfigMap::const_iterator eElements = pTiletypes->second.end();
167 while(pElements != eElements) {
170 dataSize = pElements->first.size();
171 dbFile.write((
const char *) &dataSize,
sizeof(dataSize));
172 dbFile.write((
const char *) pElements->first.c_str(), pElements->first.size());
173 dataSize = pElements->second.size();
174 dbFile.write((
const char *) &dataSize,
sizeof(dataSize));
179 ConfigBitMap::const_iterator pConfigs = pElements->second.begin();
180 ConfigBitMap::const_iterator eConfigs = pElements->second.end();
181 while(pConfigs != eConfigs) {
183 dataSize = pConfigs->first.size();
184 dbFile.write((
const char *) &dataSize,
sizeof(dataSize));
185 dbFile.write(pConfigs->first.c_str(), pConfigs->first.size());
186 dataSize = pConfigs->second.size();
187 dbFile.write((
const char *) &dataSize,
sizeof(dataSize));
190 for(std::vector<uint32_t>::const_iterator iter = pConfigs->second.begin(); iter
191 != pConfigs->second.end(); iter++) {
192 dbFile.write((
char *) &*iter,
sizeof(uint32_t));
void PopulateMaps(boost::filesystem::path libPath, TiletypeElementMap &outTileMap, std::vector< ElementConfigMap > &outElemMapVector, std::vector< ConfigBitMap > &outConfigMapVector)
boost::filesystem::path path
std::map< const std::string, ElementConfigMap > TiletypeElementMap
const std::string kFamily