remwharead  0.8.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
remwharead::Export::ExportBase Class Referenceabstract

Base class for exports. More...

#include <remwharead/export/export.hpp>

Inheritance diagram for remwharead::Export::ExportBase:
remwharead::Export::AsciiDoc remwharead::Export::Bookmarks remwharead::Export::CSV remwharead::Export::JSON remwharead::Export::RSS remwharead::Export::Simple

Public Member Functions

 ExportBase (const list< Database::entry > &entries, ostream &out=cout)
 Export list of Database::entry. More...
 
virtual void print () const =0
 Print output to std::ostream. More...
 

Protected Member Functions

const list< Database::entrysort_entries (list< Database::entry > entries) const
 Sort entries from newest to oldest and remove duplicates. More...
 

Protected Attributes

const list< Database::entry_entries
 
ostream & _out
 

Detailed Description

Base class for exports.

Since
0.6.0

Constructor & Destructor Documentation

◆ ExportBase()

remwharead::Export::ExportBase::ExportBase ( const list< Database::entry > &  entries,
ostream &  out = cout 
)
explicit

Export list of Database::entry.

Parameters
entriesList of Database::entry to export.
outOutput stream.
25  : _entries(sort_entries(entries))
26  , _out(out)
27  {}
const list< Database::entry > sort_entries(list< Database::entry > entries) const
Sort entries from newest to oldest and remove duplicates.
Definition: export.cpp:30

Member Function Documentation

◆ print()

virtual void remwharead::Export::ExportBase::print ( ) const
pure virtual

◆ sort_entries()

const list< Database::entry > remwharead::Export::ExportBase::sort_entries ( list< Database::entry entries) const
protected

Sort entries from newest to oldest and remove duplicates.

Parameters
entriesList of Database::entry to sort.
Returns
Sorted list of Database::entry.
31  {
32  entries.sort([](const auto &a, const auto &b)
33  {
34  return (a.datetime > b.datetime);
35  });
36  entries.unique();
37 
38  return entries;
39  }

The documentation for this class was generated from the following files: