From a9a5cdbb58ff549053060af39aa7bed2a434edaf Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Tue, 24 May 2016 18:41:34 +0000 Subject: [PATCH] Updated documentation comments for 3 functions in all language versions. --- cpp/QrCode.hpp | 8 +++++--- java/io/nayuki/qrcodegen/QrCode.java | 12 +++++++----- javascript/qrcodegen.js | 6 ++++-- python/qrcodegen.py | 10 ++++++---- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cpp/QrCode.hpp b/cpp/QrCode.hpp index 0d981c0..5b23776 100644 --- a/cpp/QrCode.hpp +++ b/cpp/QrCode.hpp @@ -70,6 +70,7 @@ public: * 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 * code points (not UTF-16 code units). 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. */ static QrCode encodeText(const char *text, const Ecc &ecl); @@ -78,6 +79,7 @@ public: * Returns a QR Code symbol representing the given binary data string at the given error correction level. * This function always encodes using the binary segment mode, not any text mode. The maximum number of * bytes allowed is 2953. 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. */ static QrCode encodeBinary(const std::vector &data, const Ecc &ecl); @@ -126,9 +128,9 @@ private: public: /* - * Creates a new QR Code symbol with the given version number, error correction level, binary data string, and mask number. - * This cumbersome constructor can be invoked directly by the user, but is considered - * to be even lower level than encodeSegments(). + * 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 should not be invoked directly by the user. + * To go one level up, see the encodeSegments() function. */ QrCode(int ver, const Ecc &ecl, const std::vector &dataCodewords, int mask); diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index 3cad230..bf9c760 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -43,8 +43,9 @@ public final class QrCode { * Returns a QR Code symbol representing the specified Unicode text string at the specified error correction level. * As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode * code points (not UTF-16 code units). 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. * @param text the text to be encoded, which can be any Unicode string - * @param ecl the error correction level to use + * @param ecl the error correction level to use (will be boosted) * @return a QR Code representing the text * @throws NullPointerException if the text or error correction level is {@code null} * @throws IllegalArgumentException if the text fails to fit in the largest version QR Code, which means it is too long @@ -61,8 +62,9 @@ public final class QrCode { * Returns a QR Code symbol representing the specified binary data string at the specified error correction level. * This function always encodes using the binary segment mode, not any text mode. The maximum number of * bytes allowed is 2953. 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. * @param data the binary data to encode - * @param ecl the error correction level to use + * @param ecl the error correction level to use (will be boosted) * @return a QR Code representing the binary data * @throws NullPointerException if the data or error correction level is {@code null} * @throws IllegalArgumentException if the data fails to fit in the largest version QR Code, which means it is too long @@ -187,9 +189,9 @@ public final class QrCode { /*---- Constructors ----*/ /** - * Creates a new QR Code symbol with the specified version number, error correction level, binary data string, and mask number. - *

This cumbersome constructor can be invoked directly by the user, but is considered - * to be even lower level than {@link #encodeSegments(List,Ecc)}.

+ * Creates a new QR Code symbol with the specified version number, error correction level, binary data array, and mask number. + *

This is a cumbersome low-level constructor that should not be invoked directly by the user. + * To go one level up, see the {@link #encodeSegments(List,Ecc)} function.

* @param ver the version number to use, which must be in the range 1 to 40, inclusive * @param ecl the error correction level to use * @param dataCodewords the raw binary user data to encode diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 0b59066..a6fc652 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -68,8 +68,8 @@ var qrcodegen = new function() { * This constructor can be called in one of two ways: * - new QrCode(datacodewords, mask, version, errCorLvl): * Creates a new QR Code symbol with the given version number, error correction level, binary data array, - * and mask number. This cumbersome constructor can be invoked directly by the user, but is considered - * to be even lower level than QrCode.encodeSegments(). + * and mask number. This is a cumbersome low-level constructor that should not be invoked directly by the user. + * To go one level up, see the QrCode.encodeSegments() function. * - new QrCode(qr, mask): * Creates a new QR Code symbol based on the given existing object, but with a potentially different * mask pattern. The version, error correction level, codewords, etc. of the newly created object are @@ -541,6 +541,7 @@ var qrcodegen = new function() { * 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 * code points (not UTF-16 code units). 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. */ this.QrCode.encodeText = function(text, ecl) { var segs = qrcodegen.QrSegment.makeSegments(text); @@ -552,6 +553,7 @@ var qrcodegen = new function() { * Returns a QR Code symbol representing the given binary data string at the given error correction level. * This function always encodes using the binary segment mode, not any text mode. The maximum number of * bytes allowed is 2953. 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. */ this.QrCode.encodeBinary = function(data, ecl) { var seg = qrcodegen.QrSegment.makeBytes(data); diff --git a/python/qrcodegen.py b/python/qrcodegen.py index f77b9a5..5cb51ac 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -70,7 +70,8 @@ class QrCode(object): def encode_text(text, ecl): """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 - code points (not UTF-16 code units). The smallest possible QR Code version is automatically chosen for the output.""" + code points (not UTF-16 code units). 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.""" segs = QrSegment.make_segments(text) return QrCode.encode_segments(segs, ecl) @@ -79,7 +80,8 @@ class QrCode(object): def encode_binary(data, ecl): """Returns a QR Code symbol representing the given binary data string at the given error correction level. This function always encodes using the binary segment mode, not any text mode. The maximum number of - bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.""" + bytes allowed is 2953. 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.""" if not isinstance(data, bytes): raise TypeError("Binary array expected") return QrCode.encode_segments([QrSegment.make_bytes(data)], ecl) @@ -141,8 +143,8 @@ class QrCode(object): """This constructor can be called in one of two ways: - QrCode(datacodewords=list, mask=int, version=int, errcorlvl=QrCode.Ecc): Creates a new QR Code symbol with the given version number, error correction level, binary data array, - and mask number. This cumbersome constructor can be invoked directly by the user, but is considered - to be even lower level than QrCode.encode_segments(). + and mask number. This is a cumbersome low-level constructor that should not be invoked directly by the user. + To go one level up, see the QrCode.encode_segments() function. - QrCode(qrcode=QrCode, mask=int): Creates a new QR Code symbol based on the given existing object, but with a potentially different mask pattern. The version, error correction level, codewords, etc. of the newly created object are