GS1 Barcode Syntax Engine — C / C++ API
Library for processing GS1 Application Identifier syntax
Namespaces | Data Structures | Enumerations
C++ API

Header-only C++ wrapper (requires C++17 or later) declared in gs1encoders.hpp, in the gs1encoders namespace. More...

Namespaces

namespace  gs1encoders
 Namespace containing the C++ wrapper for the GS1 Barcode Syntax Engine.
 

Data Structures

class  gs1encoders::GS1EncoderException
 Common base class for all exceptions thrown by this wrapper. More...
 
class  gs1encoders::GS1EncoderGeneralException
 Thrown to indicate a general problem initialising the library, such as when the underlying AI table cannot be loaded. More...
 
class  gs1encoders::GS1EncoderParameterException
 Thrown to indicate a problem with the parameters or input data passed to a setter. When the failure is a linting failure on AI data, gs1encoders::GS1Encoder::err_markup() returns a marked-up rendering of the offending AI. More...
 
class  gs1encoders::GS1EncoderDigitalLinkException
 Thrown to indicate an error processing GS1 Digital Link data. More...
 
class  gs1encoders::GS1EncoderScanDataException
 Thrown to indicate an error processing barcode scan data. More...
 
struct  gs1encoders::InitOpts
 Initialisation options for the gs1encoders::GS1Encoder constructor. More...
 
class  gs1encoders::GS1Encoder
 Main class for processing GS1 barcode data, including validation, format conversion, and generation of outputs such as GS1 Digital Link URIs and Human-Readable Interpretation text. More...
 

Enumerations

enum class  gs1encoders::Symbology : int {
  gs1encoders::Symbology::None = gs1_encoder_sNONE , gs1encoders::Symbology::DataBarOmni = gs1_encoder_sDataBarOmni , gs1encoders::Symbology::DataBarTruncated = gs1_encoder_sDataBarTruncated , gs1encoders::Symbology::DataBarStacked = gs1_encoder_sDataBarStacked ,
  gs1encoders::Symbology::DataBarStackedOmni = gs1_encoder_sDataBarStackedOmni , gs1encoders::Symbology::DataBarLimited = gs1_encoder_sDataBarLimited , gs1encoders::Symbology::DataBarExpanded = gs1_encoder_sDataBarExpanded , gs1encoders::Symbology::UPCA = gs1_encoder_sUPCA ,
  gs1encoders::Symbology::UPCE = gs1_encoder_sUPCE , gs1encoders::Symbology::EAN13 = gs1_encoder_sEAN13 , gs1encoders::Symbology::EAN8 = gs1_encoder_sEAN8 , gs1encoders::Symbology::GS1_128_CCA = gs1_encoder_sGS1_128_CCA ,
  gs1encoders::Symbology::GS1_128_CCC = gs1_encoder_sGS1_128_CCC , gs1encoders::Symbology::QR = gs1_encoder_sQR , gs1encoders::Symbology::DM = gs1_encoder_sDM , gs1encoders::Symbology::DotCode = gs1_encoder_sDotCode ,
  gs1encoders::Symbology::NumSyms = gs1_encoder_sNUMSYMS
}
 Recognised GS1 barcode formats ("symbologies") for processing scan data. More...
 
enum class  gs1encoders::Validation : int {
  gs1encoders::Validation::MutexAIs = gs1_encoder_vMUTEX_AIS , gs1encoders::Validation::RequisiteAIs = gs1_encoder_vREQUISITE_AIS , gs1encoders::Validation::RepeatedAIs = gs1_encoder_vREPEATED_AIS , gs1encoders::Validation::DigSigSerialKey = gs1_encoder_vDIGSIG_SERIAL_KEY ,
  gs1encoders::Validation::UnknownAInotDLattr = gs1_encoder_vUNKNOWN_AI_NOT_DL_ATTR , gs1encoders::Validation::NumValidations = gs1_encoder_vNUMVALIDATIONS
}
 Optional AI validation procedures that may be applied to detect invalid inputs. More...
 

Detailed Description

Header-only C++ wrapper (requires C++17 or later) declared in gs1encoders.hpp, in the gs1encoders namespace.

Wraps the C API with a move-only context class (gs1encoders::GS1Encoder), a fluent gs1encoders::InitOpts builder, a typed exception hierarchy rooted at gs1encoders::GS1EncoderException, and enum class mirrors of the C enums. The wrapper introduces no runtime overhead beyond the inline calls into the underlying C library.

The encoder owns the native context and releases it in its destructor, so no manual cleanup call is needed regardless of how the object's lifetime is managed: a function-scoped local, a member of a longer-lived service object, or a std::unique_ptr / std::shared_ptr for shared ownership all work.

Usage:

gs.set_ai_data_str("(01)09521234543213(99)TESTING123");
std::string uri = gs.get_dl_uri("https://example.com");
Main class for processing GS1 barcode data, including validation, format conversion,...
Definition gs1encoders.hpp:261
std::string get_dl_uri(const std::string &stem) const
Render the current AI-based input data as a GS1 Digital Link URI.
Definition gs1encoders.hpp:734
void set_ai_data_str(const std::string &v)
Set the barcode data input from a bracketed GS1 AI element string.
Definition gs1encoders.hpp:714

To load a Syntax Dictionary file instead of the embedded AI table:

.syntax_dictionary("dict.txt")
.fallback_on_syndict_error(true));
Initialisation options for the gs1encoders::GS1Encoder constructor.
Definition gs1encoders.hpp:203
InitOpts & syntax_dictionary(std::string path)
Set the path to a GS1 Syntax Dictionary file. If not set, the embedded AI table is used.
Definition gs1encoders.hpp:210

Enumeration Type Documentation

◆ Symbology

enum class gs1encoders::Symbology : int
strong

Recognised GS1 barcode formats ("symbologies") for processing scan data.

See also
gs1encoders::GS1Encoder::sym()
gs1encoders::GS1Encoder::set_sym()
gs1encoders::GS1Encoder::set_scan_data()
Enumerator
None 

None defined.

DataBarOmni 

GS1 DataBar Omnidirectional.

DataBarTruncated 

GS1 DataBar Truncated.

DataBarStacked 

GS1 DataBar Stacked.

DataBarStackedOmni 

GS1 DataBar Stacked Omnidirectional.

DataBarLimited 

GS1 DataBar Limited.

DataBarExpanded 

GS1 DataBar Expanded (Stacked).

UPCA 

UPC-A.

UPCE 

UPC-E.

EAN13 

EAN-13.

EAN8 

EAN-8.

GS1_128_CCA 

GS1-128 with CC-A or CC-B Composite Component.

GS1_128_CCC 

GS1-128 with CC-C Composite Component.

QR 

(GS1) QR Code.

DM 

(GS1) Data Matrix.

DotCode 

(GS1) DotCode.

NumSyms 

Number of defined symbologies; not itself a valid symbology.

◆ Validation

enum class gs1encoders::Validation : int
strong

Optional AI validation procedures that may be applied to detect invalid inputs.

These validation procedures are applied when AI data is supplied via gs1encoders::GS1Encoder::set_ai_data_str(), gs1encoders::GS1Encoder::set_data_str() or gs1encoders::GS1Encoder::set_scan_data(). Some procedures are locked (always enabled and not modifiable).

See also
gs1encoders::GS1Encoder::validation_enabled()
gs1encoders::GS1Encoder::set_validation_enabled()
Enumerator
MutexAIs 

Mutually exclusive AIs (locked: always enabled).

RequisiteAIs 

Mandatory associations between AIs.

RepeatedAIs 

Repeated AIs having same value (locked: always enabled).

DigSigSerialKey 

Serialisation qualifier AIs must be present with Digital Signature (locked: always enabled).

UnknownAInotDLattr 

Unknown AIs not permitted as GS1 DL URI data attributes.

NumValidations 

Number of defined validation procedures; not itself a valid procedure.