summaryrefslogtreecommitdiff
path: root/include/urlreader.h
blob: b571f1ad9068cb47d49af43a02dc7346e787e4c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef NEWSBOAT_URLREADER_H_
#define NEWSBOAT_URLREADER_H_

#include <map>
#include <set>
#include <string>
#include <vector>

#include "3rd-party/optional.hpp"

namespace newsboat {

/// \brief Base class for classes that supply Newsboat with feed URLs.
class UrlReader {
public:
	UrlReader() = default;
	virtual ~UrlReader() = default;

	/// \brief Re-read the input file.
	///
	/// \note This overwrites the contents of `urls`, `tags`, and `alltags`, so
	/// make sure to save your modifications with `write_config()`.
	virtual nonstd::optional<std::string> reload() = 0;

	/// \brief User-visible description of where URLs come from.
	///
	/// This can be a path (e.g. ~/.newsboat/urls), a URL (e.g. the value of
	/// `opml-url` setting), or a name of the remote API in use (e.g. "Tiny
	/// Tiny RSS").
	virtual std::string get_source() = 0;

	/// \brief A list of feed URLs.
	std::vector<std::string>& get_urls();

	/// \brief Tags of feed that has url `url`.
	std::vector<std::string>& get_tags(const std::string& url);

	/// \brief List of all extant tags.
	std::vector<std::string> get_alltags();

protected:
	std::vector<std::string> urls;
	std::map<std::string, std::vector<std::string>> tags;
	std::set<std::string> alltags;
};

} // namespace newsboat

#endif /* NEWSBOAT_URLREADER_H_ */