summaryrefslogtreecommitdiff
path: root/include/urlreader.h
blob: 8ff58589ccd227af6877e02adcdb5683545ea0ed (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef NEWSBEUTER_CONFIGREADER__H
#define NEWSBEUTER_CONFIGREADER__H

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

#include <configcontainer.h>

#include <libxml/tree.h>

namespace newsbeuter {

	class urlreader {
		public:
			urlreader();
			virtual ~urlreader();
			virtual void write_config() = 0;
			virtual void reload() = 0;
			virtual std::string get_source() = 0;
			std::vector<std::string>& get_urls();
			std::vector<std::string>& get_tags(const std::string& url);
			std::vector<std::string> get_alltags();
			inline void set_offline(bool off) { offline = off; }
		protected:
			std::vector<std::string> urls;
			std::map<std::string, std::vector<std::string> > tags;
			std::set<std::string> alltags;
			bool offline;
	};

	class file_urlreader : public urlreader {
		public:
			file_urlreader(const std::string& file = "");
			virtual ~file_urlreader();
			virtual void write_config();
			virtual void reload();
			void load_config(const std::string& file);
			virtual std::string get_source();
		private:
			std::string filename;
	};

	class opml_urlreader : public urlreader {
		public:
			opml_urlreader(configcontainer * c);
			virtual ~opml_urlreader();
			virtual void write_config();
			virtual void reload();
			virtual std::string get_source();
		protected:
			virtual void handle_node(xmlNode * node, const std::string& tag);
			virtual const char * get_auth();
			configcontainer * cfg;
		private:
			void rec_find_rss_outlines(xmlNode * node, std::string tag);
	};

}


#endif