summaryrefslogtreecommitdiff
path: root/zenXml
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2025-01-20 19:25:18 -0500
committerB. Stack <bgstack15@gmail.com>2025-01-20 19:25:18 -0500
commitde65d3c0295894f8eafc4c7582dfe180dc58c81e (patch)
tree3ba8ec770b81468ca4ad83d985b991c5f669de22 /zenXml
parentadd upstream 13.9 (diff)
downloadFreeFileSync-master.tar.gz
FreeFileSync-master.tar.bz2
FreeFileSync-master.zip
add upstream 14.0, depends on wx 3.3.0HEAD14.0master
Diffstat (limited to 'zenXml')
-rw-r--r--zenXml/zenxml/cvrt_struc.h6
-rw-r--r--zenXml/zenxml/cvrt_text.h1
-rw-r--r--zenXml/zenxml/dom.h17
-rw-r--r--zenXml/zenxml/parser.h15
-rw-r--r--zenXml/zenxml/xml.h6
5 files changed, 17 insertions, 28 deletions
diff --git a/zenXml/zenxml/cvrt_struc.h b/zenXml/zenxml/cvrt_struc.h
index 40277556..57a5d09d 100644
--- a/zenXml/zenxml/cvrt_struc.h
+++ b/zenXml/zenxml/cvrt_struc.h
@@ -124,9 +124,7 @@ struct ConvertElement<T, ValueType::stlContainer>
value.clear();
bool success = true;
- auto [it, itEnd] = input.getChildren();
-
- std::for_each(it, itEnd, [&](const XmlElement& xmlChild)
+ for (const XmlElement& xmlChild : input.getChildren())
{
typename T::value_type childVal;
if (zen::readStruc(xmlChild, childVal))
@@ -134,7 +132,7 @@ struct ConvertElement<T, ValueType::stlContainer>
else
success = false;
//should we support insertion of partially-loaded struct??
- });
+ }
return success;
}
};
diff --git a/zenXml/zenxml/cvrt_text.h b/zenXml/zenxml/cvrt_text.h
index b4f6fa2d..4fa4ec83 100644
--- a/zenXml/zenxml/cvrt_text.h
+++ b/zenXml/zenxml/cvrt_text.h
@@ -8,7 +8,6 @@
#define CVRT_TEXT_H_018727339083427097434
#include <chrono>
-//#include <zen/utf.h>
#include <zen/string_tools.h>
diff --git a/zenXml/zenxml/dom.h b/zenXml/zenxml/dom.h
index 89320db1..cbac4dff 100644
--- a/zenXml/zenxml/dom.h
+++ b/zenXml/zenxml/dom.h
@@ -131,21 +131,18 @@ public:
return const_cast<XmlElement*>(static_cast<const XmlElement*>(this)->getChild(name));
}
- using ChildIter = std::list<XmlElement>::iterator;
- using ChildIterConst = std::list<XmlElement>::const_iterator;
-
- ///Access all child elements sequentially via STL iterators.
+ ///Access all child elements sequentially
/**
\code
- auto [it, itEnd] = elem.getChildren();
- std::for_each(it, itEnd, [](const XmlElement& child) { ... });
+ for (const XmlElement& child : elem.getChildren())
+ { ... }
\endcode
- \return A pair of STL begin/end iterators to access all child elements sequentially. */
- std::pair<ChildIterConst, ChildIterConst> getChildren() const { return {childElements_.begin(), childElements_.end()}; }
+ \return A range object supporting begin/end functions to access all child elements sequentially. */
+ Range<std::list<XmlElement>::const_iterator> getChildren() const { return {childElements_.begin(), childElements_.end()}; }
///\sa getChildren
- std::pair<ChildIter, ChildIter> getChildren() { return {childElements_.begin(), childElements_.end()}; }
-
+ Range<std::list<XmlElement>::iterator> getChildren() { return {childElements_.begin(), childElements_.end()}; }
+
///Get parent XML element, may be nullptr for root element
XmlElement* parent() { return parent_; }
///Get parent XML element, may be nullptr for root element
diff --git a/zenXml/zenxml/parser.h b/zenXml/zenxml/parser.h
index 6c7959b4..f60a3906 100644
--- a/zenXml/zenxml/parser.h
+++ b/zenXml/zenxml/parser.h
@@ -7,7 +7,6 @@
#ifndef PARSER_H_81248670213764583021432
#define PARSER_H_81248670213764583021432
-//#include <cstdio>
#include <cstddef> //ptrdiff_t; req. on Linux
#include <zen/string_tools.h>
#include "dom.h"
@@ -206,14 +205,14 @@ void serialize(const XmlElement& element, std::string& stream,
for (auto it = attr.first; it != attr.second; ++it)
stream += ' ' + normalizeName(it->name) + "=\"" + normalizeAttribValue(it->value) + '"';
- auto [it, itEnd] = element.getChildren();
- if (it != itEnd) //structured element
+ const auto& children = element.getChildren();
+ if (!children.empty()) //structured element
{
//no support for mixed-mode content
stream += '>' + lineBreak;
- std::for_each(it, itEnd, [&](const XmlElement& el)
- { serialize(el, stream, lineBreak, indent, indentLevel + 1); });
+ for (const XmlElement& el : children)
+ serialize(el, stream, lineBreak, indent, indentLevel + 1);
for (size_t i = 0; i < indentLevel; ++i)
stream += indent;
@@ -483,9 +482,9 @@ public:
XmlElement dummy;
parseChildElements(dummy);
- auto [it, itEnd] = dummy.getChildren();
- if (it != itEnd)
- doc.root().swapSubtree(*it);
+ const auto& children = dummy.getChildren();
+ if (!children.empty())
+ doc.root().swapSubtree(*children.begin());
expectToken(Token::TK_END); //throw XmlParsingError
return doc;
diff --git a/zenXml/zenxml/xml.h b/zenXml/zenxml/xml.h
index f14a9f0b..03974fad 100644
--- a/zenXml/zenxml/xml.h
+++ b/zenXml/zenxml/xml.h
@@ -7,7 +7,6 @@
#ifndef XML_H_349578228034572457454554
#define XML_H_349578228034572457454554
-//#include <set>
#include <zen/file_io.h>
#include <zen/file_access.h>
#include "cvrt_struc.h"
@@ -258,12 +257,9 @@ public:
logConversionError(); //have XML value element, not container!
else
{
- auto [it, itEnd] = elem_->getChildren();
size_t childIdx = 0;
- std::for_each(it, itEnd, [&](const XmlElement& child)
- {
+ for (const XmlElement& child : elem_->getChildren())
fun(XmlIn(&child, elementNameFmt_ + " <" + child.getName() + ">[" + numberTo<std::string>(++childIdx) + ']', log_));
- });
}
}
bgstack15