Procházet zdrojové kódy

Fix weak warning in SerializableSectionPairRowListValue class

Patrick-Christopher Mattulat před 1 rokem
rodič
revize
b5f33fc70d

+ 9 - 9
source/ls-std/io/section-pair/serialization/SerializableSectionPairRowListValue.cpp

@@ -3,14 +3,17 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-11
-* Changed:         2023-02-23
+* Changed:         2023-02-24
 *
 * */
 
+#include <list>
 #include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
 #include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
+#include <ls-std/io/section-pair/SectionPairTypes.hpp>
 #include <ls-std/io/section-pair/model/SectionPairRowListValue.hpp>
 #include <ls-std/io/section-pair/serialization/SerializableSectionPairRowListValue.hpp>
+#include <numeric>
 
 using ls::std::core::Class;
 using ls::std::core::EmptyStringArgumentEvaluator;
@@ -19,7 +22,10 @@ using ls::std::core::type::byte_field;
 using ls::std::io::SectionPairRowListValue;
 using ls::std::io::SerializableSectionPairParameter;
 using ls::std::io::SerializableSectionPairRowListValue;
+using std::accumulate;
 using std::dynamic_pointer_cast;
+using std::list;
+using std::move;
 using std::shared_ptr;
 using std::string;
 
@@ -39,14 +45,8 @@ shared_ptr<Class> SerializableSectionPairRowListValue::getValue()
 
 byte_field SerializableSectionPairRowListValue::marshal()
 {
-  byte_field data{};
-
-  for (const auto &_value : dynamic_pointer_cast<SectionPairRowListValue>(this->getValue())->getList())
-  {
-    data += "  " + _value + this->parameter.getNewLine();
-  }
-
-  return data;
+  list<section_pair_row_value> listValue = dynamic_pointer_cast<SectionPairRowListValue>(this->getValue())->getList();
+  return accumulate(listValue.begin(), listValue.end(), byte_field{}, [this](byte_field data, const byte_field &_value) { return ::move(data) + "  " + _value + this->parameter.getNewLine(); });
 }
 
 void SerializableSectionPairRowListValue::unmarshal(const byte_field &_data)