remwharead  0.8.6
Public Member Functions | List of all members
remwharead::Export::Bookmarks Class Reference

Export as Netscape bookmark file. More...

#include <remwharead/export/bookmarks.hpp>

Inheritance diagram for remwharead::Export::Bookmarks:
remwharead::Export::ExportBase

Public Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from remwharead::Export::ExportBase
list< Database::entrysort_entries (list< Database::entry > entries) const
 Sort entries from newest to oldest and remove duplicates. More...
 
 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
 
- Protected Attributes inherited from remwharead::Export::ExportBase
const list< Database::entry_entries
 
ostream & _out
 

Detailed Description

Export as Netscape bookmark file.

Since
0.6.0

Member Function Documentation

◆ ExportBase()

remwharead::Export::ExportBase::ExportBase
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

◆ print()

void remwharead::Export::Bookmarks::print ( ) const
overridevirtual

Print output to std::ostream.

Implements remwharead::Export::ExportBase.

30 {
31  _out << "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
32  "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; "
33  "charset=UTF-8\">\n"
34  "<TITLE>Bookmarks from remwharead</TITLE>\n"
35  "<H1>Bookmarks from remwharead<H1>\n\n"
36  "<DL><p>\n"
37  "<DT><H3>remwharead</H3>\n"
38  "<DL><p>\n";
39 
40  for (const Database::entry & entry : _entries)
41  {
42  string title = entry.title;
43  if (title.empty())
44  {
45  title = entry.uri;
46  }
47  system_clock::time_point tp = entry.datetime;
48  system_clock::duration duration = tp.time_since_epoch();
49  string time_seconds =
50  std::to_string(duration_cast<seconds>(duration).count());
51 
52  _out << "<DT><A HREF=\"" << entry.uri << "\" "
53  << "ADD_DATE=\"" << time_seconds << "\">"
54  << title << "</A>\n";
55  }
56  _out << "</DL><p>\n"
57  << "</DL><p>\n";
58 }

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