91 size_t dataSize =
data.size();
92 uint8_t pendingBits = dataSize;
107 if (dataSize <= 65536)
119 mask = (mask >> 1) & (~mask);
130 while (pendingBits > 0)
141 while (pendingBits > 0)
144 mask = (mask >> 1) & (~mask);
152 uint8_t octetToWrite = 0;
155 octetToWrite |= (
data[pendingBits - j]) ? mask : 0;
156 mask = (mask << 1) & (~mask);
175 SerializeBitset<N>(
data);
181 SerializeBitstring<1>(
data);
187 SerializeBitstring<2>(
data);
193 SerializeBitstring<8>(
data);
199 SerializeBitstring<10>(
data);
205 SerializeBitstring<16>(
data);
211 SerializeBitstring<27>(
data);
217 SerializeBitstring<28>(
data);
223 SerializeBitstring<32>(
data);
231 (value) ? val.set() : val.reset();
232 SerializeBitset<1>(val);
238 bool isExtensionMarkerPresent)
const
240 if (isExtensionMarkerPresent)
245 SerializeBitstring<N>(optionalOrDefaultMask);
250 bool isExtensionMarkerPresent)
const
252 SerializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent);
257 bool isExtensionMarkerPresent)
const
259 SerializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent);
264 bool isExtensionMarkerPresent)
const
266 SerializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent);
271 bool isExtensionMarkerPresent)
const
273 SerializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent);
278 bool isExtensionMarkerPresent)
const
280 SerializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent);
285 bool isExtensionMarkerPresent)
const
287 SerializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent);
292 bool isExtensionMarkerPresent)
const
294 SerializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent);
299 bool isExtensionMarkerPresent)
const
301 SerializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent);
306 bool isExtensionMarkerPresent)
const
308 SerializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent);
313 bool isExtensionMarkerPresent)
const
315 SerializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent);
320 bool isExtensionMarkerPresent)
const
322 SerializeSequence<11>(optionalOrDefaultMask, isExtensionMarkerPresent);
342 if (isExtensionMarkerPresent)
365 long int nComp = nmin;
368 "Integer " << n <<
" is outside range [" << nmin <<
", " << nmax <<
"]");
371 int range = nmax - nmin + 1;
382 int requiredBits = std::ceil(std::log(range) / std::log(2.0));
384 switch (requiredBits)
387 SerializeBitset<1>(std::bitset<1>(n));
390 SerializeBitset<2>(std::bitset<2>(n));
393 SerializeBitset<3>(std::bitset<3>(n));
396 SerializeBitset<4>(std::bitset<4>(n));
399 SerializeBitset<5>(std::bitset<5>(n));
402 SerializeBitset<6>(std::bitset<6>(n));
405 SerializeBitset<7>(std::bitset<7>(n));
408 SerializeBitset<8>(std::bitset<8>(n));
411 SerializeBitset<9>(std::bitset<9>(n));
414 SerializeBitset<10>(std::bitset<10>(n));
417 SerializeBitset<11>(std::bitset<11>(n));
420 SerializeBitset<12>(std::bitset<12>(n));
423 SerializeBitset<13>(std::bitset<13>(n));
426 SerializeBitset<14>(std::bitset<14>(n));
429 SerializeBitset<15>(std::bitset<15>(n));
432 SerializeBitset<16>(std::bitset<16>(n));
435 SerializeBitset<17>(std::bitset<17>(n));
438 SerializeBitset<18>(std::bitset<18>(n));
441 SerializeBitset<19>(std::bitset<19>(n));
444 SerializeBitset<20>(std::bitset<20>(n));
447 std::cout <<
"SerializeInteger " << requiredBits <<
" Out of range!!" << std::endl;
490 while (bitsToRead > 0)
492 uint8_t octet = bIterator.
ReadU8();
497 for (
int j = 0; j < 8; j++)
499 data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
511 while (bitsToRead > 0)
513 data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
527 return DeserializeBitset<N>(
data, bIterator);
533 return DeserializeBitstring<1>(
data, bIterator);
539 return DeserializeBitstring<2>(
data, bIterator);
545 return DeserializeBitstring<8>(
data, bIterator);
551 return DeserializeBitstring<10>(
data, bIterator);
557 return DeserializeBitstring<16>(
data, bIterator);
563 return DeserializeBitstring<27>(
data, bIterator);
569 return DeserializeBitstring<28>(
data, bIterator);
575 return DeserializeBitstring<32>(
data, bIterator);
581 std::bitset<1> readBit;
582 bIterator = DeserializeBitset<1>(&readBit, bIterator);
583 *value = (readBit[0] == 1);
598 int range = nmax - nmin + 1;
605 int requiredBits = std::ceil(std::log(range) / std::log(2.0));
607 std::bitset<1> bitsRead1;
608 std::bitset<2> bitsRead2;
609 std::bitset<3> bitsRead3;
610 std::bitset<4> bitsRead4;
611 std::bitset<5> bitsRead5;
612 std::bitset<6> bitsRead6;
613 std::bitset<7> bitsRead7;
614 std::bitset<8> bitsRead8;
615 std::bitset<9> bitsRead9;
616 std::bitset<10> bitsRead10;
617 std::bitset<11> bitsRead11;
618 std::bitset<12> bitsRead12;
619 std::bitset<13> bitsRead13;
620 std::bitset<14> bitsRead14;
621 std::bitset<15> bitsRead15;
622 std::bitset<16> bitsRead16;
623 std::bitset<17> bitsRead17;
624 std::bitset<18> bitsRead18;
625 std::bitset<19> bitsRead19;
626 std::bitset<20> bitsRead20;
628 switch (requiredBits)
631 bIterator = DeserializeBitset<1>(&bitsRead1, bIterator);
632 *n = (int)bitsRead1.to_ulong();
635 bIterator = DeserializeBitset<2>(&bitsRead2, bIterator);
636 *n = (int)bitsRead2.to_ulong();
639 bIterator = DeserializeBitset<3>(&bitsRead3, bIterator);
640 *n = (int)bitsRead3.to_ulong();
643 bIterator = DeserializeBitset<4>(&bitsRead4, bIterator);
644 *n = (int)bitsRead4.to_ulong();
647 bIterator = DeserializeBitset<5>(&bitsRead5, bIterator);
648 *n = (int)bitsRead5.to_ulong();
651 bIterator = DeserializeBitset<6>(&bitsRead6, bIterator);
652 *n = (int)bitsRead6.to_ulong();
655 bIterator = DeserializeBitset<7>(&bitsRead7, bIterator);
656 *n = (int)bitsRead7.to_ulong();
659 bIterator = DeserializeBitset<8>(&bitsRead8, bIterator);
660 *n = (int)bitsRead8.to_ulong();
663 bIterator = DeserializeBitset<9>(&bitsRead9, bIterator);
664 *n = (int)bitsRead9.to_ulong();
667 bIterator = DeserializeBitset<10>(&bitsRead10, bIterator);
668 *n = (int)bitsRead10.to_ulong();
671 bIterator = DeserializeBitset<11>(&bitsRead11, bIterator);
672 *n = (int)bitsRead11.to_ulong();
675 bIterator = DeserializeBitset<12>(&bitsRead12, bIterator);
676 *n = (int)bitsRead12.to_ulong();
679 bIterator = DeserializeBitset<13>(&bitsRead13, bIterator);
680 *n = (int)bitsRead13.to_ulong();
683 bIterator = DeserializeBitset<14>(&bitsRead14, bIterator);
684 *n = (int)bitsRead14.to_ulong();
687 bIterator = DeserializeBitset<15>(&bitsRead15, bIterator);
688 *n = (int)bitsRead15.to_ulong();
691 bIterator = DeserializeBitset<16>(&bitsRead16, bIterator);
692 *n = (int)bitsRead16.to_ulong();
695 bIterator = DeserializeBitset<17>(&bitsRead17, bIterator);
696 *n = (int)bitsRead17.to_ulong();
699 bIterator = DeserializeBitset<18>(&bitsRead18, bIterator);
700 *n = (int)bitsRead18.to_ulong();
703 bIterator = DeserializeBitset<19>(&bitsRead19, bIterator);
704 *n = (int)bitsRead19.to_ulong();
707 bIterator = DeserializeBitset<20>(&bitsRead20, bIterator);
708 *n = (int)bitsRead20.to_ulong();
711 std::cout <<
"SerializeInteger Out of range!!" << std::endl;
723 bool isExtensionMarkerPresent,
727 if (isExtensionMarkerPresent)
744 bool isExtensionMarkerPresent,
747 if (isExtensionMarkerPresent)
752 bIterator = DeserializeBitset<N>(optionalOrDefaultMask, bIterator);
758 bool isExtensionMarkerPresent,
761 return DeserializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
766 bool isExtensionMarkerPresent,
769 return DeserializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
774 bool isExtensionMarkerPresent,
777 return DeserializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
782 bool isExtensionMarkerPresent,
785 return DeserializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
790 bool isExtensionMarkerPresent,
793 return DeserializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
798 bool isExtensionMarkerPresent,
801 return DeserializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
806 bool isExtensionMarkerPresent,
809 return DeserializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
814 bool isExtensionMarkerPresent,
817 return DeserializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
822 bool isExtensionMarkerPresent,
825 return DeserializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
830 bool isExtensionMarkerPresent,
833 return DeserializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
838 bool isExtensionMarkerPresent,
841 return DeserializeSequence<11>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
iterator in a Buffer instance
void WriteU8(uint8_t data)
void Write(const uint8_t *buffer, uint32_t size)
void Prev()
go backward by one byte
Buffer::Iterator Begin() const
void AddAtEnd(uint32_t end)
Buffer::Iterator End() const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.