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());
|
||||
}
|
||||
|
@ -94,11 +94,15 @@ namespace rss_utils {
|
||||
std::string getAuthor() const;
|
||||
std::string getCategory() const;
|
||||
std::string getComments() const;
|
||||
//std::string getEnclosure() 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:
|
||||
std::string cdata_to_string(const rapidxml::xml_node<>*) const;
|
||||
|
Loading…
Reference in New Issue
Block a user