summaryrefslogtreecommitdiff
path: root/project2/xslRows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/xslRows.cpp')
-rw-r--r--project2/xslRows.cpp43
1 files changed, 12 insertions, 31 deletions
diff --git a/project2/xslRows.cpp b/project2/xslRows.cpp
index 53ba7a2..b30d9b6 100644
--- a/project2/xslRows.cpp
+++ b/project2/xslRows.cpp
@@ -5,7 +5,6 @@
#include "exceptions.h"
#include "xmlObjectLoader.h"
#include <boost/lexical_cast.hpp>
-#include <libxml/HTMLparser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include "../libmisc/curlsup.h"
@@ -13,7 +12,6 @@
DECLARE_LOADER("xslrows", XslRows);
-SimpleMessageException(XmlParseError);
SimpleMessageException(XpathInitError);
SimpleMessageException(XpathEvalError);
@@ -58,39 +56,22 @@ XslRows::setFilter(const Glib::ustring & f)
fv = i->second;
}
-size_t
-XslRows::handleDataHelper(const char * ptr, size_t size, size_t nmemb, void *stream)
+bool
+XslRows::asHtml() const
{
- std::string * buf = static_cast<std::string *>(stream);
- buf->append(ptr, size * nmemb);
- return size * nmemb;
+ return html;
}
-xmlDocPtr
-XslRows::getDocument(const Glib::ustring & url, const char * encoding) const
+bool
+XslRows::withWarnings() const
{
- Documents::const_iterator i = documents.find(url);
- if (i == documents.end()) {
- CurlHandle::Ptr c = newCurl();
- std::string buf;
- c->setopt(CURLOPT_WRITEDATA, &buf);
- c->setopt(CURLOPT_WRITEFUNCTION, &handleDataHelper);
- c->perform();
-
- int flags = 0;
- flags |= warnings ? 0 : XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
- xmlDocPtr doc = html ?
- htmlReadMemory(buf.c_str(), buf.length(), url.c_str(), encoding, flags) :
- xmlReadMemory(buf.c_str(), buf.length(), url.c_str(), encoding, flags);
- if (!doc) {
- throw XmlParseError(xmlGetLastError()->message);
- }
- documents.insert(Documents::value_type(url, Documents::value_type::second_type(doc, xmlFreeDoc)));
- return doc;
- }
- else {
- return i->second.get();
- }
+ return warnings;
+}
+
+CurlHandle::Ptr
+XslRows::newCurl() const
+{
+ return CurlHelper::newCurl();
}
void