#include "FeatureFunction.hpp" FeatureFunction::FeatureFunction(const std::vector<std::string_view> & lines) { if (!util::doIfNameMatch(std::regex("Features :(.*)"), lines[0], [](auto){})) util::myThrow(fmt::format("Wrong line '{}', expected 'Features :'", lines[0])); for (unsigned int i = 1; i < lines.size(); i++) { if (util::doIfNameMatch(std::regex("(?: |\\t)*buffer from ((?:-|\\+|)\\d+) to ((?:-|\\+|)\\d+)"), lines[i], [this](auto &sm) { getOrCreateFeature(fmt::format("b.")); })) continue; util::myThrow(fmt::format("Unknown feature directive '{}'", lines[i])); } for (auto & it : features) fmt::print("{}\n", it.first); } FeatureFunction::Representation FeatureFunction::getRepresentation(const Config & config) const { Representation representation; return representation; } const FeatureFunction::Feature & FeatureFunction::getOrCreateFeature(const std::string & name) { auto found = features.find(name); if (found != features.end()) return found->second; if (util::doIfNameMatch(std::regex(""), name, [this,name](auto){features[name] = Feature();})) return features[name]; util::myThrow(fmt::format("Unknown feature '{}'", name)); return found->second; }