summaryrefslogtreecommitdiff
path: root/zenXml/zenxml/cvrt_struc.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-04-05 15:59:11 +0000
committerB. Stack <bgstack15@gmail.com>2021-04-05 15:59:11 +0000
commit8d28254d708c88ae4aaebbc82cbb6c91726aa390 (patch)
treedafb5e266c513a5ed9863401e62d246742861e0c /zenXml/zenxml/cvrt_struc.h
parentMerge branch '11.7' into 'master' (diff)
parentadd upstream 11.9 (diff)
downloadFreeFileSync-8d28254d708c88ae4aaebbc82cbb6c91726aa390.tar.gz
FreeFileSync-8d28254d708c88ae4aaebbc82cbb6c91726aa390.tar.bz2
FreeFileSync-8d28254d708c88ae4aaebbc82cbb6c91726aa390.zip
Merge branch '11.9' into 'master'11.9
add upstream 11.9 See merge request opensource-tracking/FreeFileSync!32
Diffstat (limited to 'zenXml/zenxml/cvrt_struc.h')
-rw-r--r--zenXml/zenxml/cvrt_struc.h35
1 files changed, 18 insertions, 17 deletions
diff --git a/zenXml/zenxml/cvrt_struc.h b/zenXml/zenxml/cvrt_struc.h
index 9d484f75..a437604c 100644
--- a/zenXml/zenxml/cvrt_struc.h
+++ b/zenXml/zenxml/cvrt_struc.h
@@ -84,17 +84,17 @@ public:
//Conversion from arbitrary types to an XML element
enum class ValueType
{
- STL_CONTAINER,
- STL_PAIR,
- OTHER,
+ stlContainer,
+ stlPair,
+ other,
};
template <class T>
using GetValueType = std::integral_constant<ValueType,
- GetTextType <T>::value != TEXT_TYPE_OTHER ? ValueType::OTHER : //some string classes are also STL containers, so check this first
- IsStlContainer<T>::value ? ValueType::STL_CONTAINER :
- IsStlPair <T>::value ? ValueType::STL_PAIR :
- ValueType::OTHER>;
+ GetTextType <T>::value != TextType::other ? ValueType::other : //some string classes are also STL containers, so check this first
+ IsStlContainer<T>::value ? ValueType::stlContainer :
+ IsStlPair <T>::value ? ValueType::stlPair :
+ ValueType::other>;
template <class T, ValueType type>
@@ -109,7 +109,7 @@ struct ConvertElement;
//partial specialization: handle conversion for all STL-container types!
template <class T>
-struct ConvertElement<T, ValueType::STL_CONTAINER>
+struct ConvertElement<T, ValueType::stlContainer>
{
void writeStruc(const T& value, XmlElement& output) const
{
@@ -121,19 +121,20 @@ struct ConvertElement<T, ValueType::STL_CONTAINER>
}
bool readStruc(const XmlElement& input, T& value) const
{
- bool success = true;
value.clear();
- auto itPair = input.getChildren("Item");
- for (auto it = itPair.first; it != itPair.second; ++it)
+ bool success = true;
+ const auto itPair = input.getChildren("Item");
+
+ std::for_each(itPair.first, itPair.second, [&](const XmlElement& xmlChild)
{
- typename T::value_type childVal; //MSVC 2010 bug: cannot put this into a lambda body
- if (zen::readStruc(*it, childVal))
- value.insert(value.end(), childVal);
+ typename T::value_type childVal;
+ if (zen::readStruc(xmlChild, childVal))
+ value.insert(value.end(), std::move(childVal));
else
success = false;
//should we support insertion of partially-loaded struct??
- }
+ });
return success;
}
};
@@ -141,7 +142,7 @@ struct ConvertElement<T, ValueType::STL_CONTAINER>
//partial specialization: handle conversion for std::pair
template <class T>
-struct ConvertElement<T, ValueType::STL_PAIR>
+struct ConvertElement<T, ValueType::stlPair>
{
void writeStruc(const T& value, XmlElement& output) const
{
@@ -169,7 +170,7 @@ struct ConvertElement<T, ValueType::STL_PAIR>
//partial specialization: not a pure structured type, try text conversion (thereby respect user specializations of writeText()/readText())
template <class T>
-struct ConvertElement<T, ValueType::OTHER>
+struct ConvertElement<T, ValueType::other>
{
void writeStruc(const T& value, XmlElement& output) const
{
bgstack15