Skip to content

Commit

Permalink
judge if the json_extention is .json
Browse files Browse the repository at this point in the history
  • Loading branch information
a1henu committed May 1, 2024
1 parent ef68dce commit fbdb46b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@
#include "utils.hpp"

// use CitationPtr to represent a shared pointer to Citation
bool hasJsonExtension(const std::string& filename) {
if (filename.size() < 5) {
return false;
}

return filename.substr(filename.size() - 5) == ".json";
}

std::unordered_map<std::string, CitationPtr> loadCitations(const std::string& filename) {
// FIXME: load citations from file
if (!hasJsonExtension(filename)) {
std::exit(1);
}

std::ifstream file{filename};
nlohmann::json citationJson;

Expand Down

0 comments on commit fbdb46b

Please sign in to comment.