lmi-commits
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]