![]() |
NDEVR
API Documentation
|
A segment of character, binary, or control data in a QR Code symbol. More...
Classes | |
| class | Mode |
| Describes how a segment's data bits are interpreted. More... | |
Public Member Functions | |
| QrSegment (const Mode &md, int numCh, Buffer< bool > &&dt) | |
| Creates a new QR Code segment with the given attributes and data (move). | |
| QrSegment (const Mode &md, int numCh, const Buffer< bool > &dt) | |
| Creates a new QR Code segment with the given attributes and data (copy). | |
| const Buffer< bool > & | getData () const |
| Returns the data bits of this segment. | |
| const Mode & | getMode () const |
| Returns the mode field of this segment. | |
| int | getNumChars () const |
| Returns the character count field of this segment. | |
Static Public Member Functions | |
| static int | getTotalBits (const QrSegmentBuffer &segs, int version) |
| Calculates the total number of bits needed to encode the given segments at the given version. | |
| static bool | isAlphanumeric (const char *text) |
| Tests whether the given string can be encoded as a segment in alphanumeric mode. | |
| static bool | isNumeric (const char *text) |
| Tests whether the given string can be encoded as a segment in numeric mode. | |
| static QrSegment | makeAlphanumeric (const char *text) |
| Returns a segment representing the given text string encoded in alphanumeric mode. | |
| static QrSegment | makeBytes (const uint01 *data, uint04 size) |
| Returns a segment representing the given binary data encoded in byte mode. | |
| static QrSegment | makeEci (long assignVal) |
| Returns a segment representing an Extended Channel Interpretation (ECI) designator with the given assignment value. | |
| static QrSegment | makeNumeric (const char *digits) |
| Returns a segment representing the given string of decimal digits encoded in numeric mode. | |
| static QrSegmentBuffer | makeSegments (const char *text) |
| Returns a list of zero or more segments to represent the given text string. | |
A segment of character, binary, or control data in a QR Code symbol.
Instances of this class are immutable. The mid-level way to create a segment is to take the payload data and call a static factory function such as QrSegment::makeNumeric(). The low-level way to create a segment is to custom-make the bit buffer and call the QrSegment() constructor with appropriate values. This segment class imposes no length restrictions, but QR Codes have restrictions. Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. Any segment longer than this is meaningless for the purpose of generating QR Codes.
Creates a new QR Code segment with the given attributes and data (copy).
The character count (numCh) must agree with the mode and the bit buffer length, but the constraint is not checked. The given bit buffer is copied and stored.
| [in] | md | The encoding mode for this segment. |
| [in] | numCh | The number of characters in the original data. |
| [in] | dt | The bit buffer containing the encoded data (copied). |
Referenced by makeAlphanumeric(), makeBytes(), makeEci(), and makeNumeric().
Creates a new QR Code segment with the given attributes and data (move).
The character count (numCh) must agree with the mode and the bit buffer length, but the constraint is not checked. The given bit buffer is moved and stored.
| [in] | md | The encoding mode for this segment. |
| [in] | numCh | The number of characters in the original data. |
| [in] | dt | The bit buffer containing the encoded data (moved). |
| const Buffer< bool > & QrSegment::getData | ( | ) | const |
Returns the data bits of this segment.
| const Mode & QrSegment::getMode | ( | ) | const |
Returns the mode field of this segment.
| int QrSegment::getNumChars | ( | ) | const |
Returns the character count field of this segment.
|
static |
Calculates the total number of bits needed to encode the given segments at the given version.
Returns a non-negative number if successful. Otherwise returns -1 if a segment has too many characters to fit its length field, or the total bits exceeds INT_MAX.
| [in] | segs | The buffer of segments to measure. |
| [in] | version | The QR Code version number (1 to 40). |
|
static |
Tests whether the given string can be encoded as a segment in alphanumeric mode.
A string is encodable if and only if each character is in the following set: 0 to 9, A to Z (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
| [in] | text | A null-terminated string to test. |
|
static |
Tests whether the given string can be encoded as a segment in numeric mode.
A string is encodable if and only if each character is in the range '0' to '9'.
| [in] | text | A null-terminated string to test. |
|
static |
Returns a segment representing the given text string encoded in alphanumeric mode.
The characters allowed are: 0 to 9, A to Z (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
| [in] | text | A null-terminated string of alphanumeric characters. |
References QrSegment().
Returns a segment representing the given binary data encoded in byte mode.
All input byte arrays are acceptable. Any text string can be converted to UTF-8 bytes and encoded as a byte mode segment.
| [in] | data | Pointer to the raw byte data to encode. |
| [in] | size | The number of bytes in the data array. |
References QrSegment().
|
static |
Returns a segment representing an Extended Channel Interpretation (ECI) designator with the given assignment value.
| [in] | assignVal | The ECI assignment value. |
References QrSegment().
|
static |
Returns a segment representing the given string of decimal digits encoded in numeric mode.
| [in] | digits | A null-terminated string of characters in the range '0' to '9'. |
References QrSegment().
|
static |
Returns a list of zero or more segments to represent the given text string.
The result may use various segment modes and switch modes to optimize the length of the bit stream.
| [in] | text | A null-terminated string to encode. |