Add Image accessor functions

This commit is contained in:
Clortox 2021-07-25 20:00:12 -04:00
parent b29bc17bee
commit c97b821587
2 changed files with 72 additions and 2 deletions

View File

@ -221,6 +221,71 @@ std::string rss::getLastBuildDate() const {
return cdata_to_string(tmp); return cdata_to_string(tmp);
} }
std::string rss::getImageURL() const {
if(!_ok)
return "";
rapidxml::xml_node<> *tmp = _item_node->first_node("image");
if(tmp == 0)
return "";
tmp = tmp->first_node("url");
if(tmp == 0)
return "";
return cdata_to_string(tmp);
}
std::string rss::getImageTitle() const {
if(!_ok)
return "";
rapidxml::xml_node<> *tmp = _item_node->first_node("image");
if(tmp == 0)
return "";
tmp = tmp->first_node("title");
if(tmp == 0)
return "";
return cdata_to_string(tmp);
}
std::string rss::getimageLink() const {
if(!_ok)
return "";
rapidxml::xml_node<> *tmp = _item_node->first_node("image");
if(tmp == 0)
return "";
tmp = tmp->first_node("link");
if(tmp == 0)
return "";
return cdata_to_string(tmp);
}
int rss::getimageWidth() const {
if(!_ok)
return 0;
rapidxml::xml_node<> *tmp = _item_node->first_node("image");
if(tmp == 0)
return 0;
tmp = tmp->first_node("width");
if(tmp == 0)
return 0;
return atoi(tmp->value());
}
int rss::getimageHeight() const {
if(!_ok)
return 0;
rapidxml::xml_node<> *tmp = _item_node->first_node("image");
if(tmp == 0)
return 0;
tmp = tmp->first_node("height");
if(tmp == 0)
return 0;
return atoi(tmp->value());
}
int rss::getItemCount() const { int rss::getItemCount() const {
if(!_ok) if(!_ok)
return -1; return -1;

View File

@ -54,8 +54,14 @@ namespace rss_utils {
std::string getDocs() const; std::string getDocs() const;
std::string getTTL() const; std::string getTTL() const;
std::string getLastBuildDate() const; std::string getLastBuildDate() const;
int getItemCount() const;
std::string getImageURL() const;
std::string getImageTitle() const;
std::string getImageLink() const;
int getImageWidth() const;
int getImageHeight() const;
int getItemCount() const;
std::vector<item> getItems(); std::vector<item> getItems();
item& getItem(const int); item& getItem(const int);
@ -64,7 +70,6 @@ namespace rss_utils {
const item& operator[](const int) const; const item& operator[](const int) const;
//TODO //TODO
//std::string getImage() const;
//std::string getCloud() const; //std::string getCloud() const;
private: private: