[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 75cf29b 08/12: Rename local variables
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 75cf29b 08/12: Rename local variables |
Date: |
Sat, 24 Oct 2020 16:51:34 -0400 (EDT) |
branch: master
commit 75cf29b2395a8ea1330c39d6a4714c14a3dd71ba
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Rename local variables
Where a throwaway variable of type 'T' is wanted,
the most natural name is 't'.
Where a throwaway variable of type 'xml::element' is wanted,
the most natural name is 'e'.
Where an argument signifies an XML parent element,
the most natural name is 'parent'.
---
xml_serialize.hpp | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/xml_serialize.hpp b/xml_serialize.hpp
index 047a64d..a18f5d8 100644
--- a/xml_serialize.hpp
+++ b/xml_serialize.hpp
@@ -85,29 +85,30 @@ template<typename C>
struct xml_sequence_io
{
using T = typename C::value_type;
+
static_assert(std::is_same<C,std::vector<T>>::value);
- static void to_xml(xml::element& e, C const& c)
+ static void to_xml(xml::element& parent, C const& c)
{
- e.clear();
+ parent.clear();
for(auto const& i : c)
{
// This is not equivalent to calling set_element():
// multiple <item> elements are expressly permitted.
- xml::element z("item");
- xml_io<T>::to_xml(z, i);
- e.push_back(z);
+ xml::element e("item");
+ xml_io<T>::to_xml(e, i);
+ parent.push_back(e);
}
}
- static void from_xml(xml::element const& e, C& c)
+ static void from_xml(xml::element const& parent, C& c)
{
c.clear();
- for(auto const& i : e.elements("item"))
+ for(auto const& i : parent.elements("item"))
{
- T z;
- xml_io<T>::from_xml(i, z);
- c.push_back(z);
+ T t;
+ xml_io<T>::from_xml(i, t);
+ c.push_back(t);
}
}
};
@@ -126,9 +127,9 @@ template<typename T>
void set_element(xml::element& parent, std::string const& name, T const& t)
{
LMI_ASSERT(parent.end() == parent.find(name.c_str()));
- xml::element z(name.c_str());
- xml_io<T>::to_xml(z, t);
- parent.push_back(z);
+ xml::element e(name.c_str());
+ xml_io<T>::to_xml(e, t);
+ parent.push_back(e);
}
/// Deserialize a datum from a subelement of the given xml element.
- [lmi-commits] [lmi] master updated (61277aa -> 4427d76), Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 65f92f3 06/12: Refactor, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 75399fe 01/12: Improve documentation, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master be4c0fd 05/12: Rename 'mete_*' functions for concinnity, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master d71f9e8 02/12: Improve parameter names, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 9671a72 03/12: Rearrange for concinnity, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 195d544 07/12: Improve explanation of certain unit tests, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master fdb2a62 04/12: Clarify unit-test output, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 75cf29b 08/12: Rename local variables,
Greg Chicares <=
- [lmi-commits] [lmi] master fb65723 09/12: Serialize pairs to and from xml, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master d385546 10/12: Serialize associative-pair containers to and from xml, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 2ba9033 11/12: Improve a variable's name, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 4427d76 12/12: C++17-ize, Greg Chicares, 2020/10/24