First byte in the example code is change to 1 not to 0
[senf.git] / Packets / 80221Bundle / TLVPacket.cc
index 5c7c0da..3bf2039 100644 (file)
@@ -127,25 +127,24 @@ prefix_ void senf::DynamicTLVLengthParser::shrink()
 }
 
 
-prefix_ void senf::BaseTLVPacketParser:: maxLengthValue(DynamicTLVLengthParser::value_type v)
-    const
+prefix_ void senf::DynamicTLVLengthParser:: maxValue(DynamicTLVLengthParser::value_type v)
 {
     if (v <= 127)
         return;
-    size_type b = senf::bytes( length_());
+    size_type b = bytes();
     if (v <= UInt8Parser::max_value) {
-        if (b < 2) length_().resize(2);
+        if (b < 2) resize(2);
         return;
     }
     if (v <= UInt16Parser::max_value) {
-        if (b < 3) length_().resize(3);
+        if (b < 3) resize(3);
         return;
     }
     if (v <= UInt24Parser::max_value) {
-        if (b < 4) length_().resize(4);
+        if (b < 4) resize(4);
         return;
     }
-    if (b < 5) length_().resize(5);
+    if (b < 5) resize(5);
 }
 
 
@@ -164,11 +163,10 @@ prefix_ void senf::DynamicTLVLengthParser::resize(size_type size)
     size_type current_size (bytes());
     SafePacketParserWrapper<DynamicTLVLengthParser> safeThis (*this);
     
-    safe_data_iterator si (data(), i());
     if (current_size > size)
-        data().erase( si, boost::next(si, current_size-size));
+        data().erase( i(), boost::next(i(), current_size-size));
     else
-        data().insert( si, size-current_size, 0);
+        data().insert( i(), size-current_size, 0);
     
     if (size > 1) {
         safeThis->extended_length_flag() = true;
@@ -176,7 +174,7 @@ prefix_ void senf::DynamicTLVLengthParser::resize(size_type size)
     } else {
         safeThis->extended_length_flag() = false;
     }
-    value(v);
+    safeThis->value(v);
 }