// 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"
-using std::cout;
-using std::cerr;
-using std::endl;
+#ifdef SYSTEM_EXPAT
+# include <expat.h>
+#else
+# include "sg_expat.h"
+#endif
+
using std::string;
using namespace simgear;
_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)
assert(res->container() == NULL);
assert(std::find(_contents.begin(), _contents.end(), res) == _contents.end());
-
- if (!strutils::starts_with(res->url(), _url)) {
- std::cerr << "us: " << _url << std::endl;
- std::cerr << "child:" << res->url() << std::endl;
-
- }
-
assert(strutils::starts_with(res->url(), _url));
assert(childWithUrl(res->url()) == NULL);
{
public:
DAVMultiStatusPrivate() :
- parserInited(false)
+ parserInited(false),
+ valid(false)
{
rootResource = NULL;
}
string tagN(const unsigned int n) const
{
- int sz = tagStack.size();
+ size_t sz = tagStack.size();
if (n >= sz) {
return string();
}
}
bool parserInited;
+ bool valid;
XML_Parser xmlParser;
DAVResource* rootResource;
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);
}
return _d->rootResource;
}
+bool DAVMultiStatus::isValid() const
+{
+ return _d->valid;
+}
+