Reduced redundancy in C++ code by wrapping .cpp source files in namespace{} blocks.

This commit is contained in:
Project Nayuki
2017-04-21 05:30:59 +00:00
parent 771bdaf069
commit cc2a5d4ce9
3 changed files with 68 additions and 56 deletions
+9 -5
View File
@@ -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));
}
}
}