diff --git a/docs/adoc_8hpp_source.html b/docs/adoc_8hpp_source.html index 6444477..3bfbbd6 100644 --- a/docs/adoc_8hpp_source.html +++ b/docs/adoc_8hpp_source.html @@ -22,7 +22,7 @@
remwharead -  0.8.4 +  0.8.5
@@ -70,9 +70,9 @@ $(function() {
adoc.hpp
-
1 /* This file is part of remwharead.
2  * Copyright © 2019 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef REMWHAREAD_EXPORT_ADOC_HPP
18 #define REMWHAREAD_EXPORT_ADOC_HPP
19 
20 #include "export.hpp"
21 #include "sqlite.hpp"
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 namespace remwharead
27 {
28 namespace Export
29 {
30 using std::string;
31 
39 class AsciiDoc : protected ExportBase
40 {
41 public:
43 
44  void print() const override;
45 
46 private:
47  using tagmap = std::map<string, list<Database::entry>>;
48  using replacemap = const std::map<const string, const string>;
49 
51  string replace(string text, const replacemap &replacements) const;
52 
54  string replace_in_tag(const string &text) const;
55 
57  string replace_in_title(const string &text) const;
58 
60  string replace_in_uri(const string &text) const;
61 
63  void print_tags(const tagmap &tags) const;
64 
66  string get_day(const Database::entry &entry) const;
67 
69  string get_time(const Database::entry &entry) const;
70 };
71 } // namespace Export
72 } // namespace remwharead
73 
74 #endif // REMWHAREAD_EXPORT_ADOC_HPP
Export as AsciiDoc document.
Definition: adoc.hpp:39
-
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export list of Database::entry.
Definition: export.cpp:24
-
Base class for exports.
Definition: export.hpp:38
+
1 /* This file is part of remwharead.
2  * Copyright © 2019 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef REMWHAREAD_EXPORT_ADOC_HPP
18 #define REMWHAREAD_EXPORT_ADOC_HPP
19 
20 #include "export.hpp"
21 #include "sqlite.hpp"
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 namespace remwharead::Export
27 {
28 using std::string;
29 
37 class AsciiDoc : protected ExportBase
38 {
39 public:
41 
42  void print() const override;
43 
44 private:
45  using tagmap = std::map<string, list<Database::entry>>;
46  using replacemap = const std::map<const string, const string>;
47 
49  [[nodiscard]]
50  string replace(string text, const replacemap &replacements) const;
51 
53  [[nodiscard]]
54  string replace_in_tag(const string &text) const;
55 
57  [[nodiscard]]
58  string replace_in_title(const string &text) const;
59 
61  [[nodiscard]]
62  string replace_in_uri(const string &text) const;
63 
65  void print_tags(const tagmap &tags) const;
66 
68  [[nodiscard]]
69  string get_day(const Database::entry &entry) const;
70 
72  [[nodiscard]]
73  string get_time(const Database::entry &entry) const;
74 };
75 } // namespace remwharead::Export
76 
77 #endif // REMWHAREAD_EXPORT_ADOC_HPP
Export as AsciiDoc document.
Definition: adoc.hpp:37
+
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export list of Database::entry.
Definition: export.cpp:22
+
Base class for exports.
Definition: export.hpp:36
Describes a database entry.
Definition: sqlite.hpp:55
void print() const override
Print output to std::ostream.
diff --git a/docs/annotated.html b/docs/annotated.html index 5cb1c73..1d3618b 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -22,7 +22,7 @@
remwharead -  0.8.4 +  0.8.5
diff --git a/docs/bookmarks_8hpp_source.html b/docs/bookmarks_8hpp_source.html index 8d5e1c7..1502656 100644 --- a/docs/bookmarks_8hpp_source.html +++ b/docs/bookmarks_8hpp_source.html @@ -22,7 +22,7 @@
remwharead -  0.8.4 +  0.8.5
@@ -70,10 +70,10 @@ $(function() {
bookmarks.hpp
-
1 /* This file is part of remwharead.
2  * Copyright © 2019 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef REMWHAREAD_EXPORT_BOOKMARKS_HPP
18 #define REMWHAREAD_EXPORT_BOOKMARKS_HPP
19 
20 #include "export.hpp"
21 
22 namespace remwharead
23 {
24 namespace Export
25 {
33  class Bookmarks : protected ExportBase
34  {
35  public:
37 
38  void print() const override;
39  };
40 } // namespace Export
41 } // namespace remwharead
42 
43 #endif // REMWHAREAD_EXPORT_BOOKMARKS_HPP
void print() const override
Print output to std::ostream.
Definition: bookmarks.cpp:29
-
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export list of Database::entry.
Definition: export.cpp:24
-
Base class for exports.
Definition: export.hpp:38
-
Export as Netscape bookmark file.
Definition: bookmarks.hpp:33
+
1 /* This file is part of remwharead.
2  * Copyright © 2019 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef REMWHAREAD_EXPORT_BOOKMARKS_HPP
18 #define REMWHAREAD_EXPORT_BOOKMARKS_HPP
19 
20 #include "export.hpp"
21 
22 namespace remwharead::Export
23 {
31  class Bookmarks : protected ExportBase
32  {
33  public:
35 
36  void print() const override;
37  };
38 } // namespace remwharead::Export
39 
40 #endif // REMWHAREAD_EXPORT_BOOKMARKS_HPP
void print() const override
Print output to std::ostream.
Definition: bookmarks.cpp:29
+
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export list of Database::entry.
Definition: export.cpp:22
+
Base class for exports.
Definition: export.hpp:36
+
Export as Netscape bookmark file.
Definition: bookmarks.hpp:31

Member Function Documentation

@@ -151,7 +151,7 @@ Public Member Functions

Returns true if connected to the database.

Since
0.6.0
-
64 {
65  return _connected;
66 }
+
62 {
63  return _connected;
64 }
@@ -182,7 +182,7 @@ Public Member Functions

Retrieve a list of Database::entry from the database.

Since
0.6.0
-
117 {
118  try
119  {
120  Database::entry entrybuf;
121  string datetime;
122  string strtags;
123  Statement select(*_session);
124 
125  // bind() copies the value.
126  select << "SELECT * FROM remwharead WHERE datetime "
127  "BETWEEN ? AND ? ORDER BY datetime DESC;",
128  bind(timepoint_to_string(start, true)),
129  bind(timepoint_to_string(end, true)),
130  into(entrybuf.uri), into(entrybuf.archive_uri), into(datetime),
131  into(strtags), into(entrybuf.title), into(entrybuf.description),
132  into(entrybuf.fulltext), range(0, 1);
133 
134  list<entry> entries;
135 
136  while(!select.done() && select.execute() != 0)
137  {
138  entrybuf.datetime = string_to_timepoint(datetime, true);
139 
140  vector<string> tags;
141  size_t pos = 0;
142  while (pos != string::npos)
143  {
144  const size_t newpos = strtags.find(',', pos);
145  const string tag = strtags.substr(pos, newpos - pos);
146  if (!tag.empty())
147  {
148  tags.push_back(tag);
149  }
150  pos = newpos;
151  if (pos != string::npos)
152  {
153  ++pos;
154  }
155  }
156  entrybuf.tags = tags;
157 
158  entries.push_back(entrybuf);
159  }
160 
161  return entries;
162  }
163  catch (std::exception &e)
164  {
165  cerr << "Error in " << __func__ << ": " << e.what() << endl;
166  }
167 
168  return {};
169 }
+
115 {
116  try
117  {
118  Database::entry entrybuf;
119  string datetime;
120  string strtags;
121  Statement select(*_session);
122 
123  // bind() copies the value.
124  select << "SELECT * FROM remwharead WHERE datetime "
125  "BETWEEN ? AND ? ORDER BY datetime DESC;",
126  bind(timepoint_to_string(start, true)),
127  bind(timepoint_to_string(end, true)),
128  into(entrybuf.uri), into(entrybuf.archive_uri), into(datetime),
129  into(strtags), into(entrybuf.title), into(entrybuf.description),
130  into(entrybuf.fulltext), range(0, 1);
131 
132  list<entry> entries;
133 
134  while(!select.done() && select.execute() != 0)
135  {
136  entrybuf.datetime = string_to_timepoint(datetime, true);
137 
138  vector<string> tags;
139  size_t pos = 0;
140  while (pos != string::npos)
141  {
142  const size_t newpos = strtags.find(',', pos);
143  const string tag = strtags.substr(pos, newpos - pos);
144  if (!tag.empty())
145  {
146  tags.push_back(tag);
147  }
148  pos = newpos;
149  if (pos != string::npos)
150  {
151  ++pos;
152  }
153  }
154  entrybuf.tags = tags;
155 
156  entries.push_back(entrybuf);
157  }
158 
159  return entries;
160  }
161  catch (std::exception &e)
162  {
163  cerr << "Error in " << __func__ << ": " << e.what() << endl;
164  }
165 
166  return {};
167 }
@@ -203,7 +203,7 @@ Public Member Functions

Store a Database::entry in the database.

Since
0.6.0
-
85 {
86  try
87  {
88  const string strdatetime = timepoint_to_string(data.datetime, true);
89  string strtags;
90  Statement insert(*_session);
91 
92  for (const string &tag : data.tags)
93  {
94  strtags += tag;
95  if (tag != *(data.tags.rbegin()))
96  {
97  strtags += ",";
98  }
99  }
100 
101  // useRef() uses the const reference.
102  insert << "INSERT INTO remwharead "
103  "VALUES(?, ?, ?, ?, ?, ?, ?);",
104  useRef(data.uri), useRef(data.archive_uri),
105  useRef(strdatetime), useRef(strtags), useRef(data.title),
106  useRef(data.description), useRef(data.fulltext);
107  insert.execute();
108  }
109  catch (std::exception &e)
110  {
111  cerr << "Error in " << __func__ << ": " << e.what() << endl;
112  }
113 }
+
83 {
84  try
85  {
86  const string strdatetime = timepoint_to_string(data.datetime, true);
87  string strtags;
88  Statement insert(*_session);
89 
90  for (const string &tag : data.tags)
91  {
92  strtags += tag;
93  if (tag != *(data.tags.rbegin()))
94  {
95  strtags += ",";
96  }
97  }
98 
99  // useRef() uses the const reference.
100  insert << "INSERT INTO remwharead "
101  "VALUES(?, ?, ?, ?, ?, ?, ?);",
102  useRef(data.uri), useRef(data.archive_uri),
103  useRef(strdatetime), useRef(strtags), useRef(data.title),
104  useRef(data.description), useRef(data.fulltext);
105  insert.execute();
106  }
107  catch (std::exception &e)
108  {
109  cerr << "Error in " << __func__ << ": " << e.what() << endl;
110  }
111 }

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