Add Cloud Accessor functions

This commit is contained in:
Clortox 2021-07-25 20:58:42 -04:00
parent c97b821587
commit 3ec8a71f9a
2 changed files with 101 additions and 49 deletions

View File

@ -247,7 +247,7 @@ std::string rss::getImageTitle() const {
return cdata_to_string(tmp); return cdata_to_string(tmp);
} }
std::string rss::getimageLink() const { std::string rss::getImageLink() const {
if(!_ok) if(!_ok)
return ""; return "";
@ -260,7 +260,7 @@ std::string rss::getimageLink() const {
return cdata_to_string(tmp); return cdata_to_string(tmp);
} }
int rss::getimageWidth() const { int rss::getImageWidth() const {
if(!_ok) if(!_ok)
return 0; return 0;
@ -273,7 +273,7 @@ int rss::getimageWidth() const {
return atoi(tmp->value()); return atoi(tmp->value());
} }
int rss::getimageHeight() const { int rss::getImageHeight() const {
if(!_ok) if(!_ok)
return 0; return 0;
@ -286,6 +286,76 @@ int rss::getimageHeight() const {
return atoi(tmp->value()); return atoi(tmp->value());
} }
std::string rss::getCloudDomain() const {
if(!_ok)
return "";
rapidxml::xml_node<> *tmp = _item_node->first_node("cloud");
if(tmp == 0)
return "";
rapidxml::xml_attribute<> *attr = tmp->first_attribute("domain");
if(attr == 0)
return "";
return attr->value();
}
int rss::getCloudPort() const {
if(!_ok)
return 0;
rapidxml::xml_node<> *tmp = _item_node->first_node("cloud");
if(tmp == 0)
return 0;
rapidxml::xml_attribute<> *attr = tmp->first_attribute("port");
if(attr == 0)
return 0;
return atoi(attr->value());
}
std::string rss::getCloudPath() const {
if(!_ok)
return "";
rapidxml::xml_node<> *tmp = _item_node->first_node("cloud");
if(tmp == 0)
return "";
rapidxml::xml_attribute<> *attr = tmp->first_attribute("path");
if(attr == 0)
return "";
return attr->value();
}
std::string rss::getRegisterProcedure() const {
if(!_ok)
return "";
rapidxml::xml_node<> *tmp = _item_node->first_node("cloud");
if(tmp == 0)
return "";
rapidxml::xml_attribute<> *attr = tmp->first_attribute("registerProcedure");
if(attr == 0)
return "";
return attr->value();
}
std::string rss::getProtocol() const {
if(!_ok)
return "";
rapidxml::xml_node<> *tmp = _item_node->first_node("cloud");
if(tmp == 0)
return "";
rapidxml::xml_attribute<> *attr = tmp->first_attribute("protocol");
if(attr == 0)
return "";
return attr->value();
}
int rss::getItemCount() const { int rss::getItemCount() const {
if(!_ok) if(!_ok)
return -1; return -1;
@ -342,16 +412,6 @@ std::vector<rapidxml::xml_node<>*> rss::parseItems() {
for(; first_item != NULL; first_item = first_item->next_sibling()) for(; first_item != NULL; first_item = first_item->next_sibling())
items.push_back(first_item); items.push_back(first_item);
/*
for(; first_item != NULL; first_item = first_item->next_sibling()){
std::map<std::string, std::string> tmp_item;
for(rapidxml::xml_node<> *item_val = first_item->first_node();
item_val != NULL; item_val = item_val->next_sibling())
tmp_item[item_val->name()] = item_val->value();
items.push_back(tmp_item);
}
*/
return items; return items;
} }
@ -483,15 +543,6 @@ std::string item::getComments() const {
return cdata_to_string(tmp); return cdata_to_string(tmp);
} }
/*
std::string item::getEnclosure() const {
rapidxml::xml_node<>* tmp = _item->first_node("enclosure");
if(tmp == 0)
return "";
return cdata_to_string(tmp);
}
*/
std::string item::getGuid() const { std::string item::getGuid() const {
rapidxml::xml_node<>* tmp = _item->first_node("guid"); rapidxml::xml_node<>* tmp = _item->first_node("guid");
if(tmp == 0) if(tmp == 0)
@ -507,7 +558,7 @@ bool item::getGuidPermaLink() const {
if(attr == 0) if(attr == 0)
return false; return false;
else if(attr->value() == std::string("true")) else if(attr->value() == std::string("true"))
return false; return true;
return false; return false;
} }
@ -532,7 +583,6 @@ std::string item::getEnclosureURL() const {
rapidxml::xml_attribute<>* attr = tmp->first_attribute("url"); rapidxml::xml_attribute<>* attr = tmp->first_attribute("url");
if(attr == 0) if(attr == 0)
return ""; return "";
else
return attr->value(); return attr->value();
} }
@ -543,7 +593,6 @@ std::string item::getEnclosureType() const {
rapidxml::xml_attribute<>* attr = tmp->first_attribute("type"); rapidxml::xml_attribute<>* attr = tmp->first_attribute("type");
if(attr == 0) if(attr == 0)
return ""; return "";
else
return attr->value(); return attr->value();
} }
@ -554,6 +603,5 @@ int item::getEnclosureLength() const {
rapidxml::xml_attribute<>* attr = tmp->first_attribute("length"); rapidxml::xml_attribute<>* attr = tmp->first_attribute("length");
if(attr == 0) if(attr == 0)
return -1; return -1;
else
return atoi(attr->value()); return atoi(attr->value());
} }

View File

@ -61,6 +61,12 @@ namespace rss_utils {
int getImageWidth() const; int getImageWidth() const;
int getImageHeight() const; int getImageHeight() const;
std::string getCloudDomain() const;
int getCloudPort() const;
std::string getCloudPath() const;
std::string getRegisterProcedure() const;
std::string getProtocol() const;
int getItemCount() const; int getItemCount() const;
std::vector<item> getItems(); std::vector<item> getItems();
@ -69,8 +75,6 @@ namespace rss_utils {
item& operator[](const int); item& operator[](const int);
const item& operator[](const int) const; const item& operator[](const int) const;
//TODO
//std::string getCloud() const;
private: private:
bool parse(const std::string&); bool parse(const std::string&);