code quality: consolidated helpers to single header

development
Michael Ochmann 2 years ago
parent b99850c042
commit df1c3a78ba
  1. 6
      main.cpp
  2. 1
      src/QR.cpp
  3. 7
      src/QR.hpp
  4. 12
      src/util.hpp

@ -3,10 +3,10 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "qrcodegen.hpp" #include <qrcodegen.hpp>
#include "QR.hpp"
#define UNUSED(var) (void) var; #include "util.hpp"
#include "QR.hpp"
// Version is injected through cmake // Version is injected through cmake
constexpr const char* VERSION = "@qr_VERSION@"; constexpr const char* VERSION = "@qr_VERSION@";

@ -14,6 +14,7 @@ namespace massivedynamic {
QR::QR(const std::string& data, std::string outputFile, size_t size, qrcodegen::QrCode::Ecc type) : outputFile(std::move(outputFile)), QR::QR(const std::string& data, std::string outputFile, size_t size, qrcodegen::QrCode::Ecc type) : outputFile(std::move(outputFile)),
qr(qrcodegen::QrCode::encodeText(data.c_str(), type)), size(size) { qr(qrcodegen::QrCode::encodeText(data.c_str(), type)), size(size) {
this->pixels.reserve(this->qr.getSize() * this->qr.getSize());
// this is inherently stupid, but "qrcodegen::QrCode" does not give access to the // this is inherently stupid, but "qrcodegen::QrCode" does not give access to the
// `segments` vector member and the class itself is marked final. // `segments` vector member and the class itself is marked final.
for (int y = 0; y < qr.getSize(); y++) { for (int y = 0; y < qr.getSize(); y++) {

@ -2,15 +2,12 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <qrcodegen.hpp>
#include "qrcodegen.hpp" #include "util.hpp"
#include "Renderer.hpp" #include "Renderer.hpp"
#define UNUSED_CASE(name) case name: break;
namespace massivedynamic { namespace massivedynamic {
typedef uint32_t Color;
enum class Format { enum class Format {
CONSOLE, CONSOLE,
SVG, SVG,

@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
#define UNUSED(var) (void) var;
#define UNUSED_CASE(name) case name: break;
namespace massivedynamic {
using Color = uint32_t;
}
Loading…
Cancel
Save