Skip to content
Snippets Groups Projects
Commit e9a03129 authored by Igor Danielewicz's avatar Igor Danielewicz
Browse files

Removed Format function class

parent 4204e9b4
No related branches found
No related tags found
No related merge requests found
...@@ -36,8 +36,6 @@ Function* ConfigParser::str2function(std::string name, ptree& config) ...@@ -36,8 +36,6 @@ Function* ConfigParser::str2function(std::string name, ptree& config)
{ {
if(name == "replace") if(name == "replace")
return new Replace(config); return new Replace(config);
if(name == "format")
return new Format(config);
else else
return nullptr; return nullptr;
} }
......
#pragma once #pragma once
#include "functions/Function.hpp" #include "functions/Function.hpp"
#include "functions/Replace.hpp" #include "functions/Replace.hpp"
#include "functions/Format.hpp"
#include "textIterators/TextIterator.hpp" #include "textIterators/TextIterator.hpp"
#include "textIterators/LineIterator.hpp" #include "textIterators/LineIterator.hpp"
#include "textIterators/TokenIterator.hpp" #include "textIterators/TokenIterator.hpp"
......
#include "functions/Format.hpp"
#include <iostream>
using ptree = boost::property_tree::ptree;
std::string remove_line_breaks(std::string str)
{
static std::regex reg = std::regex("[-–]\n");
std::string to("");
return std::regex_replace(str, reg, to);
}
std::string remove_page_numbers(std::string str)// TODO
{
// static std::regex reg = std::regex("[0-9]");
// std::string to("[|]");
// return std::regex_replace(str, reg, to);
return str;
}
Format::Format(ptree& config)// TODO
{
tasks.emplace_back(remove_line_breaks);
// if(config.get<std::string>("function") == "all")
// {
// tasks.emplace_back(remove_line_breaks);
// tasks.emplace_back(remove_page_numbers);
// }
// else
// {
// ;// config.get_child("functions");
// }
// std::string from = config.get<std::string>("from");
// auto flags = std::regex_constants::optimize;
// if(!config.get<bool>("case_sensitive", true))
// flags = flags | std::regex_constants::icase;
// reg = std::regex(from, flags);
}
std::string Format::process(std::string str)
{
for(auto& task : tasks)
{
str = task(str);
}
return str;
}
#pragma once
#include <boost/property_tree/ptree.hpp>
#include <queue>
#include <functional>
#include <regex>
#include "functions/Function.hpp"
using ptree = boost::property_tree::ptree;
class Format : public Function
{
public:
Format(ptree& config);
std::string process(std::string str);
private:
std::deque<std::function<std::string(std::string)>> tasks;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment