remwharead/src/lib/export/export.cpp

42 lines
1.2 KiB
C++
Raw Normal View History

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/>.
*/
#include <algorithm>
#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
{
ExportBase::ExportBase(const list<Database::entry> &entries, ostream &out)
: _entries(sort_entries(entries))
2019-06-06 16:06:25 +02:00
, _out(out)
{}
const list<Database::entry>
ExportBase::sort_entries(list<Database::entry> entries) const
{
entries.sort([](const auto &a, const auto &b)
{
return (a.datetime > b.datetime);
});
2019-09-20 18:19:33 +02:00
entries.unique();
return entries;
}
2019-06-06 16:06:25 +02:00
}
2019-07-27 09:59:43 +02:00
}