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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
#ifndef NEWSBOAT_RSSPP_H_
#define NEWSBOAT_RSSPP_H_
#include <curl/curl.h>
#include <exception>
#include <libxml/parser.h>
#include <string>
#include <vector>
#include "remoteapi.h"
namespace rsspp {
enum Version {
UNKNOWN = 0,
RSS_0_91,
RSS_0_92,
RSS_1_0,
RSS_2_0,
ATOM_0_3,
ATOM_1_0,
RSS_0_94,
ATOM_0_3_NONS,
TTRSS_JSON,
NEWSBLUR_JSON,
OCNEWS_JSON
};
class Item {
public:
Item()
: guid_isPermaLink(false)
, pubDate_ts(0)
{
}
std::string title;
std::string title_type;
std::string link;
std::string description;
std::string description_type;
std::string author;
std::string author_email;
std::string pubDate;
std::string guid;
bool guid_isPermaLink;
std::string enclosure_url;
std::string enclosure_type;
// extensions:
std::string content_encoded;
std::string itunes_summary;
// Atom-specific:
std::string base;
std::vector<std::string> labels;
// only required for ttrss support:
time_t pubDate_ts;
};
class Feed {
public:
Feed()
: rss_version(UNKNOWN)
{
}
std::string encoding;
Version rss_version;
std::string title;
std::string title_type;
std::string description;
std::string link;
std::string language;
std::string managingeditor;
std::string dc_creator;
std::string pubDate;
std::vector<Item> items;
};
class Exception : public std::exception {
public:
explicit Exception(const std::string& errmsg = "");
~Exception() throw() override;
const char* what() const throw() override;
private:
std::string emsg;
};
class Parser {
public:
Parser(unsigned int timeout = 30,
const std::string& user_agent = "",
const std::string& proxy = "",
const std::string& proxy_auth = "",
curl_proxytype proxy_type = CURLPROXY_HTTP,
const bool ssl_verify = true);
~Parser();
Feed parse_url(const std::string& url,
time_t lastmodified = 0,
const std::string& etag = "",
newsboat::RemoteApi* api = 0,
const std::string& cookie_cache = "",
CURL* ehandle = 0);
Feed parse_buffer(const std::string& buffer,
const std::string& url = "");
Feed parse_file(const std::string& filename);
time_t get_last_modified()
{
return lm;
}
const std::string& get_etag()
{
return et;
}
static void global_init();
static void global_cleanup();
private:
Feed parse_xmlnode(xmlNode* node);
unsigned int to;
const std::string ua;
const std::string prx;
const std::string prxauth;
curl_proxytype prxtype;
const bool verify_ssl;
xmlDocPtr doc;
time_t lm;
std::string et;
};
} // namespace rsspp
#endif /* NEWSBOAT_RSSPP_H_ */
|