Commit e9a03129 authored by Igor Danielewicz's avatar Igor Danielewicz

Removed Format function class

parent 4204e9b4
......@@ -36,8 +36,6 @@ Function* ConfigParser::str2function(std::string name, ptree& config)
{
if(name == "replace")
return new Replace(config);
if(name == "format")
return new Format(config);
else
return nullptr;
}
......
#pragma once
#include "functions/Function.hpp"
#include "functions/Replace.hpp"
#include "functions/Format.hpp"
#include "textIterators/TextIterator.hpp"
#include "textIterators/LineIterator.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;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment