From 2eba355ce6156f14bf44487299bce67d29832770 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 8 Aug 2019 22:27:26 +0200 Subject: [PATCH] 2019-08-08 --- docs/adoc_8hpp_source.html | 2 +- docs/bookmarks_8hpp_source.html | 2 +- docs/classremwharead_1_1Database.html | 4 ++-- docs/classremwharead_1_1Export_1_1AsciiDoc.html | 8 ++++---- docs/classremwharead_1_1Export_1_1Bookmarks.html | 8 ++++---- docs/classremwharead_1_1Export_1_1CSV.html | 8 ++++---- docs/classremwharead_1_1Export_1_1ExportBase.html | 10 +++++----- docs/classremwharead_1_1Export_1_1Simple.html | 8 ++++---- docs/classremwharead_1_1Search.html | 4 ++-- docs/csv_8hpp_source.html | 2 +- docs/export_8hpp_source.html | 2 +- docs/simple_8hpp_source.html | 2 +- docs/sqlite_8hpp_source.html | 2 +- 13 files changed, 31 insertions(+), 31 deletions(-) diff --git a/docs/adoc_8hpp_source.html b/docs/adoc_8hpp_source.html index 5120042..5d3dddb 100644 --- a/docs/adoc_8hpp_source.html +++ b/docs/adoc_8hpp_source.html @@ -71,7 +71,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, list<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
Export as AsciiDoc document.
Definition: adoc.hpp:39
-
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export vector of Database::entry.
Definition: export.cpp:24
+
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:39
Describes a database entry.
Definition: sqlite.hpp:55
void print() const override
Print output to std::ostream.
diff --git a/docs/bookmarks_8hpp_source.html b/docs/bookmarks_8hpp_source.html index 939ff04..598b7d6 100644 --- a/docs/bookmarks_8hpp_source.html +++ b/docs/bookmarks_8hpp_source.html @@ -71,7 +71,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_BOOKMARKS_HPP
18 #define REMWHAREAD_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  virtual void print() const override;
38  };
39 }
40 }
41 
42 #endif // REMWHAREAD_BOOKMARKS_HPP
virtual void print() const override
Print output to std::ostream.
Definition: bookmarks.cpp:29
-
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export vector of Database::entry.
Definition: export.cpp:24
+
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:39
Export as Netscape bookmark file.
Definition: bookmarks.hpp:33
diff --git a/docs/classremwharead_1_1Database.html b/docs/classremwharead_1_1Database.html index b4c47e0..cfb9ba0 100644 --- a/docs/classremwharead_1_1Database.html +++ b/docs/classremwharead_1_1Database.html @@ -105,7 +105,7 @@ Public Member Functions  Store a Database::entry in the database. More...
  const list< entryretrieve (const time_point &start=time_point(), const time_point &end=system_clock::now()) const - Retrieve a vector of Database::entry from the database. More...
+ Retrieve a list of Database::entry from the database. More...
 

Detailed Description

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

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

+

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

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  list<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.
diff --git a/docs/classremwharead_1_1Export_1_1AsciiDoc.html b/docs/classremwharead_1_1Export_1_1AsciiDoc.html index 0ee46f7..b5d9dab 100644 --- a/docs/classremwharead_1_1Export_1_1AsciiDoc.html +++ b/docs/classremwharead_1_1Export_1_1AsciiDoc.html @@ -94,7 +94,7 @@ Public Member Functions  Print output to std::ostream. More...
   ExportBase (const list< Database::entry > &entries, ostream &out=cout) - Export vector of Database::entry. More...
+ Export list of Database::entry. More...
  - +
-

Export vector of Database::entry.

+

Export list of Database::entry.

Parameters

@@ -104,7 +104,7 @@ Additional Inherited Members

 Sort entries from newest to oldest. More...
 
 ExportBase (const list< Database::entry > &entries, ostream &out=cout)
 Export vector of Database::entry. More...
 Export list of Database::entry. More...
 
- Protected Attributes inherited from remwharead::Export::ExportBase
@@ -138,10 +138,10 @@ ostream & _out
- +
entriesVector of Database::entry to export.
entriesList of Database::entry to export.
outOutput stream.
diff --git a/docs/classremwharead_1_1Export_1_1Bookmarks.html b/docs/classremwharead_1_1Export_1_1Bookmarks.html index 84324d1..d1652bb 100644 --- a/docs/classremwharead_1_1Export_1_1Bookmarks.html +++ b/docs/classremwharead_1_1Export_1_1Bookmarks.html @@ -94,7 +94,7 @@ Public Member Functions  Print output to std::ostream. More...
   ExportBase (const list< Database::entry > &entries, ostream &out=cout) - Export vector of Database::entry. More...
+ Export list of Database::entry. More...
  - +
-

Export vector of Database::entry.

+

Export list of Database::entry.

Parameters

@@ -104,7 +104,7 @@ Additional Inherited Members

 Sort entries from newest to oldest. More...
 
 ExportBase (const list< Database::entry > &entries, ostream &out=cout)
 Export vector of Database::entry. More...
 Export list of Database::entry. More...
 
- Protected Attributes inherited from remwharead::Export::ExportBase
@@ -138,10 +138,10 @@ ostream & _out
- +
entriesVector of Database::entry to export.
entriesList of Database::entry to export.
outOutput stream.
diff --git a/docs/classremwharead_1_1Export_1_1CSV.html b/docs/classremwharead_1_1Export_1_1CSV.html index 5ea2b43..1ff97c7 100644 --- a/docs/classremwharead_1_1Export_1_1CSV.html +++ b/docs/classremwharead_1_1Export_1_1CSV.html @@ -94,7 +94,7 @@ Public Member Functions  Print output to std::ostream. More...
   ExportBase (const list< Database::entry > &entries, ostream &out=cout) - Export vector of Database::entry. More...
+ Export list of Database::entry. More...
  - +
-

Export vector of Database::entry.

+

Export list of Database::entry.

Parameters

@@ -104,7 +104,7 @@ Additional Inherited Members

 Sort entries from newest to oldest. More...
 
 ExportBase (const list< Database::entry > &entries, ostream &out=cout)
 Export vector of Database::entry. More...
 Export list of Database::entry. More...
 
- Protected Attributes inherited from remwharead::Export::ExportBase
@@ -138,10 +138,10 @@ ostream & _out
- +
entriesVector of Database::entry to export.
entriesList of Database::entry to export.
outOutput stream.
diff --git a/docs/classremwharead_1_1Export_1_1ExportBase.html b/docs/classremwharead_1_1Export_1_1ExportBase.html index af76cfe..5041310 100644 --- a/docs/classremwharead_1_1Export_1_1ExportBase.html +++ b/docs/classremwharead_1_1Export_1_1ExportBase.html @@ -96,7 +96,7 @@ Inheritance diagram for remwharead::Export::ExportBase:

Public Member Functions

 ExportBase (const list< Database::entry > &entries, ostream &out=cout) - Export vector of Database::entry. More...
+ Export list of Database::entry. More...
  virtual void print () const =0  Print output to std::ostream. More...
@@ -155,10 +155,10 @@ ostream & _out
-

Export vector of Database::entry.

+

Export list of Database::entry.

Parameters
- +
entriesVector of Database::entry to export.
entriesList of Database::entry to export.
outOutput stream.
@@ -224,11 +224,11 @@ ostream & _outSort entries from newest to oldest.

Parameters
- +
entriesVector of Database::entry to sort.
entriesList of Database::entry to sort.
-
Returns
Sorted vector of Database::entry.
+
Returns
Sorted list of Database::entry.
31  {
32  entries.sort([](const auto &a, const auto &b)
33  {
34  return (a.datetime > b.datetime);
35  });
36  return entries;
37  }
diff --git a/docs/classremwharead_1_1Export_1_1Simple.html b/docs/classremwharead_1_1Export_1_1Simple.html index 5ff1c34..a2f8afe 100644 --- a/docs/classremwharead_1_1Export_1_1Simple.html +++ b/docs/classremwharead_1_1Export_1_1Simple.html @@ -94,7 +94,7 @@ Public Member Functions  Print output to std::ostream. More...
   ExportBase (const list< Database::entry > &entries, ostream &out=cout) - Export vector of Database::entry. More...
