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
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18
*/
19
20
#ifndef BITDESERIALIZER_H_
21
#define BITDESERIALIZER_H_
22
23
#include <cstdint>
24
#include <deque>
25
#include <vector>
26
27
namespace
ns3
28
{
29
30
/**
31
* \ingroup packet
32
*
33
* \brief Bit deserializer. See also \sa ns3::BitSerializer
34
*
35
* This class helps converting a variable number, variable sized
36
* number of bit-boundary fields stored as byte array representation
37
* and extract the original bit-fields.
38
*
39
* Note that once the Deserialization starts, it's not anymore
40
* possible to add more data to the byte blob to deserialize.
41
*/
42
43
class
BitDeserializer
44
{
45
public
:
46
BitDeserializer
();
47
48
/**
49
* Pushes some bytes into the blob to be deserialized.
50
* \param bytes The bytes to add.
51
*/
52
void
PushBytes
(std::vector<uint8_t> bytes);
53
54
/**
55
* Pushes some bytes into the blob to be deserialized.
56
* \param bytes The bytes to add.
57
* \param size The length of the array.
58
*/
59
void
PushBytes
(uint8_t* bytes,
uint32_t
size);
60
61
/**
62
* Pushes one byte into the blob to be deserialized.
63
* \param byte The byte to add.
64
*/
65
void
PushByte
(uint8_t
byte
);
66
67
/**
68
* Pops a given number of bits from the blob front. In other terms,
69
* 'size' bits are shifted from the contents of the byte blob
70
* onto the return value.
71
*
72
* The maximum number of bits to be deserialized in one single call is 64.
73
*
74
* \param size The number of bits to pop.
75
* \return The popped bits value
76
*/
77
uint64_t
GetBits
(uint8_t size);
78
79
private
:
80
/**
81
* Prepare the byte array to the deserialization.
82
*/
83
void
PrepareDeserialization
();
84
85
std::deque<bool>
m_blob
;
//!< Blob of bits ready to be deserialized.
86
std::vector<uint8_t>
m_bytesBlob
;
//!< Blob of bytes to be deserialized.
87
bool
m_deserializing
;
//!< True if the deserialization did start already.
88
};
89
90
}
// namespace ns3
91
92
#endif
/* BITDESERIALIZER_H_ */
ns3::BitDeserializer
Bit deserializer.
Definition:
bit-deserializer.h:44
ns3::BitDeserializer::PushBytes
void PushBytes(std::vector< uint8_t > bytes)
Pushes some bytes into the blob to be deserialized.
Definition:
bit-deserializer.cc:39
ns3::BitDeserializer::m_bytesBlob
std::vector< uint8_t > m_bytesBlob
Blob of bytes to be deserialized.
Definition:
bit-deserializer.h:86
ns3::BitDeserializer::PrepareDeserialization
void PrepareDeserialization()
Prepare the byte array to the deserialization.
Definition:
bit-deserializer.cc:85
ns3::BitDeserializer::PushByte
void PushByte(uint8_t byte)
Pushes one byte into the blob to be deserialized.
Definition:
bit-deserializer.cc:58
ns3::BitDeserializer::m_deserializing
bool m_deserializing
True if the deserialization did start already.
Definition:
bit-deserializer.h:87
ns3::BitDeserializer::m_blob
std::deque< bool > m_blob
Blob of bits ready to be deserialized.
Definition:
bit-deserializer.h:85
ns3::BitDeserializer::BitDeserializer
BitDeserializer()
Definition:
bit-deserializer.cc:32
ns3::BitDeserializer::GetBits
uint64_t GetBits(uint8_t size)
Pops a given number of bits from the blob front.
Definition:
bit-deserializer.cc:66
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
utils
bit-deserializer.h
Generated on Tue May 28 2024 23:38:42 for ns-3 by
1.9.6