mirror of
https://github.com/Clortox/rss-cli.git
synced 2024-12-29 14:38:01 +00:00
Add item attribute accessor functions
This commit is contained in:
parent
56ffed1260
commit
b29bc17bee
44
src/rss.cpp
44
src/rss.cpp
@ -434,6 +434,18 @@ std::string item::getGuid() const {
|
||||
return cdata_to_string(tmp);
|
||||
}
|
||||
|
||||
bool item::getGuidPermaLink() const {
|
||||
rapidxml::xml_node<>* tmp = _item->first_node("guid");
|
||||
if(tmp == 0)
|
||||
return false;
|
||||
rapidxml::xml_attribute<>* attr = tmp->first_attribute("isPermaLink");
|
||||
if(attr == 0)
|
||||
return false;
|
||||
else if(attr->value() == std::string("true"))
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string item::getPubDate() const {
|
||||
rapidxml::xml_node<>* tmp = _item->first_node("pubDate");
|
||||
if(tmp == 0)
|
||||
@ -448,3 +460,35 @@ std::string item::getSource() const {
|
||||
return cdata_to_string(tmp);
|
||||
}
|
||||
|
||||
std::string item::getEnclosureURL() const {
|
||||
rapidxml::xml_node<>* tmp = _item->first_node("enclosure");
|
||||
if(tmp == 0)
|
||||
return "";
|
||||
rapidxml::xml_attribute<>* attr = tmp->first_attribute("url");
|
||||
if(attr == 0)
|
||||
return "";
|
||||
else
|
||||
return attr->value();
|
||||
}
|
||||
|
||||
std::string item::getEnclosureType() const {
|
||||
rapidxml::xml_node<>* tmp = _item->first_node("enclosure");
|
||||
if(tmp == 0)
|
||||
return "";
|
||||
rapidxml::xml_attribute<>* attr = tmp->first_attribute("type");
|
||||
if(attr == 0)
|
||||
return "";
|
||||
else
|
||||
return attr->value();
|
||||
}
|
||||
|
||||
int item::getEnclosureLength() const {
|
||||
rapidxml::xml_node<>* tmp = _item->first_node("enclosure");
|
||||
if(tmp == 0)
|
||||
return -1;
|
||||
rapidxml::xml_attribute<>* attr = tmp->first_attribute("length");
|
||||
if(attr == 0)
|
||||
return -1;
|
||||
else
|
||||
return atoi(attr->value());
|
||||
}
|
||||
|
24
src/rss.hpp
24
src/rss.hpp
@ -88,16 +88,20 @@ namespace rss_utils {
|
||||
item& operator=(const item&);
|
||||
item* clone() const;
|
||||
|
||||
std::string getTitle() const;
|
||||
std::string getLink() const;
|
||||
std::string getDescription() const;
|
||||
std::string getAuthor() const;
|
||||
std::string getCategory() const;
|
||||
std::string getComments() const;
|
||||
//std::string getEnclosure() const;
|
||||
std::string getGuid() const;
|
||||
std::string getPubDate() const;
|
||||
std::string getSource() const;
|
||||
std::string getTitle() const;
|
||||
std::string getLink() const;
|
||||
std::string getDescription() const;
|
||||
std::string getAuthor() const;
|
||||
std::string getCategory() const;
|
||||
std::string getComments() const;
|
||||
std::string getGuid() const;
|
||||
bool getGuidPermaLink() const;
|
||||
std::string getPubDate() const;
|
||||
std::string getSource() const;
|
||||
|
||||
std::string getEnclosureURL() const;
|
||||
std::string getEnclosureType() const;
|
||||
int getEnclosureLength() const;
|
||||
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user