mirror of
https://github.com/status-im/QR-Code-generator.git
synced 2026-08-31 01:31:10 +00:00
Reduced redundancy in C++ code by wrapping .cpp source files in namespace{} blocks.
This commit is contained in:
+9
-5
@@ -27,22 +27,24 @@
|
||||
#include "BitBuffer.hpp"
|
||||
|
||||
|
||||
qrcodegen::BitBuffer::BitBuffer() :
|
||||
namespace qrcodegen {
|
||||
|
||||
BitBuffer::BitBuffer() :
|
||||
data(),
|
||||
bitLength(0) {}
|
||||
|
||||
|
||||
int qrcodegen::BitBuffer::getBitLength() const {
|
||||
int BitBuffer::getBitLength() const {
|
||||
return bitLength;
|
||||
}
|
||||
|
||||
|
||||
std::vector<uint8_t> qrcodegen::BitBuffer::getBytes() const {
|
||||
std::vector<uint8_t> BitBuffer::getBytes() const {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void qrcodegen::BitBuffer::appendBits(uint32_t val, int len) {
|
||||
void BitBuffer::appendBits(uint32_t val, int len) {
|
||||
if (len < 0 || len > 32 || (len < 32 && (val >> len) != 0))
|
||||
throw "Value out of range";
|
||||
if (INT_MAX - bitLength < len)
|
||||
@@ -55,7 +57,7 @@ void qrcodegen::BitBuffer::appendBits(uint32_t val, int len) {
|
||||
}
|
||||
|
||||
|
||||
void qrcodegen::BitBuffer::appendData(const QrSegment &seg) {
|
||||
void BitBuffer::appendData(const QrSegment &seg) {
|
||||
if (INT_MAX - bitLength < seg.bitLength)
|
||||
throw "Buffer too long";
|
||||
unsigned int newByteLen = ((unsigned int)bitLength + seg.bitLength + 7) / 8;
|
||||
@@ -66,3 +68,5 @@ void qrcodegen::BitBuffer::appendData(const QrSegment &seg) {
|
||||
data.at(bitLength >> 3) |= bit << (7 - (bitLength & 7));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user