BigBlueBox
An Inventory Management System for a NYLT Course or other Boy Scout Programs
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
BitBuffer.h
Go to the documentation of this file.
1 /*
2  * QR Code generator library (C++)
3  *
4  * Copyright (c) Project Nayuki. (MIT License)
5  * https://www.nayuki.io/page/qr-code-generator-library
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  * - The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  * - The Software is provided "as is", without warranty of any kind, express or
16  * implied, including but not limited to the warranties of merchantability,
17  * fitness for a particular purpose and noninfringement. In no event shall the
18  * authors or copyright holders be liable for any claim, damages or other
19  * liability, whether in an action of contract, tort or otherwise, arising from,
20  * out of or in connection with the Software or the use or other dealings in the
21  * Software.
22  */
23 
24 #pragma once
25 
26 #include <cstdint>
27 #include <vector>
28 
29 
30 namespace qrcodegen {
31 
32 /*
33  * An appendable sequence of bits (0's and 1's).
34  */
35 class BitBuffer final : public std::vector<bool> {
36 
37  /*---- Constructor ----*/
38 
39  // Creates an empty bit buffer (length 0).
40  public: BitBuffer();
41 
42 
43 
44  /*---- Methods ----*/
45 
46  // Packs this buffer's bits into bytes in big endian,
47  // padding with '0' bit values, and returns the new vector.
48  public: std::vector<std::uint8_t> getBytes() const;
49 
50 
51  // Appends the given number of low bits of the given value
52  // to this sequence. Requires 0 <= val < 2^len.
53  public: void appendBits(std::uint32_t val, int len);
54 
55 };
56 
57 }
void appendBits(std::uint32_t val, int len)
Definition: BitBuffer.cpp:41
std::vector< std::uint8_t > getBytes() const
Definition: BitBuffer.cpp:33
Definition: BitBuffer.h:35
BitBuffer()
Definition: BitBuffer.cpp:29