remwharead  0.8.5
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...
 
 ExportBase (const ExportBase &)=delete
 
ExportBaseoperator= (const ExportBase &)=delete
 
 ExportBase (ExportBase &&)=delete
 
ExportBaseoperator= (ExportBase &&)=delete
 
virtual void print () const =0
 Print output to std::ostream. More...
 

Protected Member Functions

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.
23  : _entries(sort_entries(entries))
24  , _out(out)
25 {}
list< Database::entry > sort_entries(list< Database::entry > entries) const
Sort entries from newest to oldest and remove duplicates.
Definition: export.cpp:28

Member Function Documentation

◆ print()

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

◆ sort_entries()

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.
29 {
30  entries.sort([](const auto &a, const auto &b)
31  {
32  return (a.datetime > b.datetime);
33  });
34  entries.unique();
35 
36  return entries;
37 }

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