Splitted export header.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2019-06-06 18:56:49 +02:00
parent 00aa9ffd47
commit 93298e5301
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
11 changed files with 141 additions and 51 deletions

View File

@ -14,14 +14,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include <regex>
#include <algorithm>
#include <utility>
#include <locale>
#include <curlpp/cURLpp.hpp>
#include "version.hpp"
#include "export.hpp"
#include "time.hpp"
#include "adoc.hpp"
using std::string;
using std::cerr;
using std::endl;
using std::regex;

52
src/adoc.hpp Normal file
View File

@ -0,0 +1,52 @@
/* This file is part of remwharead.
* Copyright © 2019 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REMWHAREAD_ADOC_HPP
#define REMWHAREAD_ADOC_HPP
#include <map>
#include <string>
#include <vector>
#include "sqlite.hpp"
#include "export.hpp"
using std::string;
namespace Export
{
class AsciiDoc : protected ExportBase
{
public:
using ExportBase::ExportBase;
void print() const override;
private:
using tagmap = std::map<string,vector<Database::entry>>;
using replacemap = const std::map<const string, const string>;
const string replace(string text, const replacemap &replacements) const;
//! Replaces characters in tags that asciidoctor doesn't like.
const string replace_in_tag(const string &text) const;
//! Replaces characters in title that asciidoctor doesn't like.
const string replace_in_title(const string &text) const;
void print_tags(const tagmap &tags) const;
const string get_day(const Database::entry &entry) const;
const string get_time(const Database::entry &entry) const;
};
}
#endif // REMWHAREAD_ADOC_HPP

View File

@ -15,11 +15,14 @@
*/
#include <chrono>
#include "export.hpp"
#include <string>
#include "sqlite.hpp"
#include "bookmarks.hpp"
using std::chrono::system_clock;
using std::chrono::duration_cast;
using std::chrono::seconds;
using std::string;
void Export::Bookmarks::print() const
{

33
src/bookmarks.hpp Normal file
View File

@ -0,0 +1,33 @@
/* This file is part of remwharead.
* Copyright © 2019 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REMWHAREAD_BOOKMARKS_HPP
#define REMWHAREAD_BOOKMARKS_HPP
#include "export.hpp"
namespace Export
{
//! Export as Netscape bookmark file.
class Bookmarks : protected ExportBase
{
public:
using ExportBase::ExportBase;
virtual void print() const override;
};
}
#endif // REMWHAREAD_BOOKMARKS_HPP

View File

@ -15,7 +15,7 @@
*/
#include "time.hpp"
#include "export.hpp"
#include "csv.hpp"
using std::cerr;
using std::endl;

40
src/csv.hpp Normal file
View File

@ -0,0 +1,40 @@
/* This file is part of remwharead.
* Copyright © 2019 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REMWHAREAD_CSV_HPP
#define REMWHAREAD_CSV_HPP
#include <string>
#include "export.hpp"
using std::string;
namespace Export
{
class CSV : protected ExportBase
{
public:
using ExportBase::ExportBase;
virtual void print() const override;
private:
//! replaces " with "".
const string quote(string field) const;
};
}
#endif // REMWHAREAD_CSV_HPP

View File

@ -19,8 +19,6 @@
#include <vector>
#include <iostream>
#include <map>
#include "time.hpp"
#include "sqlite.hpp"
using std::vector;
@ -41,48 +39,6 @@ namespace Export
const vector<Database::entry> &_entries;
ostream &_out;
};
class CSV : protected ExportBase
{
public:
using ExportBase::ExportBase;
virtual void print() const override;
private:
//! replaces " with "".
const string quote(string field) const;
};
class AsciiDoc : protected ExportBase
{
public:
using ExportBase::ExportBase;
void print() const override;
private:
using tagmap = std::map<string,vector<Database::entry>>;
using replacemap = const std::map<const string, const string>;
const string replace(string text, const replacemap &replacements) const;
//! Replaces characters in tags that asciidoctor doesn't like.
const string replace_in_tag(const string &text) const;
//! Replaces characters in title that asciidoctor doesn't like.
const string replace_in_title(const string &text) const;
void print_tags(const tagmap &tags) const;
const string get_day(const Database::entry &entry) const;
const string get_time(const Database::entry &entry) const;
};
//! Export as Netscape bookmark file.
class Bookmarks : protected ExportBase
{
public:
using ExportBase::ExportBase;
virtual void print() const override;
};
}
#endif // REMWHAREAD_EXPORT_HPP

View File

@ -24,7 +24,9 @@
#include "parse_options.hpp"
#include "uri.hpp"
#include "types.hpp"
#include "export.hpp"
#include "csv.hpp"
#include "adoc.hpp"
#include "bookmarks.hpp"
#include "search.hpp"
using std::cout;

View File

@ -22,7 +22,7 @@
#include <catch.hpp>
#include "time.hpp"
#include "sqlite.hpp"
#include "export.hpp"
#include "adoc.hpp"
using std::string;
using std::chrono::system_clock;

View File

@ -21,7 +21,7 @@
#include <chrono>
#include <catch.hpp>
#include "sqlite.hpp"
#include "export.hpp"
#include "bookmarks.hpp"
using std::string;
using std::chrono::system_clock;

View File

@ -22,7 +22,7 @@
#include <catch.hpp>
#include "time.hpp"
#include "sqlite.hpp"
#include "export.hpp"
#include "csv.hpp"
using std::string;
using std::chrono::system_clock;