GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TightDataPacker.hpp
Go to the documentation of this file.
1 #ifndef TIGHT_DATA_PACKER_HPP
2 #define TIGHT_DATA_PACKER_HPP
3 
4 #include <cstdint>
5 #include <cstring>
6 #include <vector>
7 
8 namespace radix {
9 
11 protected:
12  std::vector<uint8_t> data;
13 
14 public:
16  TightDataPacker(unsigned int reserveBytes);
17  template<typename T> TightDataPacker& operator<<(T k) {
18  data.insert(data.end(), sizeof(k), 0);
19  std::memcpy(&data[data.size()-sizeof(k)], &k, sizeof(k));
20  return *this;
21  }
22  void reserve(unsigned int bytes);
23  unsigned int getSize() const;
24  const uint8_t* getDataPtr() const;
25 };
26 
27 } /* namespace radix */
28 
29 #endif /* TIGHT_DATA_PACKER_HPP */
std::vector< uint8_t > data
Definition: TightDataPacker.hpp:12
Definition: GameController.hpp:7
void reserve(unsigned int bytes)
Definition: TightDataPacker.cpp:9
TightDataPacker()
Definition: TightDataPacker.hpp:15
const uint8_t * getDataPtr() const
Definition: TightDataPacker.cpp:17
unsigned int getSize() const
Definition: TightDataPacker.cpp:13
Definition: TightDataPacker.hpp:10
TightDataPacker & operator<<(T k)
Definition: TightDataPacker.hpp:17