A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
bit-deserializer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Universita' di Firenze, Italy
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
7
*/
8
9
#ifndef BITDESERIALIZER_H_
10
#define BITDESERIALIZER_H_
11
12
#include <cstdint>
13
#include <deque>
14
#include <vector>
15
16
namespace
ns3
17
{
18
19
/**
20
* \ingroup packet
21
*
22
* \brief Bit deserializer. See also \sa ns3::BitSerializer
23
*
24
* This class helps converting a variable number, variable sized
25
* number of bit-boundary fields stored as byte array representation
26
* and extract the original bit-fields.
27
*
28
* Note that once the Deserialization starts, it's not anymore
29
* possible to add more data to the byte blob to deserialize.
30
*/
31
32
class
BitDeserializer
33
{
34
public
:
35
BitDeserializer
();
36
37
/**
38
* Pushes some bytes into the blob to be deserialized.
39
* \param bytes The bytes to add.
40
*/
41
void
PushBytes
(std::vector<uint8_t> bytes);
42
43
/**
44
* Pushes some bytes into the blob to be deserialized.
45
* \param bytes The bytes to add.
46
* \param size The length of the array.
47
*/
48
void
PushBytes
(uint8_t* bytes,
uint32_t
size);
49
50
/**
51
* Pushes one byte into the blob to be deserialized.
52
* \param byte The byte to add.
53
*/
54
void
PushByte
(uint8_t
byte
);
55
56
/**
57
* Pops a given number of bits from the blob front. In other terms,
58
* 'size' bits are shifted from the contents of the byte blob
59
* onto the return value.
60
*
61
* The maximum number of bits to be deserialized in one single call is 64.
62
*
63
* \param size The number of bits to pop.
64
* \return The popped bits value
65
*/
66
uint64_t
GetBits
(uint8_t size);
67
68
private
:
69
/**
70
* Prepare the byte array to the deserialization.
71
*/
72
void
PrepareDeserialization
();
73
74
std::deque<bool>
m_blob
;
//!< Blob of bits ready to be deserialized.
75
std::vector<uint8_t>
m_bytesBlob
;
//!< Blob of bytes to be deserialized.
76
bool
m_deserializing
;
//!< True if the deserialization did start already.
77
};
78
79
}
// namespace ns3
80
81
#endif
/* BITDESERIALIZER_H_ */
ns3::BitDeserializer
Bit deserializer.
Definition
bit-deserializer.h:33
ns3::BitDeserializer::PushBytes
void PushBytes(std::vector< uint8_t > bytes)
Pushes some bytes into the blob to be deserialized.
Definition
bit-deserializer.cc:28
ns3::BitDeserializer::m_bytesBlob
std::vector< uint8_t > m_bytesBlob
Blob of bytes to be deserialized.
Definition
bit-deserializer.h:75
ns3::BitDeserializer::PrepareDeserialization
void PrepareDeserialization()
Prepare the byte array to the deserialization.
Definition
bit-deserializer.cc:74
ns3::BitDeserializer::PushByte
void PushByte(uint8_t byte)
Pushes one byte into the blob to be deserialized.
Definition
bit-deserializer.cc:47
ns3::BitDeserializer::m_deserializing
bool m_deserializing
True if the deserialization did start already.
Definition
bit-deserializer.h:76
ns3::BitDeserializer::m_blob
std::deque< bool > m_blob
Blob of bits ready to be deserialized.
Definition
bit-deserializer.h:74
ns3::BitDeserializer::BitDeserializer
BitDeserializer()
Definition
bit-deserializer.cc:21
ns3::BitDeserializer::GetBits
uint64_t GetBits(uint8_t size)
Pops a given number of bits from the blob front.
Definition
bit-deserializer.cc:55
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
utils
bit-deserializer.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0