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

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

Inheritance diagram for glbarcode::Barcode1dBase:
Collaboration diagram for glbarcode::Barcode1dBase:

Public Member Functions

 ~Barcode1dBase () 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

 Barcode1dBase ()
 
virtual bool validate (const std::string &rawData)=0
 
virtual std::string preprocess (const std::string &rawData)
 
virtual std::string encode (const std::string &cookedData)=0
 
virtual std::string prepareText (const std::string &rawData)
 
virtual void vectorize (const std::string &encodedData, const std::string &displayText, const std::string &cookedData, double &w, double &h)=0
 
- 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 Barcode1dBase class is the base class for all 1D barcode implementations. This class provides a common framework for the implementation of 1D barcodes. Creating 1D barcode types (or symbologies) would be typically accomplished by implementing this class rather than directly implementing the Barcode class.

Constructor & Destructor Documentation

◆ Barcode1dBase()

glbarcode::Barcode1dBase::Barcode1dBase ( )
protected

Default constructor.

◆ ~Barcode1dBase()

glbarcode::Barcode1dBase::~Barcode1dBase ( )
override

Destructor.

Member Function Documentation

◆ build()

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

Build 1D barcode from data.

Implements glbarcode::Barcode::build(). Calls the validate(), preprocess(), encode(), prepareText(), 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 std::string glbarcode::Barcode1dBase::encode ( const std::string &  cookedData)
protectedpure virtual

Data encoder.

Required virtual method to encode data such that it can be later vectorized. The encoded data is usually a list of characters that represent an atomic barcode element (e.g. 'w' = a wide line & 'n' = a narrow line).

Parameters
[in]cookedDataData to encode
Returns
Encoded data

◆ prepareText()

virtual std::string glbarcode::Barcode1dBase::prepareText ( const std::string &  rawData)
protectedvirtual

Prepare text.

Optional virtual method to prepare text to be displayed as part of barcode.

Parameters
[in]rawDataData to prepare
Returns
text in display form

◆ preprocess()

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

Data preprocessor.

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::Barcode1dBase::validate ( const std::string &  rawData)
protectedpure virtual

Data validator.

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::Barcode1dBase::vectorize ( const std::string &  encodedData,
const std::string &  displayText,
const std::string &  cookedData,
double &  w,
double &  h 
)
protectedpure virtual

Vectorize encoded data.

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

Parameters
[in]encodedDataData to vectorize
[in]displayTextText to display
[in]cookedDataOriginal data prior to encoding (may be needed for sizing)
[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: