summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-05-26 17:45:43 +0000
committerrandomdan <randomdan@localhost>2011-05-26 17:45:43 +0000
commitead44bdb1e79f6acde62e4a0cc70ea3e92edf426 (patch)
tree400f9a394d885936c9ebb567a1f5adce4f9c5105
parentFix quoting issue, screw old versions of boost (diff)
downloadproject2-ead44bdb1e79f6acde62e4a0cc70ea3e92edf426.tar.bz2
project2-ead44bdb1e79f6acde62e4a0cc70ea3e92edf426.tar.xz
project2-ead44bdb1e79f6acde62e4a0cc70ea3e92edf426.zip
Allow specification of encoding of documents in XslRows
Allow specification of encoding of web sites in artfulseller
-rw-r--r--project2/xslRows.cpp11
-rw-r--r--project2/xslRows.h3
2 files changed, 8 insertions, 6 deletions
diff --git a/project2/xslRows.cpp b/project2/xslRows.cpp
index 82c9d4a..7a46fae 100644
--- a/project2/xslRows.cpp
+++ b/project2/xslRows.cpp
@@ -21,7 +21,8 @@ XslRows::XslRows(const xmlpp::Element * p) :
RowSet(p),
CurlHelper(p),
html(p->get_attribute_value("html") == "true"),
- warnings(p->get_attribute_value("warnings") != "false")
+ warnings(p->get_attribute_value("warnings") != "false"),
+ encoding(p, "encoding", false)
{
BOOST_FOREACH(const xmlpp::Node * node, p->find("filterview")) {
const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node);
@@ -66,7 +67,7 @@ XslRows::handleDataHelper(const char * ptr, size_t size, size_t nmemb, void *str
}
xmlDocPtr
-XslRows::getDocument(const Glib::ustring & url) const
+XslRows::getDocument(const Glib::ustring & url, const char * encoding) const
{
Documents::const_iterator i = documents.find(url);
if (i == documents.end()) {
@@ -79,8 +80,8 @@ XslRows::getDocument(const Glib::ustring & url) const
int flags = 0;
flags |= warnings ? 0 : XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
xmlDocPtr doc = html ?
- htmlReadMemory(buf.c_str(), buf.length(), url.c_str(), NULL, flags) :
- xmlReadMemory(buf.c_str(), buf.length(), url.c_str(), NULL, flags);
+ 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);
}
@@ -97,7 +98,7 @@ XslRows::execute(const RowProcessor * rp) const
{
typedef boost::shared_ptr<xmlXPathObject> xmlXPathObjectSPtr;
typedef boost::shared_ptr<xmlXPathContext> xmlXPathContextSPtr;
- xmlDocPtr doc = getDocument(url());
+ xmlDocPtr doc = getDocument(url(), encoding());
xmlXPathContextSPtr xpathCtx = xmlXPathContextSPtr(xmlXPathNewContext(doc), xmlXPathFreeContext);
if (!xpathCtx) {
throw XpathInitError(xmlGetLastError()->message);
diff --git a/project2/xslRows.h b/project2/xslRows.h
index 7aeb4e4..5075386 100644
--- a/project2/xslRows.h
+++ b/project2/xslRows.h
@@ -51,7 +51,8 @@ class XslRows : public RowSet, CurlHelper {
typedef std::map<const Glib::ustring, boost::shared_ptr<xmlDoc> > Documents;
mutable Documents documents;
static size_t handleDataHelper(const char * ptr, size_t size, size_t nmemb, void *stream);
- xmlDocPtr getDocument(const Glib::ustring & url) const;
+ xmlDocPtr getDocument(const Glib::ustring & url, const char * encoding) const;
+ const Variable encoding;
};
#endif