Archived
1
Fork 0
This repository has been archived on 2025-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
libxiv/src/exlparser.cpp
Joshua Goins 79c482ac97 Fix compilation on MSVC
Pugixml is now downloaded if not found, and the CMake messages are now
clearer that the dependency is downloaded from the internet.

The POSIX getline function is now replaced with std::getline, which
works on MSVC.
2022-04-15 21:01:17 -04:00

30 lines
No EOL
668 B
C++

#include "exlparser.h"
#include <stdexcept>
#include <fstream>
EXL readEXL(std::string_view path) {
std::fstream file;
file.open(path.data(), std::iostream::in);
if(!file.is_open()) {
throw std::runtime_error("Failed to read exl file from " + std::string(path.data()));
}
EXL exl;
std::string line;
while (std::getline(file, line)) {
const size_t comma = line.find_first_of(',');
std::string name = line.substr(0, comma);
if(name != "EXLT") {
std::string id = line.substr(comma + 1, line.length());
exl.rows.push_back({name, std::stoi(id)});
}
}
return exl;
}