]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/DAVMultiStatus.cxx
Lots of (mostly) doxygen fixes/cleanup.
[simgear.git] / simgear / io / DAVMultiStatus.cxx
index 5270fca6175f9ce0738a66258fcc6d28b1ddaced..a805a214a5a4b76056ff28d00fe4b075be0152e1 100644 (file)
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+     
 #include "DAVMultiStatus.hxx"
 
 #include <iostream>
 #include <boost/foreach.hpp>
 
 #include "simgear/debug/logstream.hxx"
-#include "simgear/xml/xmlparse.h"
 #include "simgear/misc/strutils.hxx"
 #include "simgear/structure/exception.hxx"
 
+#ifdef SYSTEM_EXPAT
+#  include <expat.h>
+#else
+#  include "sg_expat.h"     
+#endif
+
 using std::string;
 
 using namespace simgear;
@@ -58,7 +67,10 @@ DAVResource::DAVResource(const string& href) :
   _url(href),
   _container(NULL)
 {
-    assert(!href.empty()); 
+    assert(!href.empty());
+    if (strutils::ends_with(href, "/")) {
+        _url = href.substr(0, _url.size() - 1);
+    }
 }
 
 void DAVResource::setVersionName(const std::string& aVersion)
@@ -171,7 +183,8 @@ class DAVMultiStatus::DAVMultiStatusPrivate
 {
 public:
   DAVMultiStatusPrivate() :
-  parserInited(false)
+      parserInited(false),
+      valid(false)
   {
     rootResource = NULL;
   }
@@ -275,6 +288,7 @@ public:
   }
   
   bool parserInited;
+  bool valid;
   XML_Parser xmlParser;
   DAVResource* rootResource;
   
@@ -354,13 +368,21 @@ void DAVMultiStatus::parseXML(const char* data, int size)
     
     XML_ParserFree(_d->xmlParser);
     _d->parserInited = false;
+    _d->valid = false;
   }
 }
 
 void DAVMultiStatus::finishParse()
 {
   if (_d->parserInited) {
-    XML_Parse(_d->xmlParser, NULL, 0, true);
+    if (!XML_Parse(_d->xmlParser, NULL, 0, true)) {
+        SG_LOG(SG_IO, SG_WARN, "DAV parse error:" << XML_ErrorString(XML_GetErrorCode(_d->xmlParser))
+               << " at line:" << XML_GetCurrentLineNumber(_d->xmlParser)
+               << " column " << XML_GetCurrentColumnNumber(_d->xmlParser));
+        _d->valid = false;
+    } else {
+        _d->valid = true;
+    }
     XML_ParserFree(_d->xmlParser);
   }
   
@@ -372,4 +394,9 @@ DAVResource* DAVMultiStatus::resource()
   return _d->rootResource;
 }
 
+bool DAVMultiStatus::isValid() const
+{
+    return _d->valid;
+}
+