92 size_t dataSize =
data.size();
93 uint8_t pendingBits = dataSize;
108 if (dataSize <= 65536)
120 mask = (mask >> 1) & (~mask);
131 while (pendingBits > 0)
142 while (pendingBits > 0)
145 mask = (mask >> 1) & (~mask);
153 uint8_t octetToWrite = 0;
156 octetToWrite |= (
data[pendingBits - j]) ? mask : 0;
157 mask = (mask << 1) & (~mask);
168 printf(
"FRAGMENTATION NEEDED!\n");
176 SerializeBitset<N>(
data);
182 SerializeBitstring<1>(
data);
188 SerializeBitstring<2>(
data);
194 SerializeBitstring<8>(
data);
200 SerializeBitstring<10>(
data);
206 SerializeBitstring<16>(
data);
212 SerializeBitstring<27>(
data);
218 SerializeBitstring<28>(
data);
224 SerializeBitstring<32>(
data);
232 (value) ? val.set() : val.reset();
233 SerializeBitset<1>(val);
239 bool isExtensionMarkerPresent)
const
241 if (isExtensionMarkerPresent)
246 SerializeBitstring<N>(optionalOrDefaultMask);
251 bool isExtensionMarkerPresent)
const
253 SerializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent);
258 bool isExtensionMarkerPresent)
const
260 SerializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent);
265 bool isExtensionMarkerPresent)
const
267 SerializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent);
272 bool isExtensionMarkerPresent)
const
274 SerializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent);
279 bool isExtensionMarkerPresent)
const
281 SerializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent);
286 bool isExtensionMarkerPresent)
const
288 SerializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent);
293 bool isExtensionMarkerPresent)
const
295 SerializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent);
300 bool isExtensionMarkerPresent)
const
302 SerializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent);
307 bool isExtensionMarkerPresent)
const
309 SerializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent);
314 bool isExtensionMarkerPresent)
const
316 SerializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent);
321 bool isExtensionMarkerPresent)
const
323 SerializeSequence<11>(optionalOrDefaultMask, isExtensionMarkerPresent);
343 if (isExtensionMarkerPresent)
366 long int nComp = nmin;
369 "Integer " << n <<
" is outside range [" << nmin <<
", " << nmax <<
"]");
372 int range = nmax - nmin + 1;
383 int requiredBits = std::ceil(std::log(range) / std::log(2.0));
385 switch (requiredBits)
388 SerializeBitset<1>(std::bitset<1>(n));
391 SerializeBitset<2>(std::bitset<2>(n));
394 SerializeBitset<3>(std::bitset<3>(n));
397 SerializeBitset<4>(std::bitset<4>(n));
400 SerializeBitset<5>(std::bitset<5>(n));
403 SerializeBitset<6>(std::bitset<6>(n));
406 SerializeBitset<7>(std::bitset<7>(n));
409 SerializeBitset<8>(std::bitset<8>(n));
412 SerializeBitset<9>(std::bitset<9>(n));
415 SerializeBitset<10>(std::bitset<10>(n));
418 SerializeBitset<11>(std::bitset<11>(n));
421 SerializeBitset<12>(std::bitset<12>(n));
424 SerializeBitset<13>(std::bitset<13>(n));
427 SerializeBitset<14>(std::bitset<14>(n));
430 SerializeBitset<15>(std::bitset<15>(n));
433 SerializeBitset<16>(std::bitset<16>(n));
436 SerializeBitset<17>(std::bitset<17>(n));
439 SerializeBitset<18>(std::bitset<18>(n));
442 SerializeBitset<19>(std::bitset<19>(n));
445 SerializeBitset<20>(std::bitset<20>(n));
448 std::cout <<
"SerializeInteger " << requiredBits <<
" Out of range!!" << std::endl;
491 while (bitsToRead > 0)
493 uint8_t octet = bIterator.
ReadU8();
498 for (
int j = 0; j < 8; j++)
500 data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
512 while (bitsToRead > 0)
514 data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
528 return DeserializeBitset<N>(
data, bIterator);
534 return DeserializeBitstring<1>(
data, bIterator);
540 return DeserializeBitstring<2>(
data, bIterator);
546 return DeserializeBitstring<8>(
data, bIterator);
552 return DeserializeBitstring<10>(
data, bIterator);
558 return DeserializeBitstring<16>(
data, bIterator);
564 return DeserializeBitstring<27>(
data, bIterator);
570 return DeserializeBitstring<28>(
data, bIterator);
576 return DeserializeBitstring<32>(
data, bIterator);
582 std::bitset<1> readBit;
583 bIterator = DeserializeBitset<1>(&readBit, bIterator);
584 *value = (readBit[0] == 1);
599 int range = nmax - nmin + 1;
606 int requiredBits = std::ceil(std::log(range) / std::log(2.0));
608 std::bitset<1> bitsRead1;
609 std::bitset<2> bitsRead2;
610 std::bitset<3> bitsRead3;
611 std::bitset<4> bitsRead4;
612 std::bitset<5> bitsRead5;
613 std::bitset<6> bitsRead6;
614 std::bitset<7> bitsRead7;
615 std::bitset<8> bitsRead8;
616 std::bitset<9> bitsRead9;
617 std::bitset<10> bitsRead10;
618 std::bitset<11> bitsRead11;
619 std::bitset<12> bitsRead12;
620 std::bitset<13> bitsRead13;
621 std::bitset<14> bitsRead14;
622 std::bitset<15> bitsRead15;
623 std::bitset<16> bitsRead16;
624 std::bitset<17> bitsRead17;
625 std::bitset<18> bitsRead18;
626 std::bitset<19> bitsRead19;
627 std::bitset<20> bitsRead20;
629 switch (requiredBits)
632 bIterator = DeserializeBitset<1>(&bitsRead1, bIterator);
633 *n = (int)bitsRead1.to_ulong();
636 bIterator = DeserializeBitset<2>(&bitsRead2, bIterator);
637 *n = (int)bitsRead2.to_ulong();
640 bIterator = DeserializeBitset<3>(&bitsRead3, bIterator);
641 *n = (int)bitsRead3.to_ulong();
644 bIterator = DeserializeBitset<4>(&bitsRead4, bIterator);
645 *n = (int)bitsRead4.to_ulong();
648 bIterator = DeserializeBitset<5>(&bitsRead5, bIterator);
649 *n = (int)bitsRead5.to_ulong();
652 bIterator = DeserializeBitset<6>(&bitsRead6, bIterator);
653 *n = (int)bitsRead6.to_ulong();
656 bIterator = DeserializeBitset<7>(&bitsRead7, bIterator);
657 *n = (int)bitsRead7.to_ulong();
660 bIterator = DeserializeBitset<8>(&bitsRead8, bIterator);
661 *n = (int)bitsRead8.to_ulong();
664 bIterator = DeserializeBitset<9>(&bitsRead9, bIterator);
665 *n = (int)bitsRead9.to_ulong();
668 bIterator = DeserializeBitset<10>(&bitsRead10, bIterator);
669 *n = (int)bitsRead10.to_ulong();
672 bIterator = DeserializeBitset<11>(&bitsRead11, bIterator);
673 *n = (int)bitsRead11.to_ulong();
676 bIterator = DeserializeBitset<12>(&bitsRead12, bIterator);
677 *n = (int)bitsRead12.to_ulong();
680 bIterator = DeserializeBitset<13>(&bitsRead13, bIterator);
681 *n = (int)bitsRead13.to_ulong();
684 bIterator = DeserializeBitset<14>(&bitsRead14, bIterator);
685 *n = (int)bitsRead14.to_ulong();
688 bIterator = DeserializeBitset<15>(&bitsRead15, bIterator);
689 *n = (int)bitsRead15.to_ulong();
692 bIterator = DeserializeBitset<16>(&bitsRead16, bIterator);
693 *n = (int)bitsRead16.to_ulong();
696 bIterator = DeserializeBitset<17>(&bitsRead17, bIterator);
697 *n = (int)bitsRead17.to_ulong();
700 bIterator = DeserializeBitset<18>(&bitsRead18, bIterator);
701 *n = (int)bitsRead18.to_ulong();
704 bIterator = DeserializeBitset<19>(&bitsRead19, bIterator);
705 *n = (int)bitsRead19.to_ulong();
708 bIterator = DeserializeBitset<20>(&bitsRead20, bIterator);
709 *n = (int)bitsRead20.to_ulong();
712 std::cout <<
"SerializeInteger Out of range!!" << std::endl;
724 bool isExtensionMarkerPresent,
728 if (isExtensionMarkerPresent)
745 bool isExtensionMarkerPresent,
748 if (isExtensionMarkerPresent)
753 bIterator = DeserializeBitset<N>(optionalOrDefaultMask, bIterator);
759 bool isExtensionMarkerPresent,
762 return DeserializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
767 bool isExtensionMarkerPresent,
770 return DeserializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
775 bool isExtensionMarkerPresent,
778 return DeserializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
783 bool isExtensionMarkerPresent,
786 return DeserializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
791 bool isExtensionMarkerPresent,
794 return DeserializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
799 bool isExtensionMarkerPresent,
802 return DeserializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
807 bool isExtensionMarkerPresent,
810 return DeserializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
815 bool isExtensionMarkerPresent,
818 return DeserializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
823 bool isExtensionMarkerPresent,
826 return DeserializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
831 bool isExtensionMarkerPresent,
834 return DeserializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
839 bool isExtensionMarkerPresent,
842 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_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.