#include "AtomBuilder.h" AtomBuilder::AtomBuilder(std::string templateUrl) { feed = readFile(templateUrl); int updateTagLocation = calculateStartOfIdentifierLocation(feed, ""); if (updateTagLocation == -1) printf("unable to find header update tag in AtomFeedTemplate"); feed.insert(updateTagLocation, getTimeString()); } std::string AtomBuilder::getTimeString() { // taken from https://en.cppreference.com/w/cpp/chrono/c/strftime std::time_t time = std::time({}); char timeString[std::size("yyyy-mm-ddThh:mm:ssZ")]; std::strftime(std::data(timeString), std::size(timeString), "%FT%TZ", std::gmtime(&time)); return timeString; } int AtomBuilder::calculateStartOfIdentifierLocation(std::string text, std::string id) { int location = text.find(id); if (location == std::string::npos) printf("Warning: no article found in given template file"); return location; } std::string AtomBuilder::readFile(std::string fileUrl) { std::ifstream file(fileUrl); std::stringstream fileCache; fileCache << file.rdbuf(); return fileCache.str(); } std::string AtomBuilder::getFeedHeader(std::string title, std::string link, std::string timestamp) { return "