2019-06-06 16:06:25 +02:00
|
|
|
/* This file is part of remwharead.
|
|
|
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-07-26 03:11:44 +02:00
|
|
|
#include <algorithm>
|
2019-08-03 20:10:20 +02:00
|
|
|
#include "export/export.hpp"
|
2019-06-06 16:06:25 +02:00
|
|
|
|
2019-07-27 09:59:43 +02:00
|
|
|
namespace remwharead
|
|
|
|
{
|
2019-06-06 16:06:25 +02:00
|
|
|
namespace Export
|
|
|
|
{
|
2019-08-08 15:19:42 +02:00
|
|
|
ExportBase::ExportBase(const list<Database::entry> &entries, ostream &out)
|
2019-07-26 03:11:44 +02:00
|
|
|
: _entries(sort_entries(entries))
|
2019-06-06 16:06:25 +02:00
|
|
|
, _out(out)
|
|
|
|
{}
|
2019-07-26 03:11:44 +02:00
|
|
|
|
2019-08-08 15:19:42 +02:00
|
|
|
const list<Database::entry>
|
|
|
|
ExportBase::sort_entries(list<Database::entry> entries) const
|
2019-07-26 03:11:44 +02:00
|
|
|
{
|
2019-08-08 15:19:42 +02:00
|
|
|
entries.sort([](const auto &a, const auto &b)
|
|
|
|
{
|
|
|
|
return (a.datetime > b.datetime);
|
|
|
|
});
|
2019-09-20 18:19:33 +02:00
|
|
|
entries.unique();
|
|
|
|
|
2019-07-26 03:11:44 +02:00
|
|
|
return entries;
|
|
|
|
}
|
2019-06-06 16:06:25 +02:00
|
|
|
}
|
2019-07-27 09:59:43 +02:00
|
|
|
}
|