add pugixml

This commit is contained in:
Jacek Jendrzej
2015-04-27 22:26:45 +02:00
parent 497f05b730
commit 422c91d117
16 changed files with 236 additions and 111 deletions

View File

@@ -177,7 +177,7 @@ CUPnPDevice::CUPnPDevice(std::string url)
if (strcmp(xmlGetName(root),"root"))
throw std::runtime_error(std::string("XML: no root"));
for (node = root->xmlChildrenNode; node; node=node->xmlNextNode)
for (node = xmlChildrenNode(root); node; node=xmlNextNode(node))
{
if (!strcmp(xmlGetName(node),"URLBase"))
{
@@ -188,19 +188,19 @@ CUPnPDevice::CUPnPDevice(std::string url)
}
node = root->xmlChildrenNode;
node = xmlChildrenNode(root);
if (!node)
throw std::runtime_error(std::string("XML: no root child"));
while (strcmp(xmlGetName(node),"device"))
{
node = node->xmlNextNode;
node = xmlNextNode(node);
if (!node)
throw std::runtime_error(std::string("XML: no device"));
}
device = node;
for (node=device->xmlChildrenNode; node; node=node->xmlNextNode)
for (node=xmlChildrenNode(device); node; node=xmlNextNode(node))
{
if (!strcmp(xmlGetName(node),"deviceType"))
devicetype = std::string(xmlGetData(node)?xmlGetData(node):"");
@@ -237,7 +237,7 @@ CUPnPDevice::CUPnPDevice(std::string url)
if (!strcmp(xmlGetName(node),"iconList"))
{
for (icon=node->xmlChildrenNode; icon; icon=icon->xmlNextNode)
for (icon=xmlChildrenNode(node); icon; icon=xmlNextNode(icon))
{
bool foundm = false;
bool foundw = false;
@@ -247,7 +247,7 @@ CUPnPDevice::CUPnPDevice(std::string url)
if (strcmp(xmlGetName(icon),"icon"))
throw std::runtime_error(std::string("XML: no icon"));
for (snode=icon->xmlChildrenNode; snode; snode=snode->xmlNextNode)
for (snode=xmlChildrenNode(icon); snode; snode=xmlNextNode(snode))
{
if (!strcmp(xmlGetName(snode),"mimetype"))
{
@@ -292,7 +292,7 @@ CUPnPDevice::CUPnPDevice(std::string url)
if (!strcmp(xmlGetName(node),"serviceList"))
{
servicefound = true;
for (service=node->xmlChildrenNode; service; service=service->xmlNextNode)
for (service=xmlChildrenNode(node); service; service=xmlNextNode(service))
{
bool foundc = false;
bool founde = false;
@@ -300,7 +300,7 @@ CUPnPDevice::CUPnPDevice(std::string url)
if (strcmp(xmlGetName(service),"service"))
throw std::runtime_error(std::string("XML: no service"));
for (snode=service->xmlChildrenNode; snode; snode=snode->xmlNextNode)
for (snode=xmlChildrenNode(service); snode; snode=xmlNextNode(snode))
{
if (!strcmp(xmlGetName(snode),"serviceType"))
{

View File

@@ -112,7 +112,7 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
if (envelope != "Envelope")
throw std::runtime_error(std::string("XML: no envelope"));
node = root->xmlChildrenNode;
node = xmlChildrenNode(root);
if (!node)
throw std::runtime_error(std::string("XML: no envelope child"));
@@ -124,7 +124,7 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
if (soapbody != "Body")
throw std::runtime_error(std::string("XML: no soap body"));
node = node->xmlChildrenNode;
node = xmlChildrenNode(node);
if (!node)
throw std::runtime_error(std::string("XML: no soap body child"));
@@ -138,13 +138,13 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
std::string faultstring, upnpcode, upnpdesc, errstr;
if (soapresponse != "Fault")
throw std::runtime_error(std::string("XML: http error without soap fault: ")+rcode);
for (node=node->xmlChildrenNode; node; node=node->xmlNextNode)
for (node=xmlChildrenNode(node); node; node=xmlNextNode(node))
{
if (!strcmp(xmlGetName(node),"detail"))
{
snode=node->xmlChildrenNode;
snode=xmlChildrenNode(node);
if (snode)
for (snode=snode->xmlChildrenNode; snode; snode=snode->xmlNextNode)
for (snode=xmlChildrenNode(snode); snode; snode=xmlNextNode(snode))
{
errstr=xmlGetName(snode);
pos = errstr.find(":");
@@ -168,7 +168,7 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
if (soapresponse != action + "Response")
throw std::runtime_error(std::string("XML: no soap response"));
for (node=node->xmlChildrenNode; node; node=node->xmlNextNode)
for (node=xmlChildrenNode(node); node; node=xmlNextNode(node))
results.push_back(UPnPAttribute(xmlGetName(node), xmlGetData(node)));
xmlFreeDoc(parser);