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