remwharead/src/export.hpp

75 lines
1.9 KiB
C++
Raw Normal View History

2019-05-16 03:56:17 +02:00
/* 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/>.
*/
2019-05-16 08:37:50 +02:00
#ifndef REMWHAREAD_EXPORT_HPP
#define REMWHAREAD_EXPORT_HPP
2019-05-16 03:56:17 +02:00
#include <vector>
#include <iostream>
#include <map>
2019-05-16 03:56:17 +02:00
#include "sqlite.hpp"
using std::vector;
using std::ostream;
using std::cout;
2019-06-06 16:06:25 +02:00
namespace Export
{
class ExportBase
{
public:
explicit ExportBase(const vector<Database::entry> &entries,
ostream &out = cout);
protected:
const vector<Database::entry> &_entries;
ostream &_out;
};
class CSV : protected ExportBase
{
public:
using ExportBase::ExportBase;
void print() const;
private:
2019-06-06 16:06:25 +02:00
//! replaces " with "".
const string quote(string field) const;
};
class AsciiDoc : protected ExportBase
{
public:
using ExportBase::ExportBase;
void print() const;
private:
//! Replaces characters in tags that asciidoctor doesn't like.
const string replace_in_tags(string text) const;
void print_tags(const std::map<string,vector<Database::entry>> &tags) const;
};
}
2019-05-16 03:56:17 +02:00
2019-05-16 08:37:50 +02:00
2019-05-26 15:47:06 +02:00
//! Export as Netscape bookmark file.
void export_bookmarks(const vector<Database::entry> &entries,
ostream &out = cout);
2019-05-16 08:37:50 +02:00
#endif // REMWHAREAD_EXPORT_HPP