A Discrete-Event Network Simulator
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
27namespace ns3
28{
29
44{
45 public:
47
52 void PushBytes(std::vector<uint8_t> bytes);
53
59 void PushBytes(uint8_t* bytes, uint32_t size);
60
65 void PushByte(uint8_t byte);
66
77 uint64_t GetBits(uint8_t size);
78
79 private:
84
85 std::deque<bool> m_blob;
86 std::vector<uint8_t> m_bytesBlob;
88};
89
90} // namespace ns3
91
92#endif /* BITDESERIALIZER_H_ */
Bit deserializer.
void PushBytes(std::vector< uint8_t > bytes)
Pushes some bytes into the blob to be deserialized.
std::vector< uint8_t > m_bytesBlob
Blob of bytes to be deserialized.
void PrepareDeserialization()
Prepare the byte array to the deserialization.
void PushByte(uint8_t byte)
Pushes one byte into the blob to be deserialized.
bool m_deserializing
True if the deserialization did start already.
std::deque< bool > m_blob
Blob of bits ready to be deserialized.
uint64_t GetBits(uint8_t size)
Pops a given number of bits from the blob front.
Every class exported by the ns3 library is enclosed in the ns3 namespace.