blob: db29b170295f68518a5504ce99089f051598a9ca (
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
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
|
#ifndef NEWSBOAT_LINKS_H_
#define NEWSBOAT_LINKS_H_
#include <string>
#include <vector>
#include "config.h"
namespace newsboat {
// This enum has to be kept in sync with enum LinkType in rust/libnewsboat/src/links.rs
enum class LinkType { HREF, IMG, EMBED, IFRAME, VIDEO, AUDIO };
struct LinkPair {
std::string url;
LinkType type;
};
class Links {
public:
using iterator = std::vector<LinkPair>::iterator;
using const_iterator = std::vector<LinkPair>::const_iterator;
unsigned int add_link(const std::string& url, LinkType type);
const LinkPair& operator[] (size_t idx) const
{
return links[idx];
};
iterator begin()
{
return links.begin();
};
iterator end()
{
return links.end();
}
const_iterator cbegin() const
{
return links.cbegin();
}
const_iterator cend() const
{
return links.cend();
}
size_t size() const
{
return links.size();
}
void clear()
{
links.clear();
}
bool empty() const
{
return links.empty();
}
static std::string type2str(LinkType type)
{
switch (type) {
case LinkType::HREF:
return _("link");
case LinkType::IMG:
return _("image");
case LinkType::EMBED:
return _("embedded flash");
case LinkType::IFRAME:
return _("iframe");
case LinkType::VIDEO:
return _("video");
case LinkType::AUDIO:
return _("audio");
default:
return _("unknown (bug)");
}
}
private:
std::vector<LinkPair> links;
};
}
#endif
|