| 225 | } // unnamed namespace |
| 226 | |
| 227 | IIndexArr ParseViewsFile(const String& filename, const Scene& scene) { |
| 228 | IIndexArr views; |
| 229 | std::ifstream file(filename); |
| 230 | if (!file.good()) { |
| 231 | VERBOSE("error: unable to open views file '%s'", filename.c_str()); |
| 232 | return views; |
| 233 | } |
| 234 | while (true) { |
| 235 | String imageName; |
| 236 | std::getline(file, imageName); |
| 237 | if (file.fail() || imageName.empty()) |
| 238 | break; |
| 239 | LPTSTR endIdx; |
| 240 | const IDX idx(strtoul(imageName, &endIdx, 10)); |
| 241 | const size_t szIndex(*endIdx == '\0' ? size_t(0) : imageName.size()); |
| 242 | FOREACH(idxImage, scene.images) { |
| 243 | const Image& image = scene.images[idxImage]; |
| 244 | if (szIndex == 0) { |
| 245 | // try to match by index |
| 246 | if (image.ID != idx) |
| 247 | continue; |
| 248 | } else { |
| 249 | // try to match by file name |
| 250 | const String name(Util::getFileNameExt(image.name)); |
| 251 | if (name.size() < szIndex || _tcsnicmp(name, imageName, szIndex) != 0) |
| 252 | continue; |
| 253 | } |
| 254 | views.emplace_back(idxImage); |
| 255 | break; |
| 256 | } |
| 257 | } |
| 258 | return views; |
| 259 | } |
| 260 | |
| 261 | int main(int argc, LPCTSTR* argv) |
| 262 | { |
no test coverage detected