summaryrefslogtreecommitdiff
path: root/examples/corelib
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-03-13 19:37:31 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2023-04-19 17:40:36 +0200
commitbcab157f75add9b2ac3c69e9c2c0399c71a7df5f (patch)
treed3c837536c9a206dc119e3ddb040ec91d3095bfd /examples/corelib
parent762bf783dd119edf946eafbd60011cf7daf63135 (diff)
downloadqtbase-bcab157f75add9b2ac3c69e9c2c0399c71a7df5f.tar.gz
Update table of CBOR tag descriptions in cbordump example
A comment said how to do this, so I gave it a try. Added a note to the instructions to save the next person to look at this from, as I initially did, thinking the comment in the generated code had the URL wrong. It turns out that some of the newer additions to the IANA registry have semantics elements that spread across several lines. I don't know the XSLT magic to replace each newline in a value, along with its preceding and following spacs, by a single space, so adapted the XSLT to produce C++ raw strings to wrap these multi-line entries. That'll produce somewhat ugly output, so left a TODO for the better solution. Task-number: QTBUG-111228 Pick-to: 6.5 Change-Id: I7d5e968284e0f1da2ec990af9512c9b7cb886792 Reviewed-by: MikoĊ‚aj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'examples/corelib')
-rw-r--r--examples/corelib/serialization/cbordump/main.cpp223
-rw-r--r--examples/corelib/serialization/cbordump/tag-transform.xslt8
2 files changed, 185 insertions, 46 deletions
diff --git a/examples/corelib/serialization/cbordump/main.cpp b/examples/corelib/serialization/cbordump/main.cpp
index a53bbdebda..106c408cbc 100644
--- a/examples/corelib/serialization/cbordump/main.cpp
+++ b/examples/corelib/serialization/cbordump/main.cpp
@@ -18,8 +18,17 @@
* To regenerate:
* curl -O https://www.iana.org/assignments/cbor-tags/cbor-tags.xml
* xsltproc tag-transform.xslt cbor-tags.xml
+ *
+ * The XHTML URL mentioned in the comment below is a human-readable version of
+ * the same resource.
*/
+/* TODO (if possible): fix XSLT to replace each newline and surrounding space in
+ a semantics entry with a single space, instead of using a raw string to wrap
+ each, propagating the spacing from the XML to the output of cbordump. Also
+ auto-purge dangling spaces from the ends of generated lines.
+*/
+
// GENERATED CODE
struct CborTagDescription
{
@@ -30,49 +39,177 @@ struct CborTagDescription
// CBOR Tags
static const CborTagDescription tagDescriptions[] = {
// from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml
- { QCborTag(0), " (Standard date/time string; see Section 2.4.1 [RFC7049])" },
- { QCborTag(1), " (Epoch-based date/time; see Section 2.4.1 [RFC7049])" },
- { QCborTag(2), " (Positive bignum; see Section 2.4.2 [RFC7049])" },
- { QCborTag(3), " (Negative bignum; see Section 2.4.2 [RFC7049])" },
- { QCborTag(4), " (Decimal fraction; see Section 2.4.3 [RFC7049])" },
- { QCborTag(5), " (Bigfloat; see Section 2.4.3 [RFC7049])" },
- { QCborTag(16), " (COSE Single Recipient Encrypted Data Object [RFC8152])" },
- { QCborTag(17), " (COSE Mac w/o Recipients Object [RFC8152])" },
- { QCborTag(18), " (COSE Single Signer Data Object [RFC8152])" },
- { QCborTag(21), " (Expected conversion to base64url encoding; see Section 2.4.4.2 [RFC7049])" },
- { QCborTag(22), " (Expected conversion to base64 encoding; see Section 2.4.4.2 [RFC7049])" },
- { QCborTag(23), " (Expected conversion to base16 encoding; see Section 2.4.4.2 [RFC7049])" },
- { QCborTag(24), " (Encoded CBOR data item; see Section 2.4.4.1 [RFC7049])" },
- { QCborTag(25), " (reference the nth previously seen string)" },
- { QCborTag(26), " (Serialised Perl object with classname and constructor arguments)" },
- { QCborTag(27), " (Serialised language-independent object with type name and constructor arguments)" },
- { QCborTag(28), " (mark value as (potentially) shared)" },
- { QCborTag(29), " (reference nth marked value)" },
- { QCborTag(30), " (Rational number)" },
- { QCborTag(32), " (URI; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(33), " (base64url; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(34), " (base64; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(35), " (Regular expression; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(36), " (MIME message; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(37), " (Binary UUID ( section 4.1.2))" },
- { QCborTag(38), " (Language-tagged string)" },
- { QCborTag(39), " (Identifier)" },
- { QCborTag(61), " (CBOR Web Token (CWT))" },
- { QCborTag(96), " (COSE Encrypted Data Object [RFC8152])" },
- { QCborTag(97), " (COSE MACed Data Object [RFC8152])" },
- { QCborTag(98), " (COSE Signed Data Object [RFC8152])" },
- { QCborTag(256), " (mark value as having string references)" },
- { QCborTag(257), " (Binary MIME message)" },
- { QCborTag(258), " (Mathematical finite set)" },
- { QCborTag(260), " (Network Address (IPv4 or IPv6 or MAC Address))" },
- { QCborTag(264), " (Decimal fraction with arbitrary exponent)" },
- { QCborTag(265), " (Bigfloat with arbitrary exponent)" },
- { QCborTag(1001), " (extended time)" },
- { QCborTag(1002), " (duration)" },
- { QCborTag(1003), " (period)" },
- { QCborTag(22098), " (hint that indicates an additional level of indirection)" },
- { QCborTag(55799), " (Self-describe CBOR; see Section 2.4.5 [RFC7049])" },
- { QCborTag(15309736), " (RAINS Message)" },
+ { QCborTag(0),
+ R"r( (Standard date/time string; see Section 3.4.1 [RFC8949]))r" },
+ { QCborTag(1),
+ R"r( (Epoch-based date/time; see Section 3.4.2 [RFC8949]))r" },
+ { QCborTag(2),
+ R"r( (Positive bignum; see Section 3.4.3 [RFC8949]))r" },
+ { QCborTag(3),
+ R"r( (Negative bignum; see Section 3.4.3 [RFC8949]))r" },
+ { QCborTag(4),
+ R"r( (Decimal fraction; see Section 3.4.4 [RFC8949]))r" },
+ { QCborTag(5),
+ R"r( (Bigfloat; see Section 3.4.4 [RFC8949]))r" },
+ { QCborTag(16),
+ R"r( (COSE Single Recipient Encrypted Data Object [RFC9052]))r" },
+ { QCborTag(17),
+ R"r( (COSE Mac w/o Recipients Object [RFC9052]))r" },
+ { QCborTag(18),
+ R"r( (COSE Single Signer Data Object [RFC9052]))r" },
+ { QCborTag(19),
+ R"r( (COSE standalone V2 countersignature [RFC9338]))r" },
+ { QCborTag(21),
+ R"r( (Expected conversion to base64url encoding; see Section 3.4.5.2 [RFC8949]))r" },
+ { QCborTag(22),
+ R"r( (Expected conversion to base64 encoding; see Section 3.4.5.2 [RFC8949]))r" },
+ { QCborTag(23),
+ R"r( (Expected conversion to base16 encoding; see Section 3.4.5.2 [RFC8949]))r" },
+ { QCborTag(24),
+ R"r( (Encoded CBOR data item; see Section 3.4.5.1 [RFC8949]))r" },
+ { QCborTag(25),
+ R"r( (reference the nth previously seen string))r" },
+ { QCborTag(26),
+ R"r( (Serialised Perl object with classname and constructor arguments))r" },
+ { QCborTag(27),
+ R"r( (Serialised language-independent object with type name and constructor arguments))r" },
+ { QCborTag(28),
+ R"r( (mark value as (potentially) shared))r" },
+ { QCborTag(29),
+ R"r( (reference nth marked value))r" },
+ { QCborTag(30),
+ R"r( (Rational number))r" },
+ { QCborTag(31),
+ R"r( (Absent value in a CBOR Array))r" },
+ { QCborTag(32),
+ R"r( (URI; see Section 3.4.5.3 [RFC8949]))r" },
+ { QCborTag(33),
+ R"r( (base64url; see Section 3.4.5.3 [RFC8949]))r" },
+ { QCborTag(34),
+ R"r( (base64; see Section 3.4.5.3 [RFC8949]))r" },
+ { QCborTag(35),
+ R"r( (Regular expression; see Section 2.4.4.3 [RFC7049]))r" },
+ { QCborTag(36),
+ R"r( (MIME message; see Section 3.4.5.3 [RFC8949]))r" },
+ { QCborTag(37),
+ R"r( (Binary UUID (RFC4122, Section 4.1.2)))r" },
+ { QCborTag(38),
+ R"r( (Language-tagged string [RFC9290]))r" },
+ { QCborTag(39),
+ R"r( (Identifier))r" },
+ { QCborTag(40),
+ R"r( (Multi-dimensional Array, row-major order [RFC8746]))r" },
+ { QCborTag(41),
+ R"r( (Homogeneous Array [RFC8746]))r" },
+ { QCborTag(42),
+ R"r( (IPLD content identifier))r" },
+ { QCborTag(43),
+ R"r( (YANG bits datatype; see Section 6.7. [RFC9254]))r" },
+ { QCborTag(44),
+ R"r( (YANG enumeration datatype; see Section 6.6. [RFC9254]))r" },
+ { QCborTag(45),
+ R"r( (YANG identityref datatype; see Section 6.10. [RFC9254]))r" },
+ { QCborTag(46),
+ R"r( (YANG instance-identifier datatype; see Section 6.13. [RFC9254]))r" },
+ { QCborTag(47),
+ R"r( (YANG Schema Item iDentifier (sid); see Section 3.2. [RFC9254]))r" },
+ { QCborTag(52),
+ R"r( (IPv4, [prefixlen,IPv4], [IPv4,prefixpart] [RFC9164]))r" },
+ { QCborTag(54),
+ R"r( (IPv6, [prefixlen,IPv6], [IPv6,prefixpart] [RFC9164]))r" },
+ { QCborTag(61),
+ R"r( (CBOR Web Token (CWT) [RFC8392]))r" },
+ { QCborTag(63),
+ R"r( (Encoded CBOR Sequence ))r" },
+ { QCborTag(64),
+ R"r( (uint8 Typed Array [RFC8746]))r" },
+ { QCborTag(65),
+ R"r( (uint16, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(66),
+ R"r( (uint32, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(67),
+ R"r( (uint64, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(68),
+ R"r( (uint8 Typed Array, clamped arithmetic [RFC8746]))r" },
+ { QCborTag(69),
+ R"r( (uint16, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(70),
+ R"r( (uint32, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(71),
+ R"r( (uint64, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(72),
+ R"r( (sint8 Typed Array [RFC8746]))r" },
+ { QCborTag(73),
+ R"r( (sint16, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(74),
+ R"r( (sint32, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(75),
+ R"r( (sint64, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(76),
+ R"r( ((reserved) [RFC8746]))r" },
+ { QCborTag(77),
+ R"r( (sint16, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(78),
+ R"r( (sint32, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(79),
+ R"r( (sint64, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(80),
+ R"r( (IEEE 754 binary16, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(81),
+ R"r( (IEEE 754 binary32, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(82),
+ R"r( (IEEE 754 binary64, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(83),
+ R"r( (IEEE 754 binary128, big endian, Typed Array [RFC8746]))r" },
+ { QCborTag(84),
+ R"r( (IEEE 754 binary16, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(85),
+ R"r( (IEEE 754 binary32, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(86),
+ R"r( (IEEE 754 binary64, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(87),
+ R"r( (IEEE 754 binary128, little endian, Typed Array [RFC8746]))r" },
+ { QCborTag(96),
+ R"r( (COSE Encrypted Data Object [RFC9052]))r" },
+ { QCborTag(97),
+ R"r( (COSE MACed Data Object [RFC9052]))r" },
+ { QCborTag(98),
+ R"r( (COSE Signed Data Object [RFC9052]))r" },
+ { QCborTag(100),
+ R"r( (Number of days since the epoch date 1970-01-01 [RFC8943]))r" },
+ { QCborTag(101),
+ R"r( (alternatives as given by the uint + 128; see Section 9.1))r" },
+ { QCborTag(103),
+ R"r( (Geographic Coordinates))r" },
+ { QCborTag(104),
+ R"r( (Geographic Coordinate Reference System WKT or EPSG number))r" },
+ { QCborTag(110),
+ R"r( (relative object identifier (BER encoding); SDNV sequence [RFC9090]))r" },
+ { QCborTag(111),
+ R"r( (object identifier (BER encoding) [RFC9090]))r" },
+ { QCborTag(112),
+ R"r( (object identifier (BER encoding), relative to 1.3.6.1.4.1 [RFC9090]))r" },
+ { QCborTag(120),
+ R"r( (Internet of Things Data Point))r" },
+ { QCborTag(260),
+ R"r( (Network Address (IPv4 or IPv6 or MAC Address) (DEPRECATED in favor of 52 and 54
+ for IP addresses) [http://www.employees.oRg/~RaviR/CboR-netwoRk.txt]))r" },
+ { QCborTag(261),
+ R"r( (Network Address Prefix (IPv4 or IPv6 Address + Mask Length) (DEPRECATED in favor of 52 and 54
+ for IP addresses) [https://github.Com/toRaviR/CBOR-Tag-SpeCs/blob/masteR/netwoRkPReFix.md]))r" },
+ { QCborTag(271),
+ R"r( (DDoS Open Threat Signaling (DOTS) signal channel object,
+ as defined in [RFC9132]))r" },
+ { QCborTag(1004),
+ R"r( ( full-date string [RFC8943]))r" },
+ { QCborTag(1040),
+ R"r( (Multi-dimensional Array, column-major order [RFC8746]))r" },
+ { QCborTag(55799),
+ R"r( (Self-described CBOR; see Section 3.4.6 [RFC8949]))r" },
+ { QCborTag(55800),
+ R"r( (indicates that the file contains CBOR Sequences [RFC9277]))r" },
+ { QCborTag(55801),
+ R"r( (indicates that the file starts with a CBOR-Labeled Non-CBOR Data label. [RFC9277]))r" },
{ QCborTag(-1), nullptr }
};
// END GENERATED CODE
diff --git a/examples/corelib/serialization/cbordump/tag-transform.xslt b/examples/corelib/serialization/cbordump/tag-transform.xslt
index a562cb9fc3..fb9f81df33 100644
--- a/examples/corelib/serialization/cbordump/tag-transform.xslt
+++ b/examples/corelib/serialization/cbordump/tag-transform.xslt
@@ -19,8 +19,10 @@ static const CborTagDescription tagDescriptions[] = {
</xsl:for-each> { QCborTag(-1), nullptr }
};
</xsl:template>
-<xsl:template name="row"> { QCborTag(<xsl:value-of select="a:value"/>), " (<xsl:value-of select="a:semantics"/> <xsl:call-template name="xref"/>)" },
-</xsl:template>
-<xsl:template name="xref"><xsl:if test="a:xref/@type = 'rfc'"> [<xsl:value-of select="translate(a:xref/@data,'rfc','RFC')"/>]</xsl:if>
+<xsl:template name="row"> { QCborTag(<xsl:value-of select="a:value"/>),
+ R"r( (<xsl:value-of select="a:semantics"/> <xsl:call-template name="xref"/>))r" },
+</xsl:template><!-- fn:replace(a:semantics, '\s+', ' ') -->
+<xsl:template name="xref"><xsl:if test="a:xref/@type = 'rfc'"> [<xsl:value-of
+select="translate(a:xref/@data,'rfc','RFC')"/>]</xsl:if>
</xsl:template>
</xsl:stylesheet>