-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.hpp
More file actions
104 lines (89 loc) · 2.43 KB
/
parser.hpp
File metadata and controls
104 lines (89 loc) · 2.43 KB
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
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <stdbool.h>
#include <string>
#include <libxml/parser.h>
#include <libxml/tree.h>
using namespace std;
enum feed_type {
FEED_TYPE_UNKNOWN = 0,
FEED_TYPE_RSS = 1,
FEED_TYPE_ATOM = 2
};
struct parse_config {
bool show_time;
bool show_author;
bool show_urls;
};
/**
* @brief converts a node name from atom to rss (kind of a dictionary)
*
* @param atom_name the name of the node in atom
* @return const char* the name of the node in rss
*/
const char* atom_to_rss(const char *atom_name);
/**
* @brief compares the name of the given node to the provided name
*
* @param node the node to compare
* @param name what the name should be
* @return true if the name is the same
*/
bool check_node_name(feed_type type, xmlNode *node, const char *name);
/**
* @brief Prints the author node
*
* @param node the author node to print
*/
void print_author_node(feed_type type, xmlNode *node);
/**
* @brief Prints the content of an entry or item node (one article)
*
* @param item the node to print
* @param showTime
* @param showAuthor
* @param showUrls
*/
void parse_item(feed_type type, xmlNode *item, struct parse_config config);
/**
* @brief Prints the content of a channel or feed node
*
* @param type if the feed is rss or atom
* @param node the node to print
* @param showTime
* @param showAuthor
* @param showUrls
*/
void parse_feed(feed_type type, xmlNode *node, struct parse_config config);
/**
* @brief Prints the content of a rss or atom feed from a file
* @note the file containing the actual feed, not the feedfile in assignment (which is a list of urls)
*
* @param location
* @param showTime
* @param showAuthor
* @param showUrls
*/
void parse_news_feed_file(std::string location, struct parse_config config);
/**
* @brief determines if the feed is rss or atom
*
* @param root the root node of the feed
* @return feed_type the type of the feed
*/
feed_type get_feed_type(xmlNode *root);
/**
* @brief Get the channel node object (used in rss)
*
* @param type type of the feed
* @param root
* @return the channel node
*/
xmlNode* get_channel_node(feed_type type, xmlNode *root);
/**
* @brief Returns the node content and frees the node
*
*/
string get_node_content_string(xmlNode *node);