#define XERR
#include "handler.ih"

void Handler::filter(ostream &out, istream &in)
{
    string line;

    string rater = d_rater.empty() ? "--" : "Previously rated by " + d_rater;

    string timestamp = d_date.substr(d_date.rfind(':') - 5, 5);
    log() << "date: " << d_date << ", timestamp: " << timestamp << '\n';

    while (getline(in, line))
    {
        replace(line, "${TITLE}", d_set);
        replace(line, "${AUTHOR}", d_author);
        replace(line, "${RATER}", rater);
        replace(line, "${TIME}", timestamp);

                                                // insert the order.txt files
        sections(out, line, "${SECTIONS}");     // into the pdf
        out << line << '\n';
    }
}




