Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/BarcodeFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#include "DataMatrixGenerator.h"
#include "IBarcodeGenerator.h"
#include "ItfGenerator.h"
#include "QrGenerator.h"
#include "QrCodeGenerator.h"
#include "UpcAGenerator.h"
#include "UpcEGenerator.h"
#include <memory>
#include <string>
class BarcodeFactory {
Expand Down
2 changes: 1 addition & 1 deletion include/QrGenerator.h → include/QrCodeGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <string>
#include <utility>

class QrGenerator : public virtual IBarcodeGenerator {
class QrCodeGenerator : public virtual IBarcodeGenerator {
private:
ZXing::MultiFormatWriter writer{ZXing::BarcodeFormat::QRCode};

Expand Down
21 changes: 21 additions & 0 deletions include/UpcEGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "IBarcodeGenerator.h"
#include <ZXing/Barcode.h>
#include <ZXing/BarcodeFormat.h>
#include <ZXing/BitMatrix.h>
#include <ZXing/BitMatrixIO.h>
#include <ZXing/CharacterSet.h>
#include <ZXing/Matrix.h>
#include <ZXing/MultiFormatWriter.h>
#include <memory>
#include <stdexcept>
#include <string>
#include <utility>

class UpcEGenerator : public virtual IBarcodeGenerator {
private:
ZXing::MultiFormatWriter writer{ZXing::BarcodeFormat::UPCE};

public:
std::string generate(const std::string &text, int margin, int size);
};
12 changes: 7 additions & 5 deletions src/BarcodeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

std::unique_ptr<IBarcodeGenerator>
BarcodeFactory::create(const std::string type) {
if (type == "Qr") {
return std::make_unique<QrGenerator>();
if (type == "QrCode") {
return std::make_unique<QrCodeGenerator>();
} else if (type == "DataMatrix") {
return std::make_unique<DataMatrixGenerator>();
} else if (type == "UPCA") {
} else if (type == "UpcA") {
return std::make_unique<UpcAGenerator>();
} else if (type == "ITF") {
} else if (type == "UpcE") {
return std::make_unique<UpcEGenerator>();
} else if (type == "Itf") {
return std::make_unique<ItfGenerator>();
} else if (type == "DataBar") {
return std::make_unique<DataBarGenerator>();
Expand All @@ -21,5 +23,5 @@ BarcodeFactory::create(const std::string type) {
return std::make_unique<Code93Generator>();
}

return std::make_unique<QrGenerator>();
return std::make_unique<QrCodeGenerator>();
}
10 changes: 10 additions & 0 deletions src/QrCodeGenerator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "../include/QrCodeGenerator.h"

std::string QrCodeGenerator::generate(const std::string &text, int margin,
int size) {
writer.setMargin(margin);
writer.setEncoding(ZXing::CharacterSet::UTF8);
ZXing::BitMatrix matrix = writer.encode(text, size, size);

return ZXing::ToSVG(matrix);
}
6 changes: 3 additions & 3 deletions src/QrGenerator.cpp → src/UpcEGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../include/QrGenerator.h"
#include "../include/UpcEGenerator.h"

std::string QrGenerator::generate(const std::string &text, int margin,
int size) {
std::string UpcEGenerator::generate(const std::string &text, int margin,
int size) {
writer.setMargin(margin);
writer.setEncoding(ZXing::CharacterSet::UTF8);
ZXing::BitMatrix matrix = writer.encode(text, size, size);
Expand Down