glbarcode++
 
Loading...
Searching...
No Matches
glbarcode::Barcode2dBase Class Referenceabstract

#include </home/evins/glbarcode/glbarcode/Barcode2dBase.hpp>

Inheritance diagram for glbarcode::Barcode2dBase:
Collaboration diagram for glbarcode::Barcode2dBase:

Public Member Functions

 ~Barcode2dBase () override
 
Barcodebuild (const std::string &data, double w=0, double h=0) override
 
- Public Member Functions inherited from glbarcode::Barcode
virtual ~Barcode ()
 
 Barcode (const Barcode &)=delete
 
void operator= (const Barcode &)=delete
 
BarcodesetShowText (bool value)
 
bool showText () const
 
BarcodesetChecksum (bool value)
 
bool checksum () const
 
void render (Renderer &renderer)
 
bool isEmpty () const
 
bool isDataValid () const
 
double width () const
 
double height () const
 

Protected Member Functions

 Barcode2dBase ()
 
virtual bool validate (const std::string &rawData)=0
 
virtual std::string preprocess (const std::string &rawData)
 
virtual bool encode (const std::string &cookedData, Matrix< bool > &encodedData)=0
 
virtual void vectorize (const Matrix< bool > &encodedData, double &w, double &h)
 
- Protected Member Functions inherited from glbarcode::Barcode
 Barcode ()
 
void clear ()
 
void addLine (double x, double y, double w, double h)
 
void addBox (double x, double y, double w, double h)
 
void addText (double x, double y, double size, const std::string &text, HAlign halign=H_ALIGN_CENTER)
 
void addRing (double x, double y, double r, double w)
 
void addHexagon (double x, double y, double h)
 
void setIsEmpty (bool value)
 
void setIsDataValid (bool value)
 
void setWidth (double w)
 
void setHeight (double h)
 

Detailed Description

The Barcode2dBase class is the base class for all 2D barcode implementations. This class provides a common framework for the implementation of 2D barcodes. Creating 2D barcode types (or symbologies) would be typically accomplished by implementing this class rather than directly implementing the Barcode class.

Constructor & Destructor Documentation

◆ Barcode2dBase()

glbarcode::Barcode2dBase::Barcode2dBase ( )
protected

Default constructor.

◆ ~Barcode2dBase()

glbarcode::Barcode2dBase::~Barcode2dBase ( )
override

Destructor.

Member Function Documentation

◆ build()

Barcode & glbarcode::Barcode2dBase::build ( const std::string &  data,
double  w = 0,
double  h = 0 
)
overridevirtual

Build 2D barcode from data.

Implements glbarcode::Barcode::build(). Calls the validate(), preprocess(), encode(), and vectorize() virtual methods, as shown:

Parameters
[in]dataData to encode in barcode
[in]wRequested width of barcode (0 = auto size)
[in]hRequested height of barcode (0 = auto size)
Returns
A reference to this Barcode object for chaining methods

Implements glbarcode::Barcode.

◆ encode()

virtual bool glbarcode::Barcode2dBase::encode ( const std::string &  cookedData,
Matrix< bool > &  encodedData 
)
protectedpure virtual

Encode barcode data

Required virtual method to encode data such that it can be later vectorized.

Parameters
[in]cookedDataData to encode
[out]encodedDataEncoded data in the form of a matrix
Returns
True if data was encoded successfully
False if data could not be encoded (condition not discoverable by validate())

◆ preprocess()

virtual std::string glbarcode::Barcode2dBase::preprocess ( const std::string &  rawData)
protectedvirtual

Preprocess barcode data.

Optional virtual method to perform any transformation of the data needed before encoding. (E.g. encoding an extended alphabet into a simpler one).

Parameters
[in]rawDataData to preprocess
Returns
Preprocessed data

◆ validate()

virtual bool glbarcode::Barcode2dBase::validate ( const std::string &  rawData)
protectedpure virtual

Validate barcode data.

Required virtual method to test if data is valid for encoding with barcode type.

Parameters
[in]rawDataData to validate
Returns
True if data is valid data for barcode type
False if data is not valid data for barcode type

◆ vectorize()

virtual void glbarcode::Barcode2dBase::vectorize ( const Matrix< bool > &  encodedData,
double &  w,
double &  h 
)
protectedvirtual

Vectorize encoded data

Optional virtual method to convert encoded data into a list of drawing primitives which can later be rendered.

Parameters
[in]encodedDataData to vectorize
[in,out]wRequested width of barcode (0 = auto size), vectorize will overwrite with actual width
[in,out]hRequested height of barcode (0 = auto size), vectorize will overwrite with actual width

The documentation for this class was generated from the following file: