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

30 lines
679 B
C++
Raw Normal View History

#include "exlparser.h"
#include <stdexcept>
EXL readEXL(std::string_view path) {
FILE* file = fopen(path.data(), "rb");
if(!file) {
throw std::runtime_error("Failed to read exl file from " + std::string(path.data()));
}
EXL exl;
char* data = nullptr;
size_t len = 0;
while ((getline(&data, &len, file)) != -1) {
std::string line = data;
const size_t comma = line.find_first_of(',');
std::string name = line.substr(0, comma);
2022-04-11 11:36:04 -04:00
if(name != "EXLT") {
std::string id = line.substr(comma + 1, line.length());
exl.rows.push_back({name, std::stoi(id)});
}
}
return exl;
}