Updated, added, synchronized section comments to show abstraction level in classes QrCode and QrSegment, in all languages except C.

pull/39/merge
Project Nayuki 6 years ago
parent 859438d183
commit 49e0902d9f

@ -55,7 +55,7 @@ class QrCode final {
/*---- Public static factory functions ----*/
/*---- Static factory functions (high level) ----*/
/*
* Returns a QR Code symbol representing the given Unicode text string at the given error correction level.
@ -76,6 +76,8 @@ class QrCode final {
public: static QrCode encodeBinary(const std::vector<std::uint8_t> &data, Ecc ecl);
/*---- Static factory functions (mid level) ----*/
/*
* Returns a QR Code symbol representing the given segments with the given encoding parameters.
* The smallest possible QR Code version within the given range is automatically chosen for the output.
@ -113,7 +115,7 @@ class QrCode final {
/*---- Constructor ----*/
/*---- Constructor (low level) ----*/
/*
* Creates a new QR Code symbol with the given version number, error correction level, binary data array,

@ -85,7 +85,7 @@ class QrSegment final {
/*---- Public static factory functions ----*/
/*---- Static factory functions (mid level) ----*/
/*
* Returns a segment representing the given binary data encoded in byte mode.
@ -148,7 +148,7 @@ class QrSegment final {
private: std::vector<bool> data;
/*---- Constructors ----*/
/*---- Constructors (low level) ----*/
/*
* Creates a new QR Code segment with the given parameters and data.

@ -37,7 +37,7 @@ import java.util.Objects;
*/
public final class QrCode {
/*---- Public static factory functions ----*/
/*---- Static factory functions (high level) ----*/
/**
* Returns a QR Code symbol representing the specified Unicode text string at the specified error correction level.
@ -80,6 +80,8 @@ public final class QrCode {
}
/*---- Static factory functions (mid level) ----*/
/**
* Returns a QR Code symbol representing the specified segments at the specified error correction
* level. The smallest possible QR Code version is automatically chosen for the output. The ECC level
@ -192,7 +194,7 @@ public final class QrCode {
/*---- Constructor ----*/
/*---- Constructor (low level) ----*/
/**
* Constructs a QR Code symbol with the specified version number, error correction level, binary data array, and mask number.

@ -39,7 +39,7 @@ import java.util.regex.Pattern;
*/
public final class QrSegment {
/*---- Static factory functions ----*/
/*---- Static factory functions (mid level) ----*/
/**
* Returns a segment representing the specified binary data encoded in byte mode.
@ -166,7 +166,7 @@ public final class QrSegment {
final BitBuffer data;
/*---- Constructor ----*/
/*---- Constructor (low level) ----*/
/**
* Constructs a QR Code segment with the specified parameters and data.

@ -70,7 +70,7 @@ var qrcodegen = new function() {
*/
this.QrCode = function(datacodewords, mask, version, errCorLvl) {
/*---- Constructor ----*/
/*---- Constructor (low level) ----*/
// Check arguments and handle simple scalar fields
if (mask < -1 || mask > 7)
@ -510,7 +510,7 @@ var qrcodegen = new function() {
};
/*---- Public static factory functions for QrCode ----*/
/*---- Static factory functions (high level) for QrCode ----*/
/*
* Returns a QR Code symbol representing the given Unicode text string at the given error correction level.
@ -537,6 +537,8 @@ var qrcodegen = new function() {
};
/*---- Static factory functions (mid level) for QrCode ----*/
/*
* Returns a QR Code symbol representing the given segments with the given encoding parameters.
* The smallest possible QR Code version within the given range is automatically chosen for the output.
@ -698,6 +700,7 @@ var qrcodegen = new function() {
* Any segment longer than this is meaningless for the purpose of generating QR Codes.
*/
this.QrSegment = function(mode, numChars, bitData) {
/*---- Constructor (low level) ----*/
if (numChars < 0 || !(mode instanceof Mode))
throw "Invalid argument";
bitData = bitData.slice(); // Make defensive copy
@ -715,7 +718,7 @@ var qrcodegen = new function() {
};
/*---- Public static factory functions for QrSegment ----*/
/*---- Static factory functions (mid level) for QrSegment ----*/
/*
* Returns a segment representing the given binary data encoded in byte mode.

@ -66,7 +66,7 @@ class QrCode(object):
This class covers the QR Code Model 2 specification, supporting all versions (sizes)
from 1 to 40, all 4 error correction levels, and 4 character encoding modes."""
# ---- Public static factory functions ----
# ---- Static factory functions (high level) ----
@staticmethod
def encode_text(text, ecl):
@ -90,6 +90,8 @@ class QrCode(object):
return QrCode.encode_segments([QrSegment.make_bytes(data)], ecl)
# ---- Static factory functions (mid level) ----
@staticmethod
def encode_segments(segs, ecl, minversion=1, maxversion=40, mask=-1, boostecl=True):
"""Returns a QR Code symbol representing the given segments with the given encoding parameters.
@ -142,7 +144,7 @@ class QrCode(object):
return QrCode(bb.get_bytes(), mask, version, ecl)
# ---- Constructor ----
# ---- Constructor (low level) ----
def __init__(self, datacodewords, mask, version, errcorlvl):
"""Creates a new QR Code symbol with the given version number, error correction level, binary data array,
@ -588,7 +590,7 @@ class QrSegment(object):
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."""
# ---- Public static factory functions ----
# ---- Static factory functions (mid level) ----
@staticmethod
def make_bytes(data):
@ -673,7 +675,7 @@ class QrSegment(object):
return QrSegment(QrSegment.Mode.ECI, 0, bb)
# ---- Constructor ----
# ---- Constructor (low level) ----
def __init__(self, mode, numch, bitdata):
"""Creates a new QR Code segment with the given parameters and data."""

@ -57,7 +57,7 @@ pub struct QrCode {
impl QrCode {
/*---- Public static factory functions ----*/
/*---- Static factory functions (high level) ----*/
// Returns a QR Code symbol representing the given Unicode text string at the given error correction level.
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode
@ -83,6 +83,8 @@ impl QrCode {
}
/*---- Static factory functions (mid level) ----*/
// Returns a QR Code symbol representing the given segments at the given error correction level.
// The smallest possible QR Code version is automatically chosen for the output. The ECC level
// of the result may be higher than the ecl argument if it can be done without increasing the version.
@ -167,7 +169,7 @@ impl QrCode {
}
/*---- Constructor ----*/
/*---- Constructor (low level) ----*/
// Creates a new QR Code symbol with the given version number, error correction level,
// binary data array, and mask number. This is a cumbersome low-level constructor that
@ -841,7 +843,7 @@ pub struct QrSegment {
impl QrSegment {
/*---- Static factory functions ----*/
/*---- Static factory functions (mid level) ----*/
// Returns a segment representing the given binary data encoded in byte mode.
pub fn make_bytes(data: &[u8]) -> Self {
@ -938,6 +940,8 @@ impl QrSegment {
}
/*---- Constructor (low level) ----*/
// Creates a new QR Code segment with the given parameters and data.
pub fn new(mode: QrSegmentMode, numchars: usize, data: Vec<bool>) -> Self {
Self {

@ -44,7 +44,7 @@ namespace qrcodegen {
*/
export class QrCode {
/*-- Public static factory functions --*/
/*-- Static factory functions (high level) --*/
// Returns a QR Code symbol representing the given Unicode text string at the given error correction level.
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
@ -67,6 +67,8 @@ namespace qrcodegen {
}
/*-- Static factory functions (mid level) --*/
// Returns a QR Code symbol representing the given segments with the given encoding parameters.
// The smallest possible QR Code version within the given range is automatically chosen for the output.
// This function allows the user to create a custom sequence of segments that switches
@ -142,7 +144,7 @@ namespace qrcodegen {
private readonly isFunction: Array<Array<boolean>> = [];
/*-- Constructor and fields --*/
/*-- Constructor (low level) and fields --*/
public constructor(
datacodewords: Array<byte>,
@ -654,7 +656,7 @@ namespace qrcodegen {
*/
export class QrSegment {
/*-- Static factory functions --*/
/*-- Static factory functions (mid level) --*/
// Returns a segment representing the given binary data encoded in byte mode.
public static makeBytes(data: Array<byte>): QrSegment {
@ -733,7 +735,7 @@ namespace qrcodegen {
}
/*-- Constructor and fields --*/
/*-- Constructor (low level) and fields --*/
// Creates a new QR Code segment with the given parameters and data.
public constructor(

Loading…
Cancel
Save