2 Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef DCPOMATIC_DKDM_RECIPIENT_LIST_H
23 #define DCPOMATIC_DKDM_RECIPIENT_LIST_H
27 #include "sqlite_table.h"
28 #include <libcxml/cxml.h>
29 #include <boost/filesystem.hpp>
30 #include <boost/optional.hpp>
36 class DKDMRecipientID : public ID
39 DKDMRecipientID(sqlite3_int64 id)
42 bool operator==(DKDMRecipientID const& other) const {
43 return get() == other.get();
46 bool operator!=(DKDMRecipientID const& other) const {
47 return get() != other.get();
50 bool operator<(DKDMRecipientID const& other) const {
51 return get() < other.get();
56 class DKDMRecipientList
60 DKDMRecipientList(boost::filesystem::path db_file);
63 DKDMRecipientList(DKDMRecipientList const&) = delete;
64 DKDMRecipientList& operator=(DKDMRecipientList const&) = delete;
66 DKDMRecipientList(DKDMRecipientList&& other);
67 DKDMRecipientList& operator=(DKDMRecipientList&& other);
69 void read_legacy_file(boost::filesystem::path xml_file);
70 void read_legacy_string(std::string const& xml);
74 DKDMRecipientID add_dkdm_recipient(DKDMRecipient const& dkdm_recipient);
75 void update_dkdm_recipient(DKDMRecipientID id, DKDMRecipient const& dkdm_recipient);
76 void remove_dkdm_recipient(DKDMRecipientID id);
77 std::vector<std::pair<DKDMRecipientID, DKDMRecipient>> dkdm_recipients() const;
78 boost::optional<DKDMRecipient> dkdm_recipient(DKDMRecipientID id) const;
81 void setup(boost::filesystem::path db_file);
82 void read_legacy_document(cxml::Document const& doc);
84 sqlite3* _db = nullptr;
85 SQLiteTable _dkdm_recipients;