Changed vector<Database::entry> to list<Database::entry>.
This commit is contained in:
parent
d946d25a5b
commit
c0d10423ba
|
@ -44,7 +44,7 @@ namespace Export
|
|||
void print() const override;
|
||||
|
||||
private:
|
||||
using tagmap = std::map<string,vector<Database::entry>>;
|
||||
using tagmap = std::map<string, list<Database::entry>>;
|
||||
using replacemap = const std::map<const string, const string>;
|
||||
|
||||
//! Replace strings in text.
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
#ifndef REMWHAREAD_EXPORT_HPP
|
||||
#define REMWHAREAD_EXPORT_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include "sqlite.hpp"
|
||||
|
||||
using std::vector;
|
||||
using std::list;
|
||||
using std::ostream;
|
||||
using std::cout;
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace Export
|
|||
* @param entries Vector of Database::entry to export.
|
||||
* @param out Output stream.
|
||||
*/
|
||||
explicit ExportBase(const vector<Database::entry> &entries,
|
||||
explicit ExportBase(const list<Database::entry> &entries,
|
||||
ostream &out = cout);
|
||||
|
||||
/*!
|
||||
|
@ -54,7 +54,7 @@ namespace Export
|
|||
virtual void print() const = 0;
|
||||
|
||||
protected:
|
||||
const vector<Database::entry> _entries;
|
||||
const list<Database::entry> _entries;
|
||||
ostream &_out;
|
||||
|
||||
/*!
|
||||
|
@ -64,8 +64,8 @@ namespace Export
|
|||
*
|
||||
* @return Sorted vector of Database::entry.
|
||||
*/
|
||||
const vector<Database::entry>
|
||||
sort_entries(vector<Database::entry> entries) const;
|
||||
const list<Database::entry>
|
||||
sort_entries(list<Database::entry> entries) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,16 @@
|
|||
#ifndef REMWHAREAD_SEARCH_HPP
|
||||
#define REMWHAREAD_SEARCH_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "sqlite.hpp"
|
||||
|
||||
namespace remwharead
|
||||
{
|
||||
using std::vector;
|
||||
using std::list;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
/*!
|
||||
* @brief Search in database entries.
|
||||
|
@ -41,7 +43,7 @@ namespace remwharead
|
|||
*
|
||||
* @since 0.7.0
|
||||
*/
|
||||
explicit Search(const vector<Database::entry> &entries);
|
||||
explicit Search(const list<Database::entry> &entries);
|
||||
|
||||
/*!
|
||||
* @brief Search in tags of database entries.
|
||||
|
@ -55,7 +57,7 @@ namespace remwharead
|
|||
*
|
||||
* @since 0.7.0
|
||||
*/
|
||||
const vector<Database::entry> search_tags(string expression,
|
||||
const list<Database::entry> search_tags(string expression,
|
||||
const bool is_re) const;
|
||||
|
||||
/*!
|
||||
|
@ -71,11 +73,11 @@ namespace remwharead
|
|||
*
|
||||
* @since 0.7.0
|
||||
*/
|
||||
const vector<Database::entry> search_all(string expression,
|
||||
const list<Database::entry> search_all(string expression,
|
||||
const bool is_re) const;
|
||||
|
||||
private:
|
||||
const vector<Database::entry> _entries;
|
||||
const list<Database::entry> _entries;
|
||||
|
||||
/*!
|
||||
* @brief Split expression into subexpressions.
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <list>
|
||||
#include <Poco/Data/Session.h>
|
||||
|
||||
namespace remwharead
|
||||
|
@ -31,6 +32,7 @@ namespace remwharead
|
|||
using std::vector;
|
||||
using std::chrono::system_clock;
|
||||
using time_point = system_clock::time_point;
|
||||
using std::list;
|
||||
using Poco::Data::Session;
|
||||
|
||||
/*!
|
||||
|
@ -102,7 +104,7 @@ namespace remwharead
|
|||
*
|
||||
* @since 0.6.0
|
||||
*/
|
||||
const vector<entry> retrieve(
|
||||
const list<entry> retrieve(
|
||||
const time_point &start = time_point(),
|
||||
const time_point &end = system_clock::now()) const;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <locale>
|
||||
#include <list>
|
||||
#include "sqlite.hpp"
|
||||
#include "remwharead_cli.hpp"
|
||||
#include "uri.hpp"
|
||||
|
@ -35,6 +36,7 @@ using std::endl;
|
|||
using std::string;
|
||||
using std::chrono::system_clock;
|
||||
using std::ofstream;
|
||||
using std::list;
|
||||
|
||||
int App::main(const std::vector<std::string> &args)
|
||||
{
|
||||
|
@ -108,9 +110,7 @@ int App::main(const std::vector<std::string> &args)
|
|||
|
||||
if (_format != export_format::undefined)
|
||||
{
|
||||
vector<Database::entry> entries = db.retrieve(_timespan[0],
|
||||
_timespan[1]);
|
||||
Search search(entries);
|
||||
list<Database::entry> entries = db.retrieve(_timespan[0], _timespan[1]);
|
||||
|
||||
if (!_search_tags.empty())
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace remwharead
|
|||
using std::endl;
|
||||
using std::regex;
|
||||
using std::regex_replace;
|
||||
using tagpair = std::pair<string,vector<Database::entry>>;
|
||||
using tagpair = std::pair<string,list<Database::entry>>;
|
||||
|
||||
void Export::AsciiDoc::print() const
|
||||
{
|
||||
|
|
|
@ -21,16 +21,15 @@ namespace remwharead
|
|||
{
|
||||
namespace Export
|
||||
{
|
||||
ExportBase::ExportBase(const vector<Database::entry> &entries, ostream &out)
|
||||
ExportBase::ExportBase(const list<Database::entry> &entries, ostream &out)
|
||||
: _entries(sort_entries(entries))
|
||||
, _out(out)
|
||||
{}
|
||||
|
||||
const vector<Database::entry>
|
||||
ExportBase::sort_entries(vector<Database::entry> entries) const
|
||||
const list<Database::entry>
|
||||
ExportBase::sort_entries(list<Database::entry> entries) const
|
||||
{
|
||||
std::sort(entries.begin(), entries.end(),
|
||||
[](const auto &a, const auto &b)
|
||||
entries.sort([](const auto &a, const auto &b)
|
||||
{
|
||||
return (a.datetime > b.datetime);
|
||||
});
|
||||
|
|
|
@ -17,18 +17,20 @@
|
|||
#include <regex>
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <list>
|
||||
#include <Poco/UTF8String.h>
|
||||
#include "search.hpp"
|
||||
|
||||
namespace remwharead
|
||||
{
|
||||
using std::list;
|
||||
using std::regex;
|
||||
using std::regex_search;
|
||||
using std::smatch;
|
||||
using std::find;
|
||||
using std::find_if;
|
||||
|
||||
Search::Search(const vector<Database::entry> &entries)
|
||||
Search::Search(const list<Database::entry> &entries)
|
||||
:_entries(entries)
|
||||
{}
|
||||
|
||||
|
@ -72,11 +74,11 @@ namespace remwharead
|
|||
return Poco::UTF8::toLower(str);
|
||||
}
|
||||
|
||||
const vector<DB::entry> Search::search_tags(string expression,
|
||||
const list<DB::entry> Search::search_tags(string expression,
|
||||
const bool is_re) const
|
||||
{
|
||||
vector<vector<string>> searchlist = parse_expression(expression);
|
||||
vector<DB::entry> result;
|
||||
list<DB::entry> result;
|
||||
|
||||
for (const vector<string> &tags_or : searchlist)
|
||||
{
|
||||
|
@ -116,11 +118,11 @@ namespace remwharead
|
|||
return result;
|
||||
}
|
||||
|
||||
const vector<DB::entry> Search::search_all(string expression,
|
||||
const list<DB::entry> Search::search_all(string expression,
|
||||
const bool is_re) const
|
||||
{
|
||||
vector<vector<string>> searchlist = parse_expression(expression);
|
||||
vector<DB::entry> result = search_tags(expression, is_re);
|
||||
list<DB::entry> result = search_tags(expression, is_re);
|
||||
|
||||
for (const vector<string> &terms_or : searchlist)
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace remwharead
|
|||
}
|
||||
}
|
||||
|
||||
const vector<Database::entry> Database::retrieve(
|
||||
const list<Database::entry> Database::retrieve(
|
||||
const time_point &start, const time_point &end) const
|
||||
{
|
||||
try
|
||||
|
@ -130,7 +130,7 @@ namespace remwharead
|
|||
into(strtags), into(entrybuf.title), into(entrybuf.description),
|
||||
into(entrybuf.fulltext), range(0, 1);
|
||||
|
||||
vector<entry> entries;
|
||||
list<entry> entries;
|
||||
|
||||
while(!select.done())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue