BPS C++ API  2.24.4
BpsGs1Data Class Reference

Parses and composes GS1 data records with AI elements. More...

#include <bpsgs1data.h>

Public Types

enum  Status { S_OK , S_Error }
 Status of record and elements. More...
 

Public Member Functions

void addElement (const QString &aAi, const QString &aData)
 Add another element to the record. More...
 
QString ai (int aIndex) const
 Get the application identifier of an element. More...
 
 BpsGs1Data ()
 Construct an empty GS1 data object to compose a record.
 
 BpsGs1Data (const BpsGs1Data &aOther)
 Copy constructor. More...
 
 BpsGs1Data (const QString &aString)
 Construct a GS1 data object from parsing a string with the scanned content. More...
 
void clear ()
 Clear the record.
 
QString code () const
 
int count () const
 
QString data (int aIndex) const
 Get the element content. More...
 
void fixup ()
 Fixup the record by removing elements in error, and recalculate the final checksum.
 
bool gs (int aIndex) const
 Get the GS (FNC1) requirement of an element. More...
 
int indexOf (const QRegExp &aAiRegExp, int aFrom=0)
 Returns the index of the first element matching the search pattern by QRegExp::exactMatch(ai(index)). More...
 
int indexOf (const QString &aAi, int aFrom=0)
 Returns the index of the first element with this AI. More...
 
BpsGs1Dataoperator= (const BpsGs1Data &aOther)
 Assignment. More...
 
void setCode (const QString &aCode)
 Set the code and parse it. More...
 
Status status () const
 
Status status (int aIndex) const
 Get an elements status. More...
 
QString text () const
 

Detailed Description

Parses and composes GS1 data records with AI elements.

See chapter Barcode scanning in the manual for list of supported AI's.

Member Enumeration Documentation

◆ Status

Status of record and elements.

Enumerator
S_OK 

The record or element is OK.

S_Error 

One or more of the elements are incomplete, have invalid characters, or no valid AI found.

Constructor & Destructor Documentation

◆ BpsGs1Data() [1/2]

BpsGs1Data::BpsGs1Data ( const QString aString)

Construct a GS1 data object from parsing a string with the scanned content.

Parameters
aStringThe string with the code.

◆ BpsGs1Data() [2/2]

BpsGs1Data::BpsGs1Data ( const BpsGs1Data aOther)

Copy constructor.

Parameters
aOtherThe other GS1 data object to copy.

Member Function Documentation

◆ addElement()

void BpsGs1Data::addElement ( const QString aAi,
const QString aData 
)

Add another element to the record.

Fixup will be run in advance before adding the new element. Status might be S_Error after adding though, when validation of the new element fails.

Parameters
aAiThe AI of the element.
aDataThe element content.

◆ ai()

QString BpsGs1Data::ai ( int  aIndex) const

Get the application identifier of an element.

Parameters
aIndexThe element index in range 0 ... count()-1.
Returns
The AI of the element.

◆ code()

QString BpsGs1Data::code ( ) const
Returns
The plain record code, without AI braces.

◆ count()

int BpsGs1Data::count ( ) const
Returns
Number of elements in the record.

◆ data()

QString BpsGs1Data::data ( int  aIndex) const

Get the element content.

Parameters
aIndexThe element index in range 0 ... count()-1.
Returns
Data of the element.

◆ gs()

bool BpsGs1Data::gs ( int  aIndex) const

Get the GS (FNC1) requirement of an element.

Parameters
aIndexThe element index in range 0 ... count()-1.
Returns
True: A GS (FNC1) must be inserted before next element.

◆ indexOf() [1/2]

int BpsGs1Data::indexOf ( const QRegExp aAiRegExp,
int  aFrom = 0 
)

Returns the index of the first element matching the search pattern by QRegExp::exactMatch(ai(index)).

Parameters
aAiRegExpRegular expression describing the AI to find.
aFromThe index to start searching from.
Returns
Index of the found element, or -1 if no such element found.

◆ indexOf() [2/2]

int BpsGs1Data::indexOf ( const QString aAi,
int  aFrom = 0 
)

Returns the index of the first element with this AI.

Parameters
aAiThe AI searched.
aFromThe index to start searching from.
Returns
Index of the found element, or -1 if no such element found.

◆ operator=()

BpsGs1Data& BpsGs1Data::operator= ( const BpsGs1Data aOther)

Assignment.

Parameters
aOtherThe other record to copy.
Returns
Reference to this object.

◆ setCode()

void BpsGs1Data::setCode ( const QString aCode)

Set the code and parse it.

Parameters
aCodeThe code to set and parse.

◆ status() [1/2]

Status BpsGs1Data::status ( ) const
Returns
The current record status.

◆ status() [2/2]

Status BpsGs1Data::status ( int  aIndex) const

Get an elements status.

Parameters
aIndexThe element index in range 0 ... count()-1.
Returns
Status of the element.

◆ text()

QString BpsGs1Data::text ( ) const
Returns
The code with braces around the AI's as human friendly representation.

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