+ Export list of Database::entry. More...
  - +
-

Export vector of Database::entry.

+

Export list of Database::entry.

Parameters

@@ -104,7 +104,7 @@ Additional Inherited Members

 Sort entries from newest to oldest. More...
 
 ExportBase (const list< Database::entry > &entries, ostream &out=cout)
 Export vector of Database::entry. More...
 Export list of Database::entry. More...
 
- Protected Attributes inherited from remwharead::Export::ExportBase
@@ -138,10 +138,10 @@ ostream & _out
- +
entriesVector of Database::entry to export.
entriesList of Database::entry to export.
outOutput stream.
diff --git a/docs/classremwharead_1_1Search.html b/docs/classremwharead_1_1Search.html index 476a6b3..a2d10a1 100644 --- a/docs/classremwharead_1_1Search.html +++ b/docs/classremwharead_1_1Search.html @@ -160,7 +160,7 @@ Public Member Functions -
Returns
Vector of matching Database::entry.
+
Returns
List of matching Database::entry.
Since
0.7.0
123  {
124  vector<vector<string>> searchlist = parse_expression(expression);
125  list<DB::entry> result = search_tags(expression, is_re);
126 
127  for (const vector<string> &terms_or : searchlist)
128  {
129  for (const DB::entry &entry : _entries)
130  {
131  // Add entry to result if all terms in an OR-slice match title,
132  // description or full text.
133  bool matched_title = true;
134  bool matched_description = true;
135  bool matched_fulltext = true;
136 
137  const auto it = find(result.begin(), result.end(), entry);
138  if (it != result.end())
139  { // Skip if already in result list.
140  continue;
141  }
142 
143  for (const string &term : terms_or)
144  {
145  const string title = to_lowercase(entry.title);
146  const string description = to_lowercase(entry.description);
147  const string fulltext = to_lowercase(entry.fulltext);
148 
149  // Set matched_* to false if term is not found.
150  if (is_re)
151  {
152  const regex re(term);
153 
154  if(!regex_search(title, re))
155  {
156  matched_title = false;
157  }
158 
159  if(!regex_search(description, re))
160  {
161  matched_description = false;
162  }
163 
164  if(!regex_search(fulltext, re))
165  {
166  matched_fulltext = false;
167  }
168  }
169  else
170  {
171  if (title.find(term) == string::npos)
172  {
173  matched_title = false;
174  }
175 
176  if (description.find(term) == string::npos)
177  {
178  matched_description = false;
179  }
180 
181  if (fulltext.find(term) == string::npos)
182  {
183  matched_fulltext = false;
184  }
185  }
186  }
187  if (matched_title == true
188  || matched_description == true
189  || matched_fulltext == true)
190  {
191  result.push_back(entry);
192  }
193  }
194  }
195 
196  return result;
197  }
struct remwharead::Database::entry entry
Describes a database entry.
const list< Database::entry > search_tags(string expression, const bool is_re) const
Search in tags of database entries.
Definition: search.cpp:77
@@ -202,7 +202,7 @@ Public Member Functions -
Returns
Vector of matching Database::entry.
+
Returns
List of matching Database::entry.
Since
0.7.0
79  {
80  vector<vector<string>> searchlist = parse_expression(expression);
81  list<DB::entry> result;
82 
83  for (const vector<string> &tags_or : searchlist)
84  {
85  for (const DB::entry &entry : _entries)
86  { // Add entry to result if all tags in an OR-slice match.
87  bool matched = true;
88 
89  for (const string &tag : tags_or)
90  {
91  const auto it = find_if(
92  entry.tags.begin(), entry.tags.end(),
93  [&, is_re](string s)
94  {
95  s = to_lowercase(s);
96  if (is_re)
97  {
98  const regex re("^" + tag + "$");
99  return regex_search(s, re);
100  }
101  else
102  {
103  return (s == tag);
104  }
105  });
106  if (it == entry.tags.end())
107  {
108  matched = false;
109  }
110  }
111  if (matched == true)
112  {
113  result.push_back(entry);
114  }
115  }
116  }
117 
118  return result;
119  }
struct remwharead::Database::entry entry
Describes a database entry.
diff --git a/docs/csv_8hpp_source.html b/docs/csv_8hpp_source.html index f7afc09..1a41a5a 100644 --- a/docs/csv_8hpp_source.html +++ b/docs/csv_8hpp_source.html @@ -70,7 +70,7 @@ $(function() {
csv.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_CSV_HPP
18 #define REMWHAREAD_CSV_HPP
19 
20 #include <string>
21 #include "export.hpp"
22 
23 namespace remwharead
24 {
25 namespace Export
26 {
27  using std::string;
28 
36  class CSV : protected ExportBase
37  {
38  public:
40 
41  virtual void print() const override;
42 
43  private:
45  const string quote(string field) const;
46  };
47 }
48 }
49 
50 #endif // REMWHAREAD_CSV_HPP
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export vector of Database::entry.
Definition: export.cpp:24
+
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_CSV_HPP
18 #define REMWHAREAD_CSV_HPP
19 
20 #include <string>
21 #include "export.hpp"
22 
23 namespace remwharead
24 {
25 namespace Export
26 {
27  using std::string;
28 
36  class CSV : protected ExportBase
37  {
38  public:
40 
41  virtual void print() const override;
42 
43  private:
45  const string quote(string field) const;
46  };
47 }
48 }
49 
50 #endif // REMWHAREAD_CSV_HPP
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:39
virtual void print() const override
Print output to std::ostream.
Definition: csv.cpp:25
Export as Comma Separated Values.
Definition: csv.hpp:36
diff --git a/docs/export_8hpp_source.html b/docs/export_8hpp_source.html index 7552dac..efd410e 100644 --- a/docs/export_8hpp_source.html +++ b/docs/export_8hpp_source.html @@ -70,7 +70,7 @@ $(function() {
export.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_HPP
18 #define REMWHAREAD_EXPORT_HPP
19 
20 #include <list>
21 #include <iostream>
22 #include "sqlite.hpp"
23 
24 using std::list;
25 using std::ostream;
26 using std::cout;
27 
28 namespace remwharead
29 {
30 namespace Export
31 {
39  class ExportBase
40  {
41  public:
48  explicit ExportBase(const list<Database::entry> &entries,
49  ostream &out = cout);
50 
54  virtual void print() const = 0;
55 
56  protected:
57  const list<Database::entry> _entries;
58  ostream &_out;
59 
67  const list<Database::entry>
68  sort_entries(list<Database::entry> entries) const;
69  };
70 }
71 }
72 
73 #endif // REMWHAREAD_EXPORT_HPP
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export vector of Database::entry.
Definition: export.cpp:24
+
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_HPP
18 #define REMWHAREAD_EXPORT_HPP
19 
20 #include <list>
21 #include <iostream>
22 #include "sqlite.hpp"
23 
24 using std::list;
25 using std::ostream;
26 using std::cout;
27 
28 namespace remwharead
29 {
30 namespace Export
31 {
39  class ExportBase
40  {
41  public:
48  explicit ExportBase(const list<Database::entry> &entries,
49  ostream &out = cout);
50 
54  virtual void print() const = 0;
55 
56  protected:
57  const list<Database::entry> _entries;
58  ostream &_out;
59 
67  const list<Database::entry>
68  sort_entries(list<Database::entry> entries) const;
69  };
70 }
71 }
72 
73 #endif // REMWHAREAD_EXPORT_HPP
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export list of Database::entry.
Definition: export.cpp:24
const list< Database::entry > sort_entries(list< Database::entry > entries) const
Sort entries from newest to oldest.
Definition: export.cpp:30
Base class for exports.
Definition: export.hpp:39
virtual void print() const =0
Print output to std::ostream.
diff --git a/docs/simple_8hpp_source.html b/docs/simple_8hpp_source.html index 30ef958..7780958 100644 --- a/docs/simple_8hpp_source.html +++ b/docs/simple_8hpp_source.html @@ -70,7 +70,7 @@ $(function() {
simple.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_SIMPLE_HPP
18 #define REMWHAREAD_SIMPLE_HPP
19 
20 #include "export.hpp"
21 
22 namespace remwharead
23 {
24 namespace Export
25 {
33  class Simple : protected ExportBase
34  {
35  public:
37  virtual void print() const override;
38  };
39 }
40 }
41 
42 #endif // REMWHAREAD_SIMPLE_HPP
ExportBase(const list< Database::entry > &entries, ostream &out=cout)
Export vector of Database::entry.
Definition: export.cpp:24
+
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_SIMPLE_HPP
18 #define REMWHAREAD_SIMPLE_HPP
19 
20 #include "export.hpp"
21 
22 namespace remwharead
23 {
24 namespace Export
25 {
33  class Simple : protected ExportBase
34  {
35  public:
37  virtual void print() const override;
38  };
39 }
40 }
41 
42 #endif // REMWHAREAD_SIMPLE_HPP
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:39
virtual void print() const override
Print output to std::ostream.
Definition: simple.cpp:26
Export as simple list.
Definition: simple.hpp:33
diff --git a/docs/sqlite_8hpp_source.html b/docs/sqlite_8hpp_source.html index 5db1d98..951c516 100644 --- a/docs/sqlite_8hpp_source.html +++ b/docs/sqlite_8hpp_source.html @@ -71,7 +71,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_SQLITE_HPP
18 #define REMWHAREAD_SQLITE_HPP
19 
20 #include <experimental/filesystem>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 #include <chrono>
25 #include <list>
26 #include <Poco/Data/Session.h>
27 
28 namespace remwharead
29 {
30  namespace fs = std::experimental::filesystem;
31  using std::string;
32  using std::vector;
33  using std::chrono::system_clock;
34  using time_point = system_clock::time_point;
35  using std::list;
36  using Poco::Data::Session;
37 
45  class Database
46  {
47  public:
55  typedef struct entry
56  {
57  string uri;
58  string archive_uri;
59  time_point datetime;
60  vector<string> tags;
61  string title;
62  string description;
63  string fulltext;
64 
70  friend bool operator ==(const Database::entry &a,
71  const Database::entry &b);
72 
78  const string fulltext_oneline() const;
79  } entry;
80 
86  Database();
87 
93  operator bool() const;
94 
100  void store(const entry &data) const;
101 
107  const list<entry> retrieve(
108  const time_point &start = time_point(),
109  const time_point &end = system_clock::now()) const;
110 
111  private:
112  fs::path _dbpath;
113  std::unique_ptr<Session> _session;
114  bool _connected;
115  };
116 
117  using DB = Database;
118 }
119 
120 #endif // REMWHAREAD_SQLITE_HPP
struct remwharead::Database::entry entry
Describes a database entry.
-
const list< entry > retrieve(const time_point &start=time_point(), const time_point &end=system_clock::now()) const
Retrieve a vector of Database::entry from the database.
Definition: sqlite.cpp:115
+
const list< entry > retrieve(const time_point &start=time_point(), const time_point &end=system_clock::now()) const
Retrieve a list of Database::entry from the database.
Definition: sqlite.cpp:115
Store and retrieve files from/to SQLite.
Definition: sqlite.hpp:45
void store(const entry &data) const
Store a Database::entry in the database.
Definition: sqlite.cpp:84
Describes a database entry.
Definition: sqlite.hpp:55