Restructuring directory layout. Move towards "Modern CMake" usage.

This commit is contained in:
Jim Evins
2017-11-23 22:15:24 -05:00
parent 8bec3594ec
commit b8ee5e1f73
198 changed files with 4509 additions and 5324 deletions
+8
View File
@@ -0,0 +1,8 @@
#=======================================
# Subdirectories
#=======================================
add_subdirectory (barcode)
add_subdirectory (merge)
+528
View File
@@ -0,0 +1,528 @@
/* Backends.cpp
*
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Backends.h"
#include "GnuBarcode.h"
#include "QrEncode.h"
#include "Zint.h"
#include "glbarcode/Factory.h"
namespace glabels::barcode
{
//
// Static data
//
QStringList Backends::mBackendIdList;
QMap<QString,QString> Backends::mBackendNameMap;
QList<Style> Backends::mStyleList;
Backends::Backends()
{
registerStyle( "code39", "", tr("Code 39"),
true, true, true, true, "1234567890", true, 10 );
registerStyle( "code39ext", "", tr("Code 39 Extended"),
true, true, true, true, "1234567890", true, 10 );
registerStyle( "upc-a", "", tr("UPC-A"),
true, false, true, false, "12345678901", false, 11 );
registerStyle( "ean-13", "", tr("EAN-13"),
true, false, true, false, "123456789012", false, 12 );
registerStyle( "postnet", "", tr("POSTNET (any)"),
false, false, true, false, "12345-6789-12", false, 11 );
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
false, false, true, false, "12345", false, 5 );
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
false, false, true, false, "12345-6789", false, 9 );
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
false, false, true, false, "12345-6789-12", false, 11 );
registerStyle( "cepnet", "", tr("CEPNET"),
false, false, true, false, "12345-678", false, 8 );
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
false, false, true, false, "12345678901234567890", false, 20 );
registerStyle( "datamatrix", "", tr("IEC16022 (DataMatrix)"),
false, false, true, false, "1234567890AB", false, 12 );
#if HAVE_GNU_BARCODE
//
// GNU Barcode backend
//
registerBackend( "gnu-barcode", "GNU Barcode" );
glbarcode::Factory::registerType( "gnu-barcode::ean", GnuBarcode::Ean::create );
glbarcode::Factory::registerType( "gnu-barcode::ean-8", GnuBarcode::Ean8::create );
glbarcode::Factory::registerType( "gnu-barcode::ean-8+2", GnuBarcode::Ean8_2::create );
glbarcode::Factory::registerType( "gnu-barcode::ean-8+5", GnuBarcode::Ean8_5::create );
glbarcode::Factory::registerType( "gnu-barcode::ean-13", GnuBarcode::Ean13::create );
glbarcode::Factory::registerType( "gnu-barcode::ean-13+2", GnuBarcode::Ean13_2::create );
glbarcode::Factory::registerType( "gnu-barcode::ean-13+5", GnuBarcode::Ean13_5::create );
glbarcode::Factory::registerType( "gnu-barcode::upc", GnuBarcode::Upc::create );
glbarcode::Factory::registerType( "gnu-barcode::upc-a", GnuBarcode::UpcA::create );
glbarcode::Factory::registerType( "gnu-barcode::upc-a+2", GnuBarcode::UpcA_2::create );
glbarcode::Factory::registerType( "gnu-barcode::upc-a+5", GnuBarcode::UpcA_5::create );
glbarcode::Factory::registerType( "gnu-barcode::upc-e", GnuBarcode::UpcE::create );
glbarcode::Factory::registerType( "gnu-barcode::upc-e+2", GnuBarcode::UpcE_2::create );
glbarcode::Factory::registerType( "gnu-barcode::upc-e+5", GnuBarcode::UpcE_5::create );
glbarcode::Factory::registerType( "gnu-barcode::isbn", GnuBarcode::Isbn::create );
glbarcode::Factory::registerType( "gnu-barcode::isbn+5", GnuBarcode::Isbn_5::create );
glbarcode::Factory::registerType( "gnu-barcode::code39", GnuBarcode::Code39::create );
glbarcode::Factory::registerType( "gnu-barcode::code128", GnuBarcode::Code128::create );
glbarcode::Factory::registerType( "gnu-barcode::code128c", GnuBarcode::Code128C::create );
glbarcode::Factory::registerType( "gnu-barcode::code128b", GnuBarcode::Code128B::create );
glbarcode::Factory::registerType( "gnu-barcode::i25", GnuBarcode::I25::create );
glbarcode::Factory::registerType( "gnu-barcode::cbr", GnuBarcode::Cbr::create );
glbarcode::Factory::registerType( "gnu-barcode::msi", GnuBarcode::Msi::create );
glbarcode::Factory::registerType( "gnu-barcode::pls", GnuBarcode::Pls::create );
glbarcode::Factory::registerType( "gnu-barcode::code93", GnuBarcode::Code93::create );
registerStyle( "ean", "gnu-barcode", tr("EAN (any)"),
true, true, true, false, "000000000000 00000", false, 17 );
registerStyle( "ean-8", "gnu-barcode", tr("EAN-8"),
true, true, true, false, "0000000", false, 7 );
registerStyle( "ean-8+2", "gnu-barcode", tr("EAN-8+2"),
true, true, true, false, "0000000 00", false, 9 );
registerStyle( "ean-8+5", "gnu-barcode", tr("EAN-8+5"),
true, true, true, false, "0000000 00000", false, 12 );
registerStyle( "ean-13", "gnu-barcode", tr("EAN-13"),
true, true, true, false, "000000000000", false, 12 );
registerStyle( "ean-13+2", "gnu-barcode", tr("EAN-13+2"),
true, true, true, false, "000000000000 00", false, 14 );
registerStyle( "ean-13+5", "gnu-barcode", tr("EAN-13+5"),
true, true, true, false, "000000000000 00000", false, 17 );
registerStyle( "upc", "gnu-barcode", tr("UPC (UPC-A or UPC-E)"),
true, true, true, false, "00000000000 00000", false, 16 );
registerStyle( "upc-a", "gnu-barcode", tr("UPC-A"),
true, true, true, false, "00000000000", false, 11 );
registerStyle( "upc-a+2", "gnu-barcode", tr("UPC-A +2"),
true, true, true, false, "00000000000 00", false, 13 );
registerStyle( "upc-a+5", "gnu-barcode", tr("UPC-A +5"),
true, true, true, false, "00000000000 00000", false, 16 );
registerStyle( "upc-e", "gnu-barcode", tr("UPC-E"),
true, true, true, false, "000000", false, 6 );
registerStyle( "upc-e+2", "gnu-barcode", tr("UPC-E +2"),
true, true, true, false, "000000 00", false, 8 );
registerStyle( "upc-e+5", "gnu-barcode", tr("UPC-E +5"),
true, true, true, false, "000000 00000", false, 11 );
registerStyle( "isbn", "gnu-barcode", tr("ISBN"),
true, true, true, true, "0-00000-000-0", false, 10 );
registerStyle( "isbn+5", "gnu-barcode", tr("ISBN +5"),
true, true, true, true, "0-00000-000-0 00000", false, 15 );
registerStyle( "code39", "gnu-barcode", tr("Code 39"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "code128", "gnu-barcode", tr("Code 128"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "code128c", "gnu-barcode", tr("Code 128C"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "code128b", "gnu-barcode", tr("Code 128B"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "i25", "gnu-barcode", tr("Interleaved 2 of 5"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "cbr", "gnu-barcode", tr("Codabar"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "msi", "gnu-barcode", tr("MSI"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "pls", "gnu-barcode", tr("Plessey"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "code93", "gnu-barcode", tr("Code 93"),
true, true, true, false, "0000000000", true, 10 );
#endif // HAVE_GNU_BARCODE
#if HAVE_QRENCODE
//
// Libqrencode backend
//
registerBackend( "qrencode", "QREncode" );
glbarcode::Factory::registerType( "qrencode::qrcode", QrEncode::QrCode::create );
registerStyle( "qrcode", "qrencode", tr("IEC18004 (QRCode)"),
false, false, true, false, "1234567890AB", false, 12 );
#endif // HAVE_QRENCODE
#if HAVE_ZINT
//
// Zint barcode backend
//
registerBackend( "zint", "Zint" );
glbarcode::Factory::registerType( "zint::ausp", Zint::AusP::create );
glbarcode::Factory::registerType( "zint::ausrp", Zint::AusRP::create );
glbarcode::Factory::registerType( "zint::ausrt", Zint::AusRT::create );
glbarcode::Factory::registerType( "zint::ausrd", Zint::AusRD::create );
glbarcode::Factory::registerType( "zint::aztec", Zint::Aztec::create );
glbarcode::Factory::registerType( "zint::azrun", Zint::Azrun::create );
glbarcode::Factory::registerType( "zint::cbr", Zint::Cbr::create );
glbarcode::Factory::registerType( "zint::code1", Zint::Code1::create );
glbarcode::Factory::registerType( "zint::code11", Zint::Code11::create );
glbarcode::Factory::registerType( "zint::c16k", Zint::C16k::create );
glbarcode::Factory::registerType( "zint::c25m", Zint::C25m::create );
glbarcode::Factory::registerType( "zint::c25i", Zint::C25i::create );
glbarcode::Factory::registerType( "zint::c25dl", Zint::C25dl::create );
glbarcode::Factory::registerType( "zint::code32", Zint::Code32::create );
glbarcode::Factory::registerType( "zint::code39", Zint::Code39::create );
glbarcode::Factory::registerType( "zint::code39e", Zint::Code39e::create );
glbarcode::Factory::registerType( "zint::code49", Zint::Code49::create );
glbarcode::Factory::registerType( "zint::code93", Zint::Code93::create );
glbarcode::Factory::registerType( "zint::code128", Zint::Code128::create );
glbarcode::Factory::registerType( "zint::code128b", Zint::Code128b::create );
glbarcode::Factory::registerType( "zint::daft", Zint::Daft::create );
glbarcode::Factory::registerType( "zint::dmtx", Zint::Dmtx::create );
glbarcode::Factory::registerType( "zint::dpl", Zint::Dpl::create );
glbarcode::Factory::registerType( "zint::dpi", Zint::Dpi::create );
glbarcode::Factory::registerType( "zint::kix", Zint::Kix::create );
glbarcode::Factory::registerType( "zint::ean", Zint::Ean::create );
glbarcode::Factory::registerType( "zint::gmtx", Zint::Gmtx::create );
glbarcode::Factory::registerType( "zint::gs1128", Zint::Gs1128::create );
glbarcode::Factory::registerType( "zint::rss14", Zint::Rss14::create );
glbarcode::Factory::registerType( "zint::rssltd", Zint::Rssltd::create );
glbarcode::Factory::registerType( "zint::rssexp", Zint::Rssexp::create );
glbarcode::Factory::registerType( "zint::rsss", Zint::Rsss::create );
glbarcode::Factory::registerType( "zint::rssso", Zint::Rssso::create );
glbarcode::Factory::registerType( "zint::rssse", Zint::Rssse::create );
glbarcode::Factory::registerType( "zint::hibc128", Zint::Hibc128::create );
glbarcode::Factory::registerType( "zint::hibc39", Zint::Hibc39::create );
glbarcode::Factory::registerType( "zint::hibcdm", Zint::Hibcdm::create );
glbarcode::Factory::registerType( "zint::hibcqr", Zint::Hibcqr::create );
glbarcode::Factory::registerType( "zint::hibcpdf", Zint::Hibcpdf::create );
glbarcode::Factory::registerType( "zint::hibcmpdf", Zint::Hibcmpdf::create );
glbarcode::Factory::registerType( "zint::hibcaz", Zint::Hibcaz::create );
glbarcode::Factory::registerType( "zint::i25", Zint::I25::create );
glbarcode::Factory::registerType( "zint::isbn", Zint::Isbn::create );
glbarcode::Factory::registerType( "zint::itf14", Zint::Itf14::create );
glbarcode::Factory::registerType( "zint::japan", Zint::Japan::create );
glbarcode::Factory::registerType( "zint::korea", Zint::Korea::create );
glbarcode::Factory::registerType( "zint::logm", Zint::Logm::create );
glbarcode::Factory::registerType( "zint::maxi", Zint::Maxi::create );
glbarcode::Factory::registerType( "zint::mpdf", Zint::Mpdf::create );
glbarcode::Factory::registerType( "zint::mqr", Zint::Mqr::create );
glbarcode::Factory::registerType( "zint::msi", Zint::Msi::create );
glbarcode::Factory::registerType( "zint::nve", Zint::Nve::create );
glbarcode::Factory::registerType( "zint::pdf", Zint::Pdf::create );
glbarcode::Factory::registerType( "zint::pdft", Zint::Pdft::create );
glbarcode::Factory::registerType( "zint::plan", Zint::Plan::create );
glbarcode::Factory::registerType( "zint::postnet", Zint::Postnet::create );
glbarcode::Factory::registerType( "zint::pharma", Zint::Pharma::create );
glbarcode::Factory::registerType( "zint::pharma2", Zint::Pharma2::create );
glbarcode::Factory::registerType( "zint::pzn", Zint::Pzn::create );
glbarcode::Factory::registerType( "zint::qr", Zint::Qr::create );
glbarcode::Factory::registerType( "zint::rm4", Zint::Rm4::create );
glbarcode::Factory::registerType( "zint::tele", Zint::Tele::create );
glbarcode::Factory::registerType( "zint::telex", Zint::Telex::create );
glbarcode::Factory::registerType( "zint::upc-a", Zint::UpcA::create );
glbarcode::Factory::registerType( "zint::upc-e", Zint::UpcE::create );
glbarcode::Factory::registerType( "zint::usps", Zint::Usps::create );
glbarcode::Factory::registerType( "zint::pls", Zint::Pls::create );
registerStyle( "ausp", "zint", tr("Austraila Post Standard"),
false, false, true, false, "12345678901234567890123", true, 23 );
registerStyle( "ausrp", "zint", tr("Australia Post Reply Paid"),
false, false, true, false, "12345678", true, 8 );
registerStyle( "ausrt", "zint", tr("Australia Post Route Code"),
false, false, true, false, "12345678", true, 8 );
registerStyle( "ausrd", "zint", tr("Australia Post Redirect"),
false, false, true, false, "12345678", true, 8 );
registerStyle( "aztec", "zint", tr("Aztec Code"),
false, false, true, false, "1234567890", true, 10 );
registerStyle( "azrun", "zint", tr("Aztec Rune"),
false, false, true, false, "255", true, 3 );
registerStyle( "cbr", "zint", tr("Codabar"),
true, true, true, false, "ABCDABCDAB", true, 10 );
registerStyle( "code1", "zint", tr("Code One"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "code11", "zint", tr("Code 11"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "c16k", "zint", tr("Code 16K"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "c25m", "zint", tr("Code 2 of 5 Matrix"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "c25i", "zint", tr("Code 2 of 5 IATA"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "c25dl", "zint", tr("Code 2 of 5 Data Logic"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "code32", "zint", tr("Code 32 (Italian Pharmacode)"),
true, true, true, false, "12345678", true, 8 );
registerStyle( "code39", "zint", tr("Code 39"),
true, true, false, false, "0000000000", true, 10 );
registerStyle( "code39e", "zint", tr("Code 39 Extended"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "code49", "zint", tr("Code 49"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "code93", "zint", tr("Code 93"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "code128", "zint", tr("Code 128"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "code128b", "zint", tr("Code 128 (Mode C supression)"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "daft", "zint", tr("DAFT Code"),
false, false, false, false, "DAFTDAFTDAFTDAFT", true, 16 );
registerStyle( "dmtx", "zint", tr("Data Matrix"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "dpl", "zint", tr("Deutsche Post Leitcode"),
true, true, true, false, "1234567890123", true, 13 );
registerStyle( "dpi", "zint", tr("Deutsche Post Identcode"),
true, true, true, false, "12345678901", true, 11 );
registerStyle( "kix", "zint", tr("Dutch Post KIX Code"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "ean", "zint", tr("EAN"),
true, true, true, false, "1234567890123", false, 13 );
registerStyle( "gmtx", "zint", tr("Grid Matrix"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "gs1-128", "zint", tr("GS1-128"),
true, true, true, false, "[01]12345678901234", false, 18 );
registerStyle( "rss14", "zint", tr("GS1 DataBar-14"),
true, true, true, false, "1234567890123", true, 13 );
registerStyle( "rssltd", "zint", "GS1 DataBar-14 Limited",
true, true, true, false, "1234567890123", true, 13 );
registerStyle( "rssexp", "zint", "GS1 DataBar Extended",
true, true, true, false, "[01]12345678901234", false, 18 );
registerStyle( "rsss", "zint", tr("GS1 DataBar-14 Stacked"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "rssso", "zint", tr("GS1 DataBar-14 Stacked Omni."),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "rssse", "zint", tr("GS1 DataBar Extended Stacked"),
false, false, true, false, "[01]12345678901234", false, 18 );
registerStyle( "hibc128", "zint", tr("HIBC Code 128"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "hibc39", "zint", tr("HIBC Code 39"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "hibcdm", "zint", tr("HIBC Data Matrix"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibcqr", "zint", tr("HIBC QR Code"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibcpdf", "zint", tr("HIBC PDF417"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibcmpdf", "zint", tr("HIBC Micro PDF417"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibcaz", "zint", tr("HIBC Aztec Code"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "i25", "zint", tr("Interleaved 2 of 5"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "isbn", "zint", tr("ISBN"),
true, true, true, false, "123456789", false, 9 );
registerStyle( "itf14", "zint", tr("ITF-14"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "japan", "zint", tr("Japanese Postal"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "korea", "zint", tr("Korean Postal"),
true, true, true, false, "123456", false, 6 );
registerStyle( "logm", "zint", tr("LOGMARS"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "maxi", "zint", tr("Maxicode"),
false, false, false, false, "0000000000", true, 10 );
registerStyle( "mpdf", "zint", tr("Micro PDF417"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "mqr", "zint", tr("Micro QR Code"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "msi", "zint", tr("MSI Plessey"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "nve", "zint", tr("NVE-18"),
true, true, true, false, "12345678901234567", false, 17 );
registerStyle( "pdf", "zint", tr("PDF417"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "pdft", "zint", tr("PDF417 Truncated"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "plan", "zint", tr("PLANET"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "postnet", "zint", tr("PostNet"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "pharma", "zint", tr("Pharmacode"),
false, false, true, false, "123456", false, 6 );
registerStyle( "pharma2", "zint", tr("Pharmacode 2-track"),
false, false, true, false, "12345678", false, 8 );
registerStyle( "pzn", "zint", tr("Pharmazentral Nummer (PZN)"),
true, true, true, false, "123456", false, 6 );
registerStyle( "qr", "zint", tr("QR Code"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "rm4", "zint", tr("Royal Mail 4-State"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "tele", "zint", tr("Telepen"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "telex", "zint", tr("Telepen Numeric"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "upc-a", "zint", tr("UPC-A"),
true, true, true, false, "12345678901", false, 11 );
registerStyle( "upc-e", "zint", tr("UPC-E"),
true, true, true, false, "1234567", false, 7 );
registerStyle( "usps", "zint", tr("USPS One Code"),
false, false, true, false, "12345678901234567890", true, 20 );
registerStyle( "pls", "zint", tr("UK Plessey"),
true, true, true, false, "0000000000", true, 10 );
#endif // HAVE_ZINT
}
void Backends::init()
{
static Backends* singletonInstance = nullptr;
if ( singletonInstance == nullptr )
{
singletonInstance = new Backends();
}
}
const QStringList& Backends::backendList()
{
return mBackendIdList;
}
QString Backends::backendName( const QString& backendId )
{
return mBackendNameMap[ backendId ];
}
const QList<Style>& Backends::styleList()
{
return mStyleList;
}
const Style& Backends::defaultStyle()
{
return mStyleList[0];
}
const Style& Backends::style( const QString& backendId, const QString& StyleId )
{
foreach ( const Style& bcStyle, mStyleList )
{
if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) )
{
return bcStyle;
}
}
return defaultStyle();
}
void Backends::registerBackend( const QString& backendId, const QString& backendName )
{
mBackendIdList.append( backendId );
mBackendNameMap[ backendId ] = backendName;
}
void Backends::registerStyle( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeForm,
int preferedN )
{
Style style( id, backendId, name,
canText, textOptional,
canChecksum, checksumOptional,
defaultDigits,
canFreeForm, preferedN );
mStyleList.append( style );
}
} // namespace glabels::barcode
+95
View File
@@ -0,0 +1,95 @@
/* Backends.h
*
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef barcode_Backends_h
#define barcode_Backends_h
#include "Style.h"
#include <QList>
#include <QMap>
#include <QObject>
#include <QString>
namespace glabels::barcode
{
///
/// Backends Database
///
class Backends : public QObject
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
Backends();
public:
static void init();
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
static const QStringList& backendList();
static QString backendName( const QString& backendId );
static const QList<Style>& styleList();
static const Style& defaultStyle();
static const Style& style( const QString& backendId, const QString& StyleId );
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
static void registerBackend( const QString &backendId, const QString &backendName );
static void registerStyle( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeForm,
int preferedN );
/////////////////////////////////
// Private Members
/////////////////////////////////
static QStringList mBackendIdList;
static QMap<QString,QString> mBackendNameMap;
static QList<Style> mStyleList;
};
}
#endif // barcode_Backends_h
+66
View File
@@ -0,0 +1,66 @@
project (Barcode LANGUAGES CXX)
#=======================================
# Handle optional dependencies
#=======================================
if (${GNUBARCODE_FOUND})
add_definitions (-DHAVE_GNU_BARCODE=1)
set (OPTIONAL_GNUBARCODE GNU::BARCODE)
else ()
set (OPTIONAL_GNUBARCODE "")
endif ()
if (${LIBQRENCODE_FOUND})
add_definitions (-DHAVE_QRENCODE=1)
set (OPTIONAL_QRENCODE QRENCODE::QRENCODE)
else ()
set (OPTIONAL_QRENCODE "")
endif ()
if (${LIBZINT_FOUND})
add_definitions (-DHAVE_ZINT=1)
set (OPTIONAL_ZINT ZINT::ZINT)
else ()
set (OPTIONAL_ZINT "")
endif ()
#=======================================
# Sources
#=======================================
set (barcode_sources
Backends.cpp
Style.cpp
GnuBarcode.cpp
QrEncode.cpp
Zint.cpp
)
set (barcode_qobject_headers
Backends.h
)
qt5_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
#=====================================
# Target
#=====================================
add_library (Barcode STATIC
${barcode_sources}
${barcode_moc_sources}
)
target_compile_features (Barcode
PUBLIC cxx_std_11
)
target_include_directories (Barcode
PUBLIC ..
)
target_link_libraries (Barcode
glbarcode
Qt5::Core
${OPTIONAL_GNUBARCODE}
${OPTIONAL_ZINT}
${OPTIONAL_QRENCODE}
)
+906
View File
@@ -0,0 +1,906 @@
/* GnuBarcode.cpp
*
* Copyright (C) 2017 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_GNU_BARCODE
#include "GnuBarcode.h"
#include <QtDebug>
#include <barcode.h>
#include <cctype>
namespace
{
const double INK_BLEED = 0.1; /* Shrink bars to account for ink bleed. */
const double FONT_SCALE = 0.75; /* Shrink font slightly, otherwise too crowded. */
}
namespace glabels::barcode
{
namespace GnuBarcode
{
bool Base::isAscii( const std::string& data ) const
{
for ( unsigned int i = 0; i < data.size(); i++ )
{
if ( (data[i] & 0x80) != 0 )
{
return false;
}
}
return true;
}
bool Base::isNumericLengthValid( const std::string& data,
unsigned int nMin,
unsigned int nMax ) const
{
unsigned int n = 0;
for ( unsigned int i = 0; i < data.size(); i++ )
{
if ( isdigit(data[i]) )
{
n++;
}
}
return (n >= nMin) && (n <= nMax);
}
bool Base::isNumericLength1Valid( const std::string& data,
unsigned int nMin,
unsigned int nMax ) const
{
unsigned int n = 0;
for ( unsigned int i = 0; !isspace(data[i]) && (i < data.size()); i++ )
{
if ( isdigit(data[i]) )
{
n++;
}
else if ( !isspace(data[i]) )
{
return false;
}
}
return (n >= nMin) && (n <= nMax);
}
bool Base::isNumericLength2Valid( const std::string& data,
unsigned int nMin,
unsigned int nMax ) const
{
unsigned int i;
unsigned int n = 0;
for ( i = 0; !isspace(data[i]) && (i < data.size()); i++ )
{
/* Skip over 1st string */
}
for ( i++ /* skip space */ ; i < data.size(); i++ )
{
if ( isdigit(data[i]) )
{
n++;
}
else
{
return false;
}
}
return (n >= nMin) && (n <= nMax);
}
void Base::vectorize( const std::string& encodedData,
const std::string& displayText,
const std::string& cookedData,
double& w,
double& h )
{
/*
* First encode using GNU Barcode library.
*/
Barcode_Item* bci = Barcode_Create( (char*)cookedData.c_str() );
bci->scalef = 0;
bci->width = (int)w;
bci->height = (int)h;
bci->flags = flags;
if ( !showText() )
{
bci->flags |= BARCODE_NO_ASCII;
}
if ( !checksum() )
{
bci->flags |= BARCODE_NO_CHECKSUM;
}
Barcode_Encode( bci, flags );
if ( (bci->partial == nullptr) || (bci->textinfo == nullptr) )
{
Barcode_Delete( bci );
setIsDataValid( false );
return;
}
/*
* Now do the actual vectorization.
*
* This code is based on the postscript renderer (ps.c) from the GNU barcode library:
*
* Copyright (C) 1999 Alessaandro Rubini (rubini@gnu.org)
* Copyright (C) 1999 Prosa Srl. (prosa@prosa.it)
*/
if (bci->width > (2*bci->margin))
{
bci->width -= 2*bci->margin;
}
if (bci->height > (2*bci->margin))
{
bci->height -= 2*bci->margin;
}
/* First calculate barlen */
int barlen = bci->partial[0] - '0';
for ( int i = 1; bci->partial[i] != 0; i++ )
{
if ( isdigit(bci->partial[i]) )
{
barlen += bci->partial[i] - '0';
}
else
{
if ( (bci->partial[i] != '+') && (bci->partial[i] != '-') )
{
barlen += bci->partial[i] - 'a' + 1;
}
}
}
/* The scale factor depends on bar length */
double scalef = 1;
if ( bci->scalef == 0 )
{
if ( bci->width == 0 )
{
bci->width = barlen; /* default */
}
scalef = bci->scalef = (double)bci->width / (double)barlen;
if ( scalef < 0.5 )
{
scalef = 0.5;
}
}
/* The width defaults to "just enough" */
bci->width = (int)( barlen * scalef + 1 );
/* But it can be too small, in this case enlarge and center the area */
if ( bci->width < (int)(barlen * scalef) )
{
int wid = (int)( barlen * scalef + 1);
bci->xoff -= (wid - bci->width)/2 ;
bci->width = wid;
/* Can't extend too far on the left */
if (bci->xoff < 0)
{
bci->width += -bci->xoff;
bci->xoff = 0;
}
}
/* The height defaults to 80 points (rescaled) */
if ( bci->height == 0 )
{
bci->height = (int)( 80 * scalef );
}
/* If too small (5 + text), reduce the scale factor and center */
int i = 5 + 10 * ( ((bci->flags & BARCODE_NO_ASCII)==0) ? 1 : 0 );
if ( bci->height < (int)(i * scalef) )
{
bci->height = (int)( i * scalef );
}
/* Now traverse the code string and create a list of lines */
char mode = '-'; /* text below bars */
double x = bci->margin + (bci->partial[0] - '0') * scalef;
i = 1;
for ( int ip = 1; bci->partial[ip] != 0; ip++, i++)
{
/* special cases: '+' and '-' */
if ( bci->partial[ip] == '+' || bci->partial[ip] == '-' )
{
mode = bci->partial[ip]; /* don't count it */
i++;
continue;
}
/* j is the width of this bar/space */
int j;
if ( isdigit(bci->partial[ip]) )
{
j = bci->partial[ip] - '0';
}
else
{
j = bci->partial[ip] - 'a' + 1;
}
if ( (i % 2) != 0 )
{
/* bar */
double x0 = x;
double y0 = bci->margin;
double yr = bci->height;
if ( (bci->flags & BARCODE_NO_ASCII) == 0 )
{
/* leave space for text */
if (mode == '-')
{
/* text below bars: 10 or 5 points */
yr -= (isdigit(bci->partial[ip]) ? 10 : 5) * scalef;
}
else
{
/* '+' */
/* above bars: 10 or 0 from bottom,
and 10 from top */
y0 += 10 * scalef;
yr -= (isdigit(bci->partial[ip]) ? 20 : 10) * scalef;
}
}
addBox( x0, y0, (j * scalef) - INK_BLEED, yr );
}
x += j * scalef;
}
/* Now the text */
mode = '-'; /* reinstantiate default */
if ( (bci->flags & BARCODE_NO_ASCII) == 0 )
{
int len = strlen( bci->textinfo );
for ( int i = 0; i < len; i++ )
{
if ( bci->textinfo[i] == ' ' )
{
continue;
}
if ( (bci->textinfo[i] == '+') || (bci->textinfo[i] == '-') )
{
mode = bci->textinfo[i];
continue;
}
double f1, f2;
char c;
if ( sscanf( &bci->textinfo[i], "%lf:%lf:%c", &f1, &f2, &c) != 3 )
{
qDebug() << "Impossible data:" << QString(&bci->textinfo[i]);
continue;
}
f2 *= FONT_SCALE;
double x0 = f1*scalef + bci->margin + 0.4*f2*scalef;
double y0;
if (mode == '-')
{
y0 = bci->margin + bci->height - 8*scalef + 0.75*f2*scalef;
}
else
{
y0 = bci->margin + 0.75*f2*scalef;
}
addText( x0, y0, f2*scalef, QString(c).toStdString() );
/* skip past the substring we just read. */
while ( (bci->textinfo[i] != ' ') && (bci->textinfo[i] != 0) )
{
i++;
}
}
}
/* Fill in other info */
w = bci->width + 2.0*bci->margin;
h = bci->height + 2.0*bci->margin;
/* Cleanup */
Barcode_Delete( bci );
}
//////////////////////////////////////////////////////
// EAN Barcode (Any)
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean::create()
{
return new Ean();
}
bool Ean::validate( const std::string& rawData )
{
return ( isNumericLengthValid( rawData, 7, 8 )
|| isNumericLengthValid( rawData, 12, 13 )
|| ( isNumericLength1Valid( rawData, 7, 8 ) && isNumericLength2Valid( rawData, 2, 2 ) )
|| ( isNumericLength1Valid( rawData, 7, 8 ) && isNumericLength2Valid( rawData, 5, 5 ) )
|| ( isNumericLength1Valid( rawData, 12, 13 ) && isNumericLength2Valid( rawData, 2, 2 ) )
|| ( isNumericLength1Valid( rawData, 12, 13 ) && isNumericLength2Valid( rawData, 5, 5 ) ) );
}
std::string Ean::encode( const std::string& cookedData )
{
flags = BARCODE_EAN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// EAN-8 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean8::create()
{
return new Ean8();
}
bool Ean8::validate( const std::string& rawData )
{
return isNumericLengthValid( rawData, 7, 8 );
}
std::string Ean8::encode( const std::string& cookedData )
{
flags = BARCODE_EAN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// EAN-8+2 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean8_2::create()
{
return new Ean8_2();
}
bool Ean8_2::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 7, 8 ) && isNumericLength2Valid( rawData, 2, 2 );
}
std::string Ean8_2::encode( const std::string& cookedData )
{
flags = BARCODE_EAN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// EAN-8+5 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean8_5::create()
{
return new Ean8_5();
}
bool Ean8_5::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 7, 8 ) && isNumericLength2Valid( rawData, 5, 5 );
}
std::string Ean8_5::encode( const std::string& cookedData )
{
flags = BARCODE_EAN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// EAN-13 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean13::create()
{
return new Ean13();
}
bool Ean13::validate( const std::string& rawData )
{
return isNumericLengthValid( rawData, 12, 13 );
}
std::string Ean13::encode( const std::string& cookedData )
{
flags = BARCODE_EAN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// EAN-13+2 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean13_2::create()
{
return new Ean13_2();
}
bool Ean13_2::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 12, 13 ) && isNumericLength2Valid( rawData, 2, 2 );
}
std::string Ean13_2::encode( const std::string& cookedData )
{
flags = BARCODE_EAN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// EAN-13+5 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean13_5::create()
{
return new Ean13_5();
}
bool Ean13_5::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 12, 13 ) && isNumericLength2Valid( rawData, 5, 5 );
}
std::string Ean13_5::encode( const std::string& cookedData )
{
flags = BARCODE_EAN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// UPC Barcode (Any)
//////////////////////////////////////////////////////
glbarcode::Barcode* Upc::create()
{
return new Upc();
}
bool Upc::validate( const std::string& rawData )
{
return isNumericLengthValid( rawData, 6, 8 )
|| isNumericLengthValid( rawData, 11, 12 )
|| (isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 2, 2 ))
|| (isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 5, 5 ))
|| (isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 2, 2 ))
|| (isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 5, 5 ));
}
std::string Upc::encode( const std::string& cookedData )
{
flags = BARCODE_UPC;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// UPC-A Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* UpcA::create()
{
return new UpcA();
}
bool UpcA::validate( const std::string& rawData )
{
return isNumericLengthValid( rawData, 11, 12 );
}
std::string UpcA::encode( const std::string& cookedData )
{
flags = BARCODE_UPC;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// UPC-A+2 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* UpcA_2::create()
{
return new UpcA_2();
}
bool UpcA_2::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 2, 2 );
}
std::string UpcA_2::encode( const std::string& cookedData )
{
flags = BARCODE_UPC;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// UPC-A+5 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* UpcA_5::create()
{
return new UpcA_5();
}
bool UpcA_5::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 5, 5 );
}
std::string UpcA_5::encode( const std::string& cookedData )
{
flags = BARCODE_UPC;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// UPC-E Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* UpcE::create()
{
return new UpcE();
}
bool UpcE::validate( const std::string& rawData )
{
return isNumericLengthValid( rawData, 6, 8 );
}
std::string UpcE::encode( const std::string& cookedData )
{
flags = BARCODE_UPC;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// UPC-E+2 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* UpcE_2::create()
{
return new UpcE_2();
}
bool UpcE_2::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 2, 2 );
}
std::string UpcE_2::encode( const std::string& cookedData )
{
flags = BARCODE_UPC;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// UPC-E+5 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* UpcE_5::create()
{
return new UpcE_5();
}
bool UpcE_5::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 5, 5 );
}
std::string UpcE_5::encode( const std::string& cookedData )
{
flags = BARCODE_UPC;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// ISBN Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Isbn::create()
{
return new Isbn();
}
bool Isbn::validate( const std::string& rawData )
{
return isNumericLengthValid( rawData, 9, 10 );
}
std::string Isbn::encode( const std::string& cookedData )
{
flags = BARCODE_ISBN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// ISBN+5 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Isbn_5::create()
{
return new Isbn_5();
}
bool Isbn_5::validate( const std::string& rawData )
{
return isNumericLength1Valid( rawData, 9, 10 ) && isNumericLength2Valid( rawData, 5, 5 );
}
std::string Isbn_5::encode( const std::string& cookedData )
{
flags = BARCODE_ISBN;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Code39 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Code39::create()
{
return new Code39();
}
bool Code39::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Code39::encode( const std::string& cookedData )
{
flags = BARCODE_39;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Code128 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Code128::create()
{
return new Code128();
}
bool Code128::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Code128::encode( const std::string& cookedData )
{
flags = BARCODE_128;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Code128C Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Code128C::create()
{
return new Code128C();
}
bool Code128C::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Code128C::encode( const std::string& cookedData )
{
flags = BARCODE_128C;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Code128B Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Code128B::create()
{
return new Code128B();
}
bool Code128B::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Code128B::encode( const std::string& cookedData )
{
flags = BARCODE_128B;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// I25 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* I25::create()
{
return new I25();
}
bool I25::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string I25::encode( const std::string& cookedData )
{
flags = BARCODE_I25;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// CBR Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Cbr::create()
{
return new Cbr();
}
bool Cbr::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Cbr::encode( const std::string& cookedData )
{
flags = BARCODE_CBR;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// MSI Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Msi::create()
{
return new Msi();
}
bool Msi::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Msi::encode( const std::string& cookedData )
{
flags = BARCODE_MSI;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// PLS Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Pls::create()
{
return new Pls();
}
bool Pls::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Pls::encode( const std::string& cookedData )
{
flags = BARCODE_PLS;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Code93 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Code93::create()
{
return new Code93();
}
bool Code93::validate( const std::string& rawData )
{
return isAscii( rawData );
}
std::string Code93::encode( const std::string& cookedData )
{
flags = BARCODE_93;
return ""; // Actual encoding is done in vectorize
}
}
}
#endif // HAVE_GNU_BARCODE
+421
View File
@@ -0,0 +1,421 @@
/* GnuBarcode.h
*
* Copyright (C) 2017 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef barcode_GnuBarcode_h
#define barcode_GnuBarcode_h
#if HAVE_GNU_BARCODE
#include "glbarcode/Barcode1dBase.h"
namespace glabels::barcode
{
namespace GnuBarcode
{
/**
* GnuBarcode::Base base class for all GNU Barcodes
*
* Implements glbarcode::Barcode1dBase.
*/
class Base : public glbarcode::Barcode1dBase
{
protected:
int flags;
bool isAscii( const std::string& data ) const;
bool isNumericLengthValid( const std::string& data,
unsigned int nMin,
unsigned int nMax ) const;
bool isNumericLength1Valid( const std::string& data,
unsigned int nMin,
unsigned int nMax ) const;
bool isNumericLength2Valid( const std::string& data,
unsigned int nMin,
unsigned int nMax ) const;
void vectorize( const std::string& encodedData,
const std::string& displayText,
const std::string& cookedData,
double& w,
double& h ) override;
};
/**
* EAN Barcode (Any)
*/
class Ean : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* EAN-8 Barcode
*/
class Ean8 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* EAN-8+2 Barcode
*/
class Ean8_2 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* EAN-8+5 Barcode
*/
class Ean8_5 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* EAN-13 Barcode
*/
class Ean13 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* EAN-13+2 Barcode
*/
class Ean13_2 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* EAN-13+5 Barcode
*/
class Ean13_5 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* UPC Barcode (Any)
*/
class Upc : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* UPC-A Barcode
*/
class UpcA : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* UPC-A+2 Barcode
*/
class UpcA_2 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* UPC-A+5 Barcode
*/
class UpcA_5 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* UPC-E Barcode
*/
class UpcE : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* UPC-E+2 Barcode
*/
class UpcE_2 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* UPC-E+5 Barcode
*/
class UpcE_5 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* ISBN Barcode
*/
class Isbn : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* ISBN+5 Barcode
*/
class Isbn_5 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* Code39 Barcode
*/
class Code39 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* Code128 Barcode
*/
class Code128 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* Code128C Barcode
*/
class Code128C : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* Code128B Barcode
*/
class Code128B : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* I25 Barcode
*/
class I25 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* CBR Barcode
*/
class Cbr : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* MSI Barcode
*/
class Msi : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* PLS Barcode
*/
class Pls : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
/**
* Code93 Barcode
*/
class Code93 : public Base
{
public:
static Barcode* create();
protected:
bool validate( const std::string& rawData ) override;
std::string encode( const std::string& cookedData ) override;
};
}
}
#endif // HAVE_GNU_BARCODE
#endif // barcode_GnuBarcode_h
+89
View File
@@ -0,0 +1,89 @@
/* QrEncode.cpp
*
* Copyright (C) 2017 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_QRENCODE
#include "QrEncode.h"
#include <qrencode.h>
namespace glabels::barcode
{
namespace QrEncode
{
/*
* Static QrCode barcode creation method
*/
glbarcode::Barcode* QrCode::create()
{
return new QrCode();
}
/*
* QrCode data validation, implements glbarcode::Barcode2dBase::validate()
*/
bool QrCode::validate( const std::string& rawData )
{
if ( rawData.size() == 0 )
{
return false;
}
return true;
}
/*
* QrCode data encoding, implements glbarcode::Barcode2dBase::encode()
*/
bool QrCode::encode( const std::string& cookedData, glbarcode::Matrix<bool>& encodedData )
{
QRcode *qrcode = QRcode_encodeString( cookedData.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1 );
if ( qrcode == NULL )
{
return false;
}
int w = qrcode->width;
encodedData.resize( w, w );
for ( int iy = 0; iy < w; iy++ )
{
for ( int ix = 0; ix < w; ix++ )
{
encodedData[iy][ix] = qrcode->data[ iy*w + ix ] & 0x01;
}
}
QRcode_free( qrcode );
QRcode_clearCache();
return true;
}
}
}
#endif // HAVE_QRENCODE
+57
View File
@@ -0,0 +1,57 @@
/* QrEncode.h
*
* Copyright (C) 2017 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef barcode_QrEncode_h
#define barcode_QrEncode_h
#if HAVE_QRENCODE
#include "glbarcode/Barcode2dBase.h"
namespace glabels::barcode
{
namespace QrEncode
{
/**
* QrEncode::QrCode QR Code Barcode
*
* Implements glbarcode::Barcode2dBase.
*/
class QrCode : public glbarcode::Barcode2dBase
{
public:
static Barcode* create();
private:
bool validate( const std::string& rawData ) override;
bool encode( const std::string& cookedData,
glbarcode::Matrix<bool>& encodedData ) override;
};
}
}
#endif // HAVE_QRENCODE
#endif // barcode_QrEncode_h
+204
View File
@@ -0,0 +1,204 @@
/* Style.cpp
*
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Style.h"
namespace glabels::barcode
{
///
/// Default Constructor
///
Style::Style ()
: mId( "" ),
mBackendId( "" ),
mName( "" ),
mCanText( false ),
mTextOptional( false ),
mCanChecksum( false ),
mChecksumOptional( false ),
mDefaultDigits( "" ),
mCanFreeform( false ),
mPreferedN( 0 )
{
// empty
}
///
/// Constructor From Data
///
Style::Style ( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeform,
int preferedN )
: mId( id ),
mBackendId( backendId ),
mName( name ),
mCanText( canText ),
mTextOptional( textOptional ),
mCanChecksum( canChecksum ),
mChecksumOptional( checksumOptional ),
mDefaultDigits( defaultDigits ),
mCanFreeform( canFreeform ),
mPreferedN( preferedN )
{
// empty
}
///
/// ID Property Getter
///
const QString& Style::id() const
{
return mId;
}
///
/// Full ID Property Getter
///
QString Style::fullId() const
{
if ( mBackendId == "" )
{
return mId;
}
else
{
return mBackendId + "::" + mId;
}
}
///
/// Backend ID Property Getter
///
const QString& Style::backendId() const
{
return mBackendId;
}
///
/// Name Property Getter
///
const QString& Style::name() const
{
return mName;
}
///
/// Can Text Property Getter
///
bool Style::canText() const
{
return mCanText;
}
///
/// Text Optional Property Getter
///
bool Style::textOptional() const
{
return mTextOptional;
}
///
/// Can Checksum Property Getter
///
bool Style::canChecksum() const
{
return mCanChecksum;
}
///
/// Checksum Optional Property Getter
///
bool Style::checksumOptional() const
{
return mChecksumOptional;
}
///
/// Default Digits Property Getter
///
const QString& Style::defaultDigits() const
{
return mDefaultDigits;
}
///
/// Can Freeform Property Getter
///
bool Style::canFreeform() const
{
return mCanFreeform;
}
///
/// Prefered N Property Getter
///
int Style::preferedN() const
{
return mPreferedN;
}
///
/// Generate Example Digits
///
QString Style::exampleDigits( int n ) const
{
if ( mCanFreeform )
{
return QString( qMax( n, 1 ), QChar('0') );
}
else
{
return mDefaultDigits;
}
}
///
/// "Not equals" operator
///
bool Style::operator!=( const Style& other ) const
{
return mId != other.mId;
}
} // namespace glabels::barcode
+115
View File
@@ -0,0 +1,115 @@
/* Style.h
*
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef barcode_Style_h
#define barcode_Style_h
#include <QString>
namespace glabels::barcode
{
///
/// Style Type
///
class Style
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
Style ();
Style ( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeform,
int preferedN );
/////////////////////////////////
// Properties
/////////////////////////////////
const QString& id() const;
QString fullId() const;
const QString& backendId() const;
const QString& name() const;
bool canText() const;
bool textOptional() const;
bool canChecksum() const;
bool checksumOptional() const;
const QString& defaultDigits() const;
bool canFreeform() const;
int preferedN() const;
/////////////////////////////////
// Methods
/////////////////////////////////
public:
QString exampleDigits( int n ) const;
/////////////////////////////////
// Operators
/////////////////////////////////
public:
bool operator!=( const Style& other ) const;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
QString mId;
QString mBackendId;
QString mName;
bool mCanText;
bool mTextOptional;
bool mCanChecksum;
bool mChecksumOptional;
QString mDefaultDigits;
bool mCanFreeform;
int mPreferedN;
};
}
#endif // barcode_Style_h
File diff suppressed because it is too large Load Diff
+932
View File
@@ -0,0 +1,932 @@
/* Zint.h
*
* Copyright (C) 2017 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef barcode_Zint_h
#define barcode_Zint_h
#if HAVE_ZINT
#include "glbarcode/Barcode1dBase.h"
namespace glabels::barcode
{
namespace Zint
{
/**
* Zint::Base base class for all Zint barcodes
*
* Implements glbarcode::Barcode1dBase.
*/
class Base : public glbarcode::Barcode1dBase
{
protected:
int symbology;
bool validate( const std::string& rawData ) override;
void vectorize( const std::string& encodedData,
const std::string& displayText,
const std::string& cookedData,
double& w,
double& h ) override;
};
/**
* AusP Barcode
*/
class AusP : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* AusRP Barcode
*/
class AusRP : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* AusRT Barcode
*/
class AusRT : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* AusRD Barcode
*/
class AusRD : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Aztec Barcode
*/
class Aztec : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Azrun Barcode
*/
class Azrun : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Cbr Barcode
*/
class Cbr : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code1 Barcode
*/
class Code1 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code11 Barcode
*/
class Code11 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* C16k Barcode
*/
class C16k : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* C25m Barcode
*/
class C25m : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* C25i Barcode
*/
class C25i : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* C25dl Barcode
*/
class C25dl : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code32 Barcode
*/
class Code32 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code39 Barcode
*/
class Code39 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code39e Barcode
*/
class Code39e : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code49 Barcode
*/
class Code49 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code93 Barcode
*/
class Code93 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code128 Barcode
*/
class Code128 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Code128b Barcode
*/
class Code128b : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Daft Barcode
*/
class Daft : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Dmtx Barcode
*/
class Dmtx : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Dpl Barcode
*/
class Dpl : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Dpi Barcode
*/
class Dpi : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Kix Barcode
*/
class Kix : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Ean Barcode
*/
class Ean : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Hibc128 Barcode
*/
class Hibc128 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Hibc39 Barcode
*/
class Hibc39 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Hibcdm Barcode
*/
class Hibcdm : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Hibcqr Barcode
*/
class Hibcqr : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Hibcpdf Barcode
*/
class Hibcpdf : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Hibcmpdf Barcode
*/
class Hibcmpdf : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Hibcaz Barcode
*/
class Hibcaz : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* I25 Barcode
*/
class I25 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Isbn Barcode
*/
class Isbn : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Itf14 Barcode
*/
class Itf14 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Gmtx Barcode
*/
class Gmtx : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Gs1128 Barcode
*/
class Gs1128 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Logm Barcode
*/
class Logm : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Rss14 Barcode
*/
class Rss14 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Rssltd Barcode
*/
class Rssltd : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Rssexp Barcode
*/
class Rssexp : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Rsss Barcode
*/
class Rsss : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Rssso Barcode
*/
class Rssso : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Rssse Barcode
*/
class Rssse : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Pharma Barcode
*/
class Pharma : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Pharma2 Barcode
*/
class Pharma2 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Pzn Barcode
*/
class Pzn : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Tele Barcode
*/
class Tele : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Telex Barcode
*/
class Telex : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Japan Barcode
*/
class Japan : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Korea Barcode
*/
class Korea : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Maxi Barcode
*/
class Maxi : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Mpdf Barcode
*/
class Mpdf : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Msi Barcode
*/
class Msi : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Mqr Barcode
*/
class Mqr : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Nve Barcode
*/
class Nve : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Plan Barcode
*/
class Plan : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Postnet Barcode
*/
class Postnet : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Pdf Barcode
*/
class Pdf : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Pdft Barcode
*/
class Pdft : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Qr Barcode
*/
class Qr : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Rm4 Barcode
*/
class Rm4 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* UpcA Barcode
*/
class UpcA : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* UpcE Barcode
*/
class UpcE : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Usps Barcode
*/
class Usps : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Pls Barcode
*/
class Pls : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
}
}
#endif // HAVE_ZINT
#endif // barcode_Zint_h
+46
View File
@@ -0,0 +1,46 @@
project (Merge LANGUAGES CXX)
#=====================================
# Sources
#=====================================
set (merge_sources
Factory.cpp
Record.cpp
Merge.cpp
None.cpp
Text.cpp
TextCsv.cpp
TextCsvKeys.cpp
TextTsv.cpp
TextTsvKeys.cpp
TextColon.cpp
TextColonKeys.cpp
TextSemicolon.cpp
TextSemicolonKeys.cpp
)
set (merge_qobject_headers
Merge.h
)
qt5_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
#=====================================
# Target
#=====================================
add_library (Merge STATIC
${merge_sources}
${merge_moc_sources}
)
target_compile_features (Merge
PUBLIC cxx_std_11
)
target_include_directories (Merge
PUBLIC ..
)
target_link_libraries (Merge
Qt5::Core
)
+219
View File
@@ -0,0 +1,219 @@
/* Merge/Factory.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Factory.h"
#include "None.h"
#include "TextCsv.h"
#include "TextCsvKeys.h"
#include "TextTsv.h"
#include "TextTsvKeys.h"
#include "TextColon.h"
#include "TextColonKeys.h"
#include "TextSemicolon.h"
#include "TextSemicolonKeys.h"
namespace glabels::merge
{
//
// Static data
//
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
QStringList Factory::mNameList;
///
/// Constructor
///
Factory::Factory()
{
registerBackend( None::id(),
tr("None"),
NONE,
&None::create );
registerBackend( TextCsv::id(),
tr("Text: Comma Separated Values (CSV)"),
FILE,
&TextCsv::create );
registerBackend( TextCsvKeys::id(),
tr("Text: Comma Separated Values (CSV), keys on line 1"),
FILE,
&TextCsvKeys::create );
registerBackend( TextTsv::id(),
tr("Text: Tab Separated Values (TSV)"),
FILE,
&TextTsv::create );
registerBackend( TextTsvKeys::id(),
tr("Text: Tab Separated Values (TSV), keys on line 1"),
FILE,
&TextTsvKeys::create );
registerBackend( TextColon::id(),
tr("Text: Colon Separated Values"),
FILE,
&TextColon::create );
registerBackend( TextColonKeys::id(),
tr("Text: Colon Separated Values, keys on line 1"),
FILE,
&TextColonKeys::create );
registerBackend( TextSemicolon::id(),
tr("Text: Semicolon Separated Values"),
FILE,
&TextSemicolon::create );
registerBackend( TextSemicolonKeys::id(),
tr("Text: Semicolon Separated Values, keys on line 1"),
FILE,
&TextSemicolonKeys::create );
}
///
/// Initialize
///
void Factory::init()
{
static Factory* singletonInstance = nullptr;
if ( !singletonInstance )
{
singletonInstance = new Factory();
}
}
///
/// Create Merge object
///
Merge* Factory::createMerge( const QString& id )
{
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
if ( iBackend != mBackendIdMap.end() )
{
return iBackend->create();
}
return None::create();
}
///
/// Get name list
///
QStringList Factory::nameList()
{
return mNameList;
}
///
/// Convert ID to name
///
QString Factory::idToName( const QString& id )
{
if ( mBackendIdMap.contains( id ) )
{
return mBackendIdMap[id].name;
}
else
{
return tr("None");
}
}
///
/// Convert name to ID
///
QString Factory::nameToId( const QString& name )
{
if ( mBackendNameMap.contains( name ) )
{
return mBackendNameMap[name].id;
}
else
{
return "None";
}
}
///
/// Convert ID to type
///
Factory::SourceType Factory::idToType( const QString& id )
{
if ( mBackendIdMap.contains( id ) )
{
return mBackendIdMap[id].type;
}
else
{
return NONE;
}
}
///
/// Lookup ID from index
///
QString Factory::indexToId( int index )
{
if ( (index > 0) && (index < mNameList.size()) )
{
QString name = mNameList[index];
return mBackendNameMap[ name ].id;
}
return "None";
}
///
/// Register backend
///
void Factory::registerBackend( const QString& id,
const QString& name,
SourceType type,
CreateFct create )
{
BackendEntry backend;
backend.id = id;
backend.name = name;
backend.type = type;
backend.create = create;
mBackendIdMap[ id ] = backend;
mBackendNameMap[ name ] = backend;
mNameList << name;
}
} // namespace glabels::merge
+107
View File
@@ -0,0 +1,107 @@
/* Merge/Factory.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Factory_h
#define merge_Factory_h
#include <QCoreApplication>
#include <QStringList>
#include <QMap>
namespace glabels::merge
{
// Forward references
class Merge;
///
/// Factory
///
class Factory
{
Q_DECLARE_TR_FUNCTIONS(Factory)
/////////////////////////////////
// Source Type
/////////////////////////////////
public:
enum SourceType { NONE, FIXED, FILE };
/////////////////////////////////
// Life Cycle
/////////////////////////////////
protected:
Factory();
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static void init();
static Merge* createMerge( const QString& id );
static QStringList nameList();
static QString idToName( const QString& id );
static QString nameToId( const QString& name );
static SourceType idToType( const QString& id );
static QString indexToId( int index );
/////////////////////////////////
// private methods
/////////////////////////////////
private:
typedef Merge* (*CreateFct)();
static void registerBackend( const QString& id,
const QString& name,
SourceType type,
CreateFct create );
/////////////////////////////////
// private data
/////////////////////////////////
class BackendEntry
{
public:
QString id;
QString name;
SourceType type;
CreateFct create;
};
static QMap<QString,BackendEntry> mBackendIdMap;
static QMap<QString,BackendEntry> mBackendNameMap;
static QStringList mNameList;
};
}
#endif // merge_Factory_h
+210
View File
@@ -0,0 +1,210 @@
/* Merge/Merge.cpp
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Merge.h"
#include "Record.h"
namespace glabels::merge
{
///
/// Constructor
///
Merge::Merge()
{
}
///
/// Constructor
///
Merge::Merge( const Merge* merge ) : mSource(merge->mSource)
{
foreach ( Record* record, merge->mRecordList )
{
mRecordList << record->clone();
}
}
///
/// Destructor
///
Merge::~Merge()
{
foreach ( Record* record, mRecordList )
{
delete record;
}
mRecordList.clear();
}
///
/// Get id
///
QString Merge::id() const
{
return mId;
}
///
/// Get source
///
QString Merge::source() const
{
return mSource;
}
///
/// Set source
///
void Merge::setSource( const QString& source )
{
mSource = source;
// Clear out any old records
foreach ( Record* record, mRecordList )
{
delete record;
}
mRecordList.clear();
open();
for ( Record* record = readNextRecord(); record != nullptr; record = readNextRecord() )
{
mRecordList.append( record );
}
close();
emit sourceChanged();
}
///
/// Get record list
///
const QList<Record*>& Merge::recordList( ) const
{
return mRecordList;
}
///
/// Select matching record
///
void Merge::select( Record* record )
{
record->setSelected( true );
emit selectionChanged();
}
///
/// Unselect matching record
///
void Merge::unselect( Record* record )
{
record->setSelected( false );
emit selectionChanged();
}
///
/// Select/unselect i'th record
///
void Merge::setSelected( int i, bool state )
{
if ( (i >= 0) && (i < mRecordList.size()) )
{
mRecordList[i]->setSelected( state );
emit selectionChanged();
}
}
///
/// Select all records
///
void Merge::selectAll()
{
foreach ( Record* record, mRecordList )
{
record->setSelected( true );
}
emit selectionChanged();
}
///
/// Unselect all records
///
void Merge::unselectAll()
{
foreach ( Record* record, mRecordList )
{
record->setSelected( false );
}
emit selectionChanged();
}
///
/// Return count of selected records
///
int Merge::nSelectedRecords() const
{
int count = 0;
foreach ( Record* record, mRecordList )
{
if ( record->isSelected() )
{
count++;
}
}
return count;
}
///
/// Return list of selected records
///
const QList<Record*> Merge::selectedRecords() const
{
QList<Record*> list;
foreach ( Record* record, mRecordList )
{
if ( record->isSelected() )
{
list.append( record );
}
}
return list;
}
} // namespace glabels::merge
+120
View File
@@ -0,0 +1,120 @@
/* Merge/Merge.h
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Merge_h
#define merge_Merge_h
#include <QObject>
#include <QString>
#include <QStringList>
#include <QList>
namespace glabels::merge
{
// Forward references
class Record;
///
/// Merge Object
///
struct Merge : QObject
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
protected:
Merge();
Merge( const Merge* merge );
public:
~Merge() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
virtual Merge* clone() const = 0;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
QString id() const;
QString source() const;
void setSource( const QString& source );
const QList<Record*>& recordList( void ) const;
/////////////////////////////////
// Selection methods
/////////////////////////////////
public:
void select( Record* record );
void unselect( Record* record );
void setSelected( int i, bool state = true );
void selectAll();
void unselectAll();
int nSelectedRecords() const;
const QList<Record*> selectedRecords() const;
/////////////////////////////////
// Virtual methods
/////////////////////////////////
public:
virtual QStringList keys() const = 0;
virtual QString primaryKey() const = 0;
protected:
virtual void open() = 0;
virtual void close() = 0;
virtual Record* readNextRecord() = 0;
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void sourceChanged();
void selectionChanged();
/////////////////////////////////
// Private data
/////////////////////////////////
protected:
QString mId;
private:
QString mSource;
QList<Record*> mRecordList;
};
}
#endif // merge_Merge_h
+122
View File
@@ -0,0 +1,122 @@
/* Merge/None.cpp
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "None.h"
namespace glabels::merge
{
///
/// Constructor
///
None::None() : Merge()
{
mId = "None";
}
///
/// Constructor
///
None::None( const None* merge ) : Merge( merge )
{
}
///
/// Destructor
///
None::~None()
{
}
///
/// Clone
///
None* None::clone() const
{
return new None( this );
}
///
/// Get ID
///
QString None::id()
{
return "None";
}
///
/// Create
///
Merge* None::create()
{
return new None();
}
///
/// Get key list
///
QStringList None::keys() const
{
QStringList emptyList;
return emptyList;
}
///
/// Get primary key
///
QString None::primaryKey() const
{
return "";
}
///
/// Open source
///
void None::open()
{
}
///
/// Close source
///
void None::close()
{
}
///
/// Read next record
///
Record* None::readNextRecord()
{
return nullptr;
}
} // namespace glabels::merge
+75
View File
@@ -0,0 +1,75 @@
/* Merge/None.h
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_None_h
#define merge_None_h
#include "Merge.h"
namespace glabels::merge
{
///
/// None Merge Backend
///
struct None : public Merge
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
None();
None( const None* merge );
~None() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
None* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
/////////////////////////////////
// Implementation of virtual methods
/////////////////////////////////
public:
QStringList keys() const override;
QString primaryKey() const override;
protected:
void open() override;
void close() override;
Record* readNextRecord() override;
};
}
#endif // merge_None_h
+70
View File
@@ -0,0 +1,70 @@
/* Merge/Record.cpp
*
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Record.h"
namespace glabels::merge
{
///
/// Constructor
///
Record::Record() : mSelected( true )
{
}
///
/// Constructor
///
Record::Record( const Record* record )
: QMap<QString,QString>(*record), mSelected(record->mSelected)
{
}
///
/// Clone
///
Record* Record::clone() const
{
return new Record( this );
}
///
/// Is record selected?
///
bool Record::isSelected() const
{
return mSelected;
}
///
/// Set selected on not selected
///
void Record::setSelected( bool value )
{
mSelected = value;
}
} // namespace glabels::merge
+71
View File
@@ -0,0 +1,71 @@
/* Merge/Record.h
*
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Record_h
#define merge_Record_h
#include <QString>
#include <QMap>
namespace glabels::merge
{
///
/// Merge Record
///
struct Record : public QMap<QString,QString>
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
Record();
Record( const Record* record );
/////////////////////////////////
// Object duplication
/////////////////////////////////
Record* clone() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
bool isSelected() const;
void setSelected( bool value );
/////////////////////////////////
// Private data
/////////////////////////////////
private:
bool mSelected;
};
}
#endif // merge_Record_h
+416
View File
@@ -0,0 +1,416 @@
/* Merge/Text.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Text.h"
#include "Record.h"
#include <QtDebug>
namespace glabels::merge
{
///
/// Constructor
///
Text::Text( QChar delimiter, bool line1HasKeys )
: mDelimeter(delimiter), mLine1HasKeys(line1HasKeys), mNFieldsMax(0)
{
}
///
/// Constructor
///
Text::Text( const Text* merge )
: Merge( merge ),
mDelimeter(merge->mDelimeter), mLine1HasKeys(merge->mLine1HasKeys),
mNFieldsMax(merge->mNFieldsMax)
{
}
///
/// Destructor
///
Text::~Text()
{
}
///
/// Get key list
///
QStringList Text::keys() const
{
QStringList keys;
for ( int iField = 0; iField < mNFieldsMax; iField++ )
{
keys << keyFromIndex(iField);
}
return keys;
}
///
/// Get primary key
///
QString Text::primaryKey() const
{
return keyFromIndex(0);
}
///
/// Open source
///
void Text::open()
{
mFile.setFileName( source() );
mFile.open( QIODevice::ReadOnly|QIODevice::Text );
mKeys.clear();
mNFieldsMax = 0;
if ( mLine1HasKeys && mFile.isOpen() )
{
mKeys = parseLine();
if ( (mKeys.size() == 1) && (mKeys[0] == "") )
{
mKeys.clear();
}
else
{
mNFieldsMax = mKeys.size();
}
}
}
///
/// Close source
///
void Text::close()
{
if ( mFile.isOpen() )
{
mFile.close();
}
}
///
/// Read next record
///
Record* Text::readNextRecord()
{
QStringList values = parseLine();
if ( !values.isEmpty() )
{
Record* record = new Record();
int iField = 0;
foreach ( QString value, values )
{
(*record)[ keyFromIndex(iField) ] = value;
iField++;
}
mNFieldsMax = std::max( mNFieldsMax, iField );
return record;
}
return nullptr;
}
///
/// Key from field index
///
QString Text::keyFromIndex( int iField ) const
{
if ( mLine1HasKeys && ( iField < mKeys.size() ) )
{
return mKeys[iField];
}
else
{
return QString::number( iField+1 );
}
}
///
/// Parse line.
///
/// Attempt to be a robust parser of various CSV (and similar) formats.
///
/// Based on CSV format described in RFC 4180 section 2.
///
/// Additions to RFC 4180 rules:
/// - delimeters and other special characters may be "escaped" by a leading
/// backslash (\)
/// - C escape sequences for newline (\n) and tab (\t) are also translated.
/// - if quoted text is not followed by a delimeter, any additional text is
/// concatenated with quoted portion.
///
/// Returns a list of fields. A blank line is considered a line with one
/// empty field. Returns an empty list when done.
///
QStringList Text::parseLine()
{
QStringList fields;
enum State
{
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
} state = DELIM;
QByteArray field;
while ( state != DONE )
{
char c;
if ( mFile.getChar( &c ) )
{
switch (state)
{
case DELIM:
switch (c)
{
case '\n':
/* last field is empty. */
fields << "";
state = DONE;
break;
case '\r':
/* ignore */
state = DELIM;
break;
case '"':
/* start a quoted field. */
state = QUOTED;
break;
case '\\':
/* simple field, but 1st character is an escape. */
state = SIMPLE_ESCAPED;
break;
default:
if ( c == mDelimeter )
{
/* field is empty. */
fields << "";
state = DELIM;
}
else
{
/* begining of a simple field. */
field.append( c );
state = SIMPLE;
}
break;
}
break;
case QUOTED:
switch (c)
{
case '"':
/* Possible end of field, but could be 1st of a pair. */
state = QUOTED_QUOTE1;
break;
case '\\':
/* Escape next character, or special escape, e.g. \n. */
state = QUOTED_ESCAPED;
break;
default:
/* Use character literally. */
field.append( c );
break;
}
break;
case QUOTED_QUOTE1:
switch (c)
{
case '\n':
/* line ended after quoted item */
fields << QString( field );
state = DONE;
break;
case '"':
/* second quote, insert and stay quoted. */
field.append( c );
state = QUOTED;
break;
case '\r':
/* ignore and go to fallback */
state = SIMPLE;
break;
default:
if ( c == mDelimeter )
{
/* end of field. */
fields << QString( field );
field.clear();
state = DELIM;
}
else
{
/* fallback if not a delim or another quote. */
field.append( c );
state = SIMPLE;
}
break;
}
break;
case QUOTED_ESCAPED:
switch (c)
{
case 'n':
/* Decode "\n" as newline. */
field.append( '\n' );
state = QUOTED;
break;
case 't':
/* Decode "\t" as tab. */
field.append( '\t' );
state = QUOTED;
break;
default:
/* Use character literally. */
field.append( c );
state = QUOTED;
break;
}
break;
case SIMPLE:
switch (c)
{
case '\n':
/* line ended */
fields << QString( field );
state = DONE;
break;
case '\r':
/* ignore */
state = SIMPLE;
break;
case '\\':
/* Escape next character, or special escape, e.g. \n. */
state = SIMPLE_ESCAPED;
break;
default:
if ( c == mDelimeter )
{
/* end of field. */
fields << QString( field );
field.clear();
state = DELIM;
}
else
{
/* Use character literally. */
field.append( c );
state = SIMPLE;
}
break;
}
break;
case SIMPLE_ESCAPED:
switch (c)
{
case 'n':
/* Decode "\n" as newline. */
field.append( '\n' );
state = SIMPLE;
break;
case 't':
/* Decode "\t" as tab. */
field.append( '\t' );
state = SIMPLE;
break;
default:
/* Use character literally. */
field.append( (char)c );
state = SIMPLE;
break;
}
break;
default:
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
break;
}
}
else
{
/* Handle EOF (could also be an error while reading). */
switch (state)
{
case DELIM:
/* EOF, no more lines. */
break;
case QUOTED:
/* File ended midway through quoted item. Truncate field. */
fields << QString( field );
break;
case QUOTED_QUOTE1:
/* File ended after quoted item. */
fields << QString( field );
break;
case QUOTED_ESCAPED:
/* File ended midway through quoted item. Truncate field. */
fields << QString( field );
break;
case SIMPLE:
/* File ended after simple item. */
fields << QString( field );
break;
case SIMPLE_ESCAPED:
/* File ended midway through escaped item. */
fields << QString( field );
break;
default:
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
break;
}
state = DONE;
}
}
return fields;
}
} // namespace glabels::merge
+81
View File
@@ -0,0 +1,81 @@
/* Merge/Text.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Text_h
#define merge_Text_h
#include "Merge.h"
#include <QFile>
namespace glabels::merge
{
///
/// Text Merge Backend
///
struct Text : public Merge
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
protected:
Text( QChar delimiter, bool line1HasKeys );
Text( const Text* merge );
~Text() override;
/////////////////////////////////
// Implementation of virtual methods
/////////////////////////////////
public:
QStringList keys() const override;
QString primaryKey() const override;
protected:
void open() override;
void close() override;
Record* readNextRecord() override;
/////////////////////////////////
// Private methods
/////////////////////////////////
QString keyFromIndex( int iField ) const;
QStringList parseLine();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
QChar mDelimeter;
bool mLine1HasKeys;
QFile mFile;
QStringList mKeys;
int mNFieldsMax;
};
}
#endif // merge_Text_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextColon.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextColon.h"
namespace glabels::merge
{
static const QString ID = "Text/Colon";
///
/// Constructor
///
TextColon::TextColon() : Text(':',false)
{
mId = ID;
}
///
/// Constructor
///
TextColon::TextColon( const TextColon* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextColon::~TextColon()
{
}
///
/// Clone
///
TextColon* TextColon::clone() const
{
return new TextColon( this );
}
///
/// Get ID
///
QString TextColon::id()
{
return ID;
}
///
/// Create
///
Merge* TextColon::create()
{
return new TextColon();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextColon.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextColon_h
#define merge_TextColon_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextColon Merge Backend
///
struct TextColon : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextColon();
TextColon( const TextColon* merge );
~TextColon() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextColon* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextColon_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextColonKeys.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextColonKeys.h"
namespace glabels::merge
{
static const QString ID = "Text/Colon/Line1Keys";
///
/// Constructor
///
TextColonKeys::TextColonKeys() : Text(':',true)
{
mId = ID;
}
///
/// Constructor
///
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextColonKeys::~TextColonKeys()
{
}
///
/// Clone
///
TextColonKeys* TextColonKeys::clone() const
{
return new TextColonKeys( this );
}
///
/// Get ID
///
QString TextColonKeys::id()
{
return ID;
}
///
/// Create
///
Merge* TextColonKeys::create()
{
return new TextColonKeys();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextColonKeys.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextColonKeys_h
#define merge_TextColonKeys_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextColonKeys Merge Backend
///
struct TextColonKeys : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextColonKeys();
TextColonKeys( const TextColonKeys* merge );
~TextColonKeys() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextColonKeys* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextColonKeys_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextCsv.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextCsv.h"
namespace glabels::merge
{
static const QString ID = "Text/Comma";
///
/// Constructor
///
TextCsv::TextCsv() : Text(',',false)
{
mId = ID;
}
///
/// Constructor
///
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextCsv::~TextCsv()
{
}
///
/// Clone
///
TextCsv* TextCsv::clone() const
{
return new TextCsv( this );
}
///
/// Get ID
///
QString TextCsv::id()
{
return ID;
}
///
/// Create
///
Merge* TextCsv::create()
{
return new TextCsv();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextCsv.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextCsv_h
#define merge_TextCsv_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextCsv Merge Backend
///
struct TextCsv : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextCsv();
TextCsv( const TextCsv* merge );
~TextCsv() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextCsv* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextCsv_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextCsvKeys.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextCsvKeys.h"
namespace glabels::merge
{
static const QString ID = "Text/Comma/Line1Keys";
///
/// Constructor
///
TextCsvKeys::TextCsvKeys() : Text(',',true)
{
mId = ID;
}
///
/// Constructor
///
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextCsvKeys::~TextCsvKeys()
{
}
///
/// Clone
///
TextCsvKeys* TextCsvKeys::clone() const
{
return new TextCsvKeys( this );
}
///
/// Get ID
///
QString TextCsvKeys::id()
{
return ID;
}
///
/// Create
///
Merge* TextCsvKeys::create()
{
return new TextCsvKeys();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextCsvKeys.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextCsvKeys_h
#define merge_TextCsvKeys_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextCsvKeys Merge Backend
///
struct TextCsvKeys : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextCsvKeys();
TextCsvKeys( const TextCsvKeys* merge );
~TextCsvKeys() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextCsvKeys* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextCsvKeys_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextSemicolon.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextSemicolon.h"
namespace glabels::merge
{
static const QString ID = "Text/Semicolon";
///
/// Constructor
///
TextSemicolon::TextSemicolon() : Text(';',false)
{
mId = ID;
}
///
/// Constructor
///
TextSemicolon::TextSemicolon( const TextSemicolon* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextSemicolon::~TextSemicolon()
{
}
///
/// Clone
///
TextSemicolon* TextSemicolon::clone() const
{
return new TextSemicolon( this );
}
///
/// Get ID
///
QString TextSemicolon::id()
{
return ID;
}
///
/// Create
///
Merge* TextSemicolon::create()
{
return new TextSemicolon();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextSemicolon.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextSemicolon_h
#define merge_TextSemicolon_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextSemicolon Merge Backend
///
struct TextSemicolon : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextSemicolon();
TextSemicolon( const TextSemicolon* merge );
~TextSemicolon() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextSemicolon* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextSemicolon_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextSemicolonKeys.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextSemicolonKeys.h"
namespace glabels::merge
{
static const QString ID = "Text/Semicolon/Keys";
///
/// Constructor
///
TextSemicolonKeys::TextSemicolonKeys() : Text(';',true)
{
mId = ID;
}
///
/// Constructor
///
TextSemicolonKeys::TextSemicolonKeys( const TextSemicolonKeys* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextSemicolonKeys::~TextSemicolonKeys()
{
}
///
/// Clone
///
TextSemicolonKeys* TextSemicolonKeys::clone() const
{
return new TextSemicolonKeys( this );
}
///
/// Get ID
///
QString TextSemicolonKeys::id()
{
return ID;
}
///
/// Create
///
Merge* TextSemicolonKeys::create()
{
return new TextSemicolonKeys();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextSemicolonKeys.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextSemicolonKeys_h
#define merge_TextSemicolonKeys_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextSemicolonKeys Merge Backend
///
struct TextSemicolonKeys : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextSemicolonKeys();
TextSemicolonKeys( const TextSemicolonKeys* merge );
~TextSemicolonKeys() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextSemicolonKeys* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextSemicolonKeys_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextTsv.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextTsv.h"
namespace glabels::merge
{
static const QString ID = "Text/Tab";
///
/// Constructor
///
TextTsv::TextTsv() : Text('\t',false)
{
mId = ID;
}
///
/// Constructor
///
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextTsv::~TextTsv()
{
}
///
/// Clone
///
TextTsv* TextTsv::clone() const
{
return new TextTsv( this );
}
///
/// Get ID
///
QString TextTsv::id()
{
return ID;
}
///
/// Create
///
Merge* TextTsv::create()
{
return new TextTsv();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextTsv.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextTsv_h
#define merge_TextTsv_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextTsv Merge Backend
///
struct TextTsv : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextTsv();
TextTsv( const TextTsv* merge );
~TextTsv() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextTsv* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextTsv_h
+81
View File
@@ -0,0 +1,81 @@
/* Merge/TextTsvKeys.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TextTsvKeys.h"
namespace glabels::merge
{
static const QString ID = "Text/Tab/Line1Keys";
///
/// Constructor
///
TextTsvKeys::TextTsvKeys() : Text('\t',true)
{
mId = ID;
}
///
/// Constructor
///
TextTsvKeys::TextTsvKeys( const TextTsvKeys* merge ) : Text( merge )
{
}
///
/// Destructor
///
TextTsvKeys::~TextTsvKeys()
{
}
///
/// Clone
///
TextTsvKeys* TextTsvKeys::clone() const
{
return new TextTsvKeys( this );
}
///
/// Get ID
///
QString TextTsvKeys::id()
{
return ID;
}
///
/// Create
///
Merge* TextTsvKeys::create()
{
return new TextTsvKeys();
}
} // namespace glabels::merge
+65
View File
@@ -0,0 +1,65 @@
/* Merge/TextTsvKeys.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_TextTsvKeys_h
#define merge_TextTsvKeys_h
#include "Text.h"
namespace glabels::merge
{
///
/// TextTsvKeys Merge Backend
///
struct TextTsvKeys : public Text
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
TextTsvKeys();
TextTsvKeys( const TextTsvKeys* merge );
~TextTsvKeys() override;
/////////////////////////////////
// Object duplication
/////////////////////////////////
public:
TextTsvKeys* clone() const override;
/////////////////////////////////
// Static methods
/////////////////////////////////
public:
static QString id();
static Merge* create();
};
}
#endif // merge_TextTsvKeys_h