summaryrefslogtreecommitdiff
path: root/zenXml/zenxml
diff options
context:
space:
mode:
Diffstat (limited to 'zenXml/zenxml')
-rw-r--r--zenXml/zenxml/dom.h2
-rw-r--r--zenXml/zenxml/xml.h9
2 files changed, 6 insertions, 5 deletions
diff --git a/zenXml/zenxml/dom.h b/zenXml/zenxml/dom.h
index 427e89f2..5befdd7f 100644
--- a/zenXml/zenxml/dom.h
+++ b/zenXml/zenxml/dom.h
@@ -217,7 +217,7 @@ public:
\code
auto itPair = elem.getAttributes();
for (auto it = itPair.first; it != itPair.second; ++it)
- std::cout << "name: " << it->name << " value: " << it->value << '\n';
+ std::cout << std::string("name: ") + it->name + " value: " + it->value + '\n';
\endcode
\return A pair of STL begin/end iterators to access all attributes sequentially as a list of name/value pairs of std::string. */
std::pair<AttrIter, AttrIter> getAttributes() const { return {attributes_.begin(), attributes_.end()}; }
diff --git a/zenXml/zenxml/xml.h b/zenXml/zenxml/xml.h
index 829bb5f3..c87655ba 100644
--- a/zenXml/zenxml/xml.h
+++ b/zenXml/zenxml/xml.h
@@ -34,16 +34,17 @@ namespace
{
XmlDoc loadXml(const Zstring& filePath) //throw FileError
{
- FileInput fileIn(filePath, nullptr /*notifyUnbufferedIO*/); //throw FileError, ErrorFileLocked
- const size_t blockSize = fileIn.getBlockSize();
+ FileInputPlain fileIn(filePath); //throw FileError
+ const size_t blockSize = fileIn.getBlockSize(); //throw FileError
const std::string xmlPrefix = "<?xml version=";
bool xmlPrefixChecked = false;
std::string buffer;
for (;;)
{
+ warn_static("don't need zero-initialization! => resize_and_overwrite")
buffer.resize(buffer.size() + blockSize);
- const size_t bytesRead = fileIn.read(&*(buffer.end() - blockSize), blockSize); //throw FileError, ErrorFileLocked, (X); return "bytesToRead" bytes unless end of stream!
+ const size_t bytesRead = fileIn.tryRead(&*(buffer.end() - blockSize), blockSize); //throw FileError; may return short, only 0 means EOF! CONTRACT: bytesToRead > 0!
buffer.resize(buffer.size() - blockSize + bytesRead); //caveat: unsigned arithmetics
//quick test whether input is an XML: avoid loading large binary files up front!
@@ -55,7 +56,7 @@ XmlDoc loadXml(const Zstring& filePath) //throw FileError
throw FileError(replaceCpy(_("File %x does not contain a valid configuration."), L"%x", fmtPath(filePath)));
}
- if (bytesRead < blockSize) //end of file
+ if (bytesRead == 0) //end of file
break;
}
bgstack15