summaryrefslogtreecommitdiff
path: root/xmlreader/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-10-15 15:48:30 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-10-17 16:06:27 +0100
commit794a7c67e89be302cb65ea95d7b12a1da34839c0 (patch)
tree027c7c9160785a4d8c0f4a3fecbf4ee92893457f /xmlreader/source
parent239847102b632a4976f50d99b38b3c79b95e56aa (diff)
allow XmlReader to parse a string
Change-Id: I3433e6f3766c1ea54ad53896c4e4d142d1e319a5
Diffstat (limited to 'xmlreader/source')
-rw-r--r--xmlreader/source/xmlreader.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/xmlreader/source/xmlreader.cxx b/xmlreader/source/xmlreader.cxx
index fcf6e157a246..e297cd176c53 100644
--- a/xmlreader/source/xmlreader.cxx
+++ b/xmlreader/source/xmlreader.cxx
@@ -96,19 +96,38 @@ XmlReader::XmlReader(rtl::OUString const & fileUrl)
rtl::OUString::valueOf(static_cast< sal_Int32 >(e)) + ")"),
css::uno::Reference< css::uno::XInterface >());
}
+ init();
+ pos_ = static_cast< char * >(fileAddress_);
+ end_ = pos_ + fileSize_;
+}
+
+XmlReader::XmlReader(const char * str, sal_uInt64 len)
+ SAL_THROW(())
+ : fileHandle_(NULL)
+ , fileSize_(len)
+ , fileAddress_(NULL)
+{
+ init();
+ pos_ = str;
+ end_ = pos_ + fileSize_;
+}
+
+void XmlReader::init()
+{
namespaceIris_.push_back(
Span(
RTL_CONSTASCII_STRINGPARAM(
"http://www.w3.org/XML/1998/namespace")));
namespaces_.push_back(
NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML));
- pos_ = static_cast< char * >(fileAddress_);
- end_ = pos_ + fileSize_;
state_ = STATE_CONTENT;
firstAttribute_ = true;
}
XmlReader::~XmlReader() {
+ if (!fileHandle_)
+ return;
+
oslFileError e = osl_unmapMappedFile(fileHandle_, fileAddress_, fileSize_);
if (e != osl_File_E_None) {
SAL_WARN(