From 4994223aee0d98e16ed2f2effd8810fb0b4f9f1d Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 8 Aug 2019 11:28:50 +0200 Subject: [PATCH] 2019-08-08 --- docs/adoc_8hpp_source.html | 2 +- docs/annotated.html | 10 +- docs/classes.html | 14 +- docs/classremwharead_1_1Database.html | 14 +- docs/classremwharead_1_1Search-members.html | 87 +++++++ docs/classremwharead_1_1Search.html | 224 ++++++++++++++++++ docs/classremwharead_1_1URI-members.html | 6 +- docs/classremwharead_1_1URI.html | 82 ++++--- .../dir_d44c64559bbebec7f509842c48db8b23.html | 2 - docs/files.html | 2 +- docs/functions.html | 13 +- docs/functions_func.html | 13 +- docs/hierarchy.html | 20 +- docs/remwharead_8hpp_source.html | 3 +- docs/search/all_0.js | 3 +- docs/search/all_8.js | 2 +- docs/search/all_c.js | 4 +- docs/search/classes_0.js | 1 + docs/search/classes_6.js | 1 + docs/search/files_0.js | 3 +- docs/search/functions_0.js | 2 +- docs/search/functions_5.js | 2 +- docs/search/functions_9.js | 3 + docs/search/searchdata.js | 2 +- docs/search_8hpp_source.html | 6 +- docs/sqlite_8hpp_source.html | 16 +- ...structremwharead_1_1Database_1_1entry.html | 9 +- ...remwharead_1_1archive__answer-members.html | 88 +++++++ docs/structremwharead_1_1archive__answer.html | 117 +++++++++ ...ctremwharead_1_1html__extract-members.html | 7 +- docs/structremwharead_1_1html__extract.html | 20 +- docs/uri_8hpp_source.html | 23 +- 32 files changed, 700 insertions(+), 101 deletions(-) create mode 100644 docs/classremwharead_1_1Search-members.html create mode 100644 docs/classremwharead_1_1Search.html create mode 100644 docs/structremwharead_1_1archive__answer-members.html create mode 100644 docs/structremwharead_1_1archive__answer.html diff --git a/docs/adoc_8hpp_source.html b/docs/adoc_8hpp_source.html index d73b89e..09f70c5 100644 --- a/docs/adoc_8hpp_source.html +++ b/docs/adoc_8hpp_source.html @@ -73,7 +73,7 @@ $(function() {
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_ADOC_HPP
18 #define REMWHAREAD_ADOC_HPP
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include "sqlite.hpp"
24 #include "export.hpp"
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,vector<Database::entry>>;
48  using replacemap = const std::map<const string, const string>;
49 
51  const string replace(string text, const replacemap &replacements) const;
52 
54  const string replace_in_tag(const string &text) const;
55 
57  const string replace_in_title(const string &text) const;
58 
60  const string replace_in_uri(const string &text) const;
61 
63  void print_tags(const tagmap &tags) const;
64 
66  const string get_day(const Database::entry &entry) const;
67 
69  const string get_time(const Database::entry &entry) const;
70  };
71 }
72 }
73 
74 #endif // REMWHAREAD_ADOC_HPP
ExportBase(const vector< Database::entry > &entries, ostream &out=cout)
Export vector of Database::entry.
Definition: export.cpp:24
Export as AsciiDoc document.
Definition: adoc.hpp:39
Base class for exports.
Definition: export.hpp:39
-
Describes a database entry.
Definition: sqlite.hpp:46
+
Describes a database entry.
Definition: sqlite.hpp:53
Definition: bookmarks.cpp:22
void print() const override
Print output to std::ostream.
diff --git a/docs/annotated.html b/docs/annotated.html index c5ab386..21dc4c7 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -75,10 +75,12 @@ $(function() {  CCSVExport as Comma Separated Values  CExportBaseBase class for exports  CSimpleExport as simple list - CDatabaseStore and retrieve files from/to SQLite - CentryDescribes a database entry - Chtml_extractA processed HTML page - CURIDownload, archive and process an URI + Carchive_answerThe result of the call to the archive service + CDatabaseStore and retrieve files from/to SQLite + CentryDescribes a database entry + Chtml_extractA processed HTML page + CSearchSearch in database entries + CURIDownload, archive and process an URI diff --git a/docs/classes.html b/docs/classes.html index a49e139..96a461c 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -74,15 +74,15 @@ $(function() {
  s  
-AsciiDoc (remwharead::Export)   CSV (remwharead::Export)   Database::entry (remwharead)   Simple (remwharead::Export)    +archive_answer (remwharead)   CSV (remwharead::Export)   Database::entry (remwharead)   Search (remwharead)    +AsciiDoc (remwharead::Export)   
  d  
+ExportBase (remwharead::Export)   Simple (remwharead::Export)   
  b  
-
  d  
-ExportBase (remwharead::Export)   
  u  
+
  h  
+
  u  
-
  h  
- -Bookmarks (remwharead::Export)   Database (remwharead)   URI (remwharead)    -html_extract (remwharead)    +Database (remwharead)    +Bookmarks (remwharead::Export)   html_extract (remwharead)   URI (remwharead)   
a | b | c | d | e | h | s | u
diff --git a/docs/classremwharead_1_1Database.html b/docs/classremwharead_1_1Database.html index dff657a..b301a57 100644 --- a/docs/classremwharead_1_1Database.html +++ b/docs/classremwharead_1_1Database.html @@ -125,6 +125,7 @@ Public Member Functions

Describes a database entry.

+
Since
0.6.0
@@ -145,7 +146,8 @@ Public Member Functions

Connects to the database and creates it if necessary.

-
32  : _connected(false)
33  {
34  try
35  {
36  xdgHandle xdg;
37  xdgInitHandle(&xdg);
38  _dbpath = xdgDataHome(&xdg) / fs::path("remwharead");
39  xdgWipeHandle(&xdg);
40 
41  if (!fs::exists(_dbpath))
42  {
43  fs::create_directories(_dbpath);
44  }
45  _dbpath /= "database.sqlite";
46 
47  _con = std::make_unique<sqlite::connection>(_dbpath);
48  sqlite::execute(*_con, "CREATE TABLE IF NOT EXISTS remwharead("
49  "uri TEXT, archive_uri TEXT, datetime TEXT, "
50  "tags TEXT, title TEXT, description TEXT, "
51  "fulltext TEXT);", true);
52 
53  _connected = true;
54  }
55  catch (std::exception &e)
56  {
57  cerr << "Error in " << __func__ << ": " << e.what() << endl;
58  }
59  }
+
Since
0.6.0
+
34  : _connected(false)
35  {
36  try
37  {
38  xdgHandle xdg;
39  xdgInitHandle(&xdg);
40  _dbpath = xdgDataHome(&xdg) / fs::path("remwharead");
41  xdgWipeHandle(&xdg);
42 
43  if (!fs::exists(_dbpath))
44  {
45  fs::create_directories(_dbpath);
46  }
47  _dbpath /= "database.sqlite";
48 
49  Poco::Data::SQLite::Connector::registerConnector();
50  _session = std::make_unique<Session>("SQLite", _dbpath);
51  *_session << "CREATE TABLE IF NOT EXISTS remwharead("
52  "uri TEXT, archive_uri TEXT, datetime TEXT, "
53  "tags TEXT, title TEXT, description TEXT, fulltext TEXT);", now;
54 
55  _connected = true;
56  }
57  catch (std::exception &e)
58  {
59  cerr << "Error in " << __func__ << ": " << e.what() << endl;
60  }
61  }

Member Function Documentation

@@ -165,7 +167,8 @@ Public Member Functions

Returns true if connected to the database.

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

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

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

Store a Database::entry in the database.

-
83  {
84  try
85  {
86  const string strdatetime = timepoint_to_string(data.datetime, true);
87  string strtags;
88  for (const string &tag : data.tags)
89  {
90  strtags += tag;
91  if (tag != *(data.tags.rbegin()))
92  {
93  strtags += ",";
94  }
95  }
96 
97  sqlite::execute ins(*_con, "INSERT INTO remwharead "
98  "VALUES(?, ?, ?, ?, ?, ?, ?);");
99  ins % data.uri % data.archive_uri % strdatetime % strtags
100  % data.title % data.description % data.fulltext;
101  ins();
102  }
103  catch (std::exception &e)
104  {
105  cerr << "Error in " << __func__ << ": " << e.what() << endl;
106  }
107  }
+
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  }

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