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

Export as Netscape bookmark file. More...

#include <bookmarks.hpp>

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

Public Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from remwharead::Export::ExportBase
const vector< Database::entrysort_entries (vector< Database::entry > entries) const
 Sort entries from newest to oldest. More...
 
 ExportBase (const vector< Database::entry > &entries, ostream &out=cout)
 Export vector of Database::entry. More...
 
- Protected Attributes inherited from remwharead::Export::ExportBase
const vector< Database::entry_entries
 
ostream & _out
 

Detailed Description

Export as Netscape bookmark file.

Member Function Documentation

◆ ExportBase()

remwharead::Export::ExportBase::ExportBase
explicit

Export vector of Database::entry.

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

◆ 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  }
struct remwharead::Database::entry entry
Describes a database entry.

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