A Discrete-Event Network Simulator
API
bit-deserializer.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 Universita' di Firenze, Italy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19  */
20 
21 #ifndef BITDESERIALIZER_H_
22 #define BITDESERIALIZER_H_
23 
24 #include <vector>
25 #include <deque>
26 
27 namespace ns3 {
28 
43 {
44 public:
45  BitDeserializer ();
46 
51  void PushBytes (std::vector<uint8_t> bytes);
52 
58  void PushBytes (uint8_t* bytes, uint32_t size);
59 
64  void PushByte (uint8_t byte);
65 
76  uint64_t GetBits (uint8_t size);
77 
78 private:
82  void PrepareDeserialization ();
83 
84  std::deque<bool> m_blob;
85  std::vector<uint8_t> m_bytesBlob;
87 };
88 
89 } // namespace ns3
90 
91 #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.