fixed ...
[senf.git] / senf / Packets / ListOptionTypeParser.cti
index adf88ca..819f15e 100644 (file)
@@ -109,9 +109,8 @@ construct(container_type & c)
     safe_data_iterator e = i + realAux_;
     for (n_ = 0; i != e;) {
         unsigned int elByte = senf::bytes(ElementParser(i, c.state()));
-        if (((i + elByte) == e) && (i[0] == 0u || i[0] == 1u)) { //check wether last element is padding or not
+        if (((i + elByte) == e) && (i[0] == 0u || i[0] == 1u)) { //check weather last element is padding or not
             realAux_ -= std::distance(i, e);
-            container_size_ -= std::distance(i, e);
             c.data().erase(i, e); //delete padding
             e = i; //set end iterator
         } else{
@@ -119,7 +118,6 @@ construct(container_type & c)
             std::advance(i, elByte);
         }
     }
-    //    container_size_ = std::distance(i,e);
     container_size_ = c.data().size(); //set actual size without padding
 }
 
@@ -131,12 +129,15 @@ destruct(container_type & c)
 {
     // data_iterator i (AuxPolicy::adjust(parser_type::get(p).i(), parser_type::get(p).state()));
     safe_data_iterator i (c.data(), c.i()) ;
-    safe_data_iterator const e = i + realAux_;
+    safe_data_iterator e = i + realAux_;
     unsigned int padBytes = 0;
     if (realAux_ == 0)      //if list is empty, 6 padding bytes required!
       padBytes = 6;
-    else
+    else{
       padBytes = ( (realAux_+2) % 8);
+      if (padBytes != 0)
+          padBytes = 8 - padBytes;
+    }
     if (padBytes > 0) {
         c.data().insert(e, padBytes, 0u);
         if (padBytes > 1) {
@@ -179,9 +180,7 @@ prefix_ void
 senf::detail::ListOptionTypeParser_Policy<ElementParser,AuxPolicy>::container_policy::
 init(data_iterator i, state_type s)
 {
-//    i[0] = 1u;
-    //    for (unsigned int n = 1;n < 6; ++n)
-//        i[n] = 0u;
+    realAux_ = 0;
     n_ = 0;
     container_size_ = s->size();
     AuxPolicy::aux(0, i, s);
@@ -193,15 +192,10 @@ prefix_ void
 senf::detail::ListOptionTypeParser_Policy<ElementParser,AuxPolicy>::container_policy::
 erase(container_type & c, data_iterator p)
 {
-    size_type b(senf::bytes(ElementParser(p, c.state()))); //length of parser
-    //    AuxPolicy::aux(
-    //                 AuxPolicy::aux( c.i(), c.state()) -b,
-    //                 c.i(),
-    //                 c.state());
+    size_type b(senf::bytes(ElementParser(p, c.state())));
     realAux_ -= b;
     --n_;
-    // The container will be reduced by b bytes directly after this call
-    container_size_ -= b;
+    container_size_ = c.data().size() - b;
 }
 
 //insert()
@@ -211,7 +205,6 @@ senf::detail::ListOptionTypeParser_Policy<ElementParser,AuxPolicy>::container_po
 insert(container_type & c, data_iterator p)
 {
     size_type b(senf::bytes(ElementParser(p, c.state())));
-    //    AuxPolicy::aux( AuxPolicy::aux(c.i(), c.state())+b, c.i(), c.state());
     realAux_ += b;
     ++n_;
     container_size_ = c.data().size();
@@ -230,7 +223,6 @@ update(container_type const & c)
     data_iterator j(i);
     for (size_type n(n_); n; --n, std::advance(j, senf::bytes(ElementParser(j,c.state()))));
     realAux_ = std::distance(i, j);
-    //    aux( std::distance(i,j), c.i(), c.state() );
     container_size_ = c.data().size();
 }
 
@@ -243,7 +235,6 @@ setBegin(container_type const & c, iterator_data & d)
     const
 {
     return c.i();
-    //    return AuxPolicy::adjust(c.i(), c.state());
 }
 
 //setEnd()
@@ -253,8 +244,8 @@ prefix_ typename senf::detail::ListOptionTypeParser_Policy<
 senf::detail::ListOptionTypeParser_Policy<ElementParser,AuxPolicy>::container_policy::
 setEnd(container_type const & c, iterator_data & d)
     const
-{ //wtf??
-    return boost::next(AuxPolicy::adjust(c.i(), c.state()), aux(c.i(),c.state()));
+{
+    return boost::next(c.i(),realAux_);
 }
 
 //setFromPosition()