xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::cbor Namespace Reference

CBOR encoder and decoder. More...

Classes

class  Array
 Header of an array, without the actual elements. More...
 
struct  BreakTag
 Type used to read and write special value 31 (break) from or to a CBOR stream. More...
 
class  Decoder
 A class that decodes CBOR data types that includes: unsigned integers, negative integers, byte strings, text strings encoded as UTF-8, simple values and float-point number. More...
 
class  Encoder
 A class that encodes CBOR data types that includes: unsigned integers, negative integers, byte strings, text strings encoded as UTF8, simple values and float-point number. More...
 
class  ExtendedDataType
 A CBOR data type with additional information. More...
 
struct  IndefiniteTag
 Type used to determine whether an array or a map has indefinite length. More...
 
class  Map
 Header of a map, without the actual key/value pairs. More...
 
struct  NullTag
 Type used to read and write special value 22 (null) from or to a CBOR stream. More...
 
class  RangeIterator
 An object that can be used to keep track of the elements when decoding a CBOR array or map. More...
 
struct  UndefinedTag
 Type used to read and write special value 23 (undefined) from or to a CBOR stream. More...
 

Enumerations

enum class  AlternativeValue : std::uint64_t
 A class for alternatives values. More...
 
enum class  DataType {
  Null , UnsignedInteger , NegativeInteger , FloatingPoint ,
  Boolean , TextString , ByteString , Array ,
  Map , Tag , Undefined , SimpleValue ,
  Break
}
 A fundamental CBOR data type. More...
 
enum class  SimpleValue : std::uint8_t { False , True , Null , Undefined }
 A class for simple values. More...
 
enum class  Tag : std::uint64_t {
  StandardDateTimeString , EpochBasedDateTime , PositiveBignum , NegativeBignum ,
  DecimalFraction , Bigfloat , CoseSingleRecipientEncryptedDataObject , CoseMacWithoutRecipientsObject ,
  CoseSingleSignerDataObject , CoseStandaloneV2Countersignature , ExpectedConversionToBase64urlEncoding , ExpectedConversionToBase64Encoding ,
  ExpectedConversionToBase16Encoding , EncodedCborDataItem , ReferenceTheNthPreviouslySeenString , SerialisedPerlObjectWithClassnameAndConstructorArguments ,
  SerialisedLanguageIndependentObjectWithTypeNameAndConstructorArguments , MarkValueAsPotentiallyShared , ReferenceNthMarkedValue , RationalNumber ,
  AbsentValueInACborArray , Uri , Base64url , Base64 ,
  RegularExpression , MimeMessage , BinaryUuid , LanguageTaggedString ,
  Identifier , MultiDimensionalArrayRowMajorOrder , HomogeneousArray , IpldContentIdentifier ,
  YangBitsDatatype , YangEnumerationDatatype , YangIdentityrefDatatype , YangInstanceIdentifierDatatype ,
  YangSchemaItemIdentifier , Ipv4 , Ipv6 , CborWebToken ,
  EncodedCborSequence , Uint8TypedArray , Uint16BigEndianTypedArray , Uint32BigEndianTypedArray ,
  Uint64BigEndianTypedArray , Uint8TypedArrayClampedArithmetic , Uint16LittleEndianTypedArray , Uint32LittleEndianTypedArray ,
  Uint64LittleEndianTypedArray , Sint8TypedArray , Sint16BigEndianTypedArray , Sint32BigEndianTypedArray ,
  Sint64BigEndianTypedArray , Sint16LittleEndianTypedArray , Sint32LittleEndianTypedArray , Sint64LittleEndianTypedArray ,
  Ieee754Binary16BigEndianTypedArray , Ieee754Binary32BigEndianTypedArray , Ieee754Binary64BigEndianTypedArray , Ieee754Binary128BigEndianTypedArray ,
  Ieee754Binary16LittleEndianTypedArray , Ieee754Binary32LittleEndianTypedArray , Ieee754Binary64LittleEndianTypedArray , Ieee754Binary128LittleEndianTypedArray ,
  CoseEncryptedDataObject , CoseMacedDataObject , CoseSignedDataObject , NumberOfDaysSinceTheEpochDate ,
  GeographicCoordinates , GeographicCoordinateReferenceSystemWktOrEpsgNumber , RelativeObjectIdentifier , ObjectIdentifier ,
  ObjectIdentifierRelativeTo1_3_6_1_4_1 , InternetOfThingsDataPoint , MarkValueAsHavingStringReferences , BinaryMimeMessage ,
  MathematicalFiniteSet , MapDatatypeWithKeyValueOperations , NetworkAddress , NetworkAddressPrefix ,
  EmbeddedJsonObject , HexadecimalString , DecimalFractionWithArbitraryExponent , BigfloatWithArbitraryExponent ,
  InternationalizedResourceIdentifier , InternationalizedResourceIdentifierReference , ExtendedDecimalFraction , ExtendedBigfloat ,
  ExtendedRationalNumber , DotsSignalChannelObjectAsDefinedIn , NonUtf8Cesu8String , NonUtf8Wtf8String ,
  NonUtf8Mutf8String , MapContainsOnlyKeysThatAreOfTypeTextString , ErisBinaryReadCapability , GadShape ,
  GadDescriptionOfVelocity , ExtendedTime , Duration , Period ,
  FullDateString , MultiDimensionalArrayColumnMajorOrder , HintThatIndicatesAnAdditionalLevelOfIndirection , Capture ,
  IdentifierForAFhirConstant , ExternalReference , ConfidentialityClearance , MetadataBinding ,
  CollectionOfNcmsMetadataElements , SingleComplexNumber , ArrayOfComplexNumbersInInterleavedForm , PlatformVIsId ,
  PlatformVIsName , PlatformVIsValue , PlatformVHasCompositeValue , PlatformVHasMappedValue ,
  PlatformVHasObjId , PlatformVHasObjTag , PlatformVHasChild , PlatformVHasProperty ,
  PlatformVHasMeta , PlatformVHasEvent , PlatformVHasAction , PlatformVIsType ,
  SelfDescribedCbor , FileContainsCborSequences , FileStartsWithACborLabeledNonCborDataLabel , CompressedByteString ,
  SetOfRecordStructures , RecordStructure , ArrayOfAttestationEvidenceDataWithIntelTeeQuote , ArrayOfAttestationEvidenceDataWithIntelTeeReport ,
  ArrayOfAttestationEvidenceDataWithIntelSgxReport , RainsMessage , CborEncodedOpenswanConfigurationFile , ConciseSoftwareIdentifier ,
  ArrayOfContentAddressedBlocksAndErisReadCapabilities , IntelFpgaSpdmManifest
}
 A CBOR data item tag. More...
 

Functions

auto throwRangeError () -> void
 Throws an exception denoting a range error in a CBOR stream.
 
auto throwCorruptDataError () -> void
 Throws an exception denoting a corrupt data error in a CBOR stream.
 
constexpr auto operator== (std::size_t size, IndefiniteTag tag) noexcept -> bool
 Checks whether a length value represents an indefinite length array or map.
 

Variables

constexpr NullTag kNull
 A marker for special CBOR value 22 (null)
 
constexpr UndefinedTag kUndefined
 A marker for special CBOR value 23 (undefined)
 
constexpr BreakTag kBreak
 A marker for special CBOR value 31 (break)
 
constexpr IndefiniteTag kIndefinite
 A helper object used to determine whether an array or a map has indefinite length.
 

Detailed Description

CBOR encoder and decoder.

This namespace contains functionality related to C++ coroutines.

Enumeration Type Documentation

◆ AlternativeValue

A class for alternatives values.

◆ DataType

enum class xentara::utils::cbor::DataType
strong

A fundamental CBOR data type.

These data types mostly correspond to CBOR major types. However, CBOR uses major type 7 to hold both floating point numbers, and so called “simple values” (see section 3.3 of RFC 8949). This enum defines separate enum values for the different uses of major type 7, however, to make handling major type 7 easier.

Include file
#include <xentara/utils/cbor/DataType.hpp>
Enumerator
Null 

Null (Major type 7, additional information value 22)

UnsignedInteger 

Usigned integer (Major type 0)

NegativeInteger 

Negative integer (Major type 1)

FloatingPoint 

Floating-point number (Major type 7, additional information values 25 to 27)

Boolean 

Boolean (Major type 7, additional information values 20 and 21)

TextString 

Text string encoded as UTF-8 (Major type 3)

ByteString 

Byte string (Major type 2)

Array 

CBOR array (Major type 4)

Map 

CBOR map (Major type 5)

Tag 

CBOR data item tag (Major type 6)

See also
section 3.4 of RFC 8949.
Undefined 

Undefined (Major type 7, additional information value 23)

See also
section 5.7 of RFC 8949.
SimpleValue 

Unassigned simple value (Major type 7, additional information values 0 to 19 and 32 to 255)

Break 

Break (Major type 7, additional information value 31)

See also
section 3.2.1 of RFC 8949.

◆ SimpleValue

A class for simple values.

Include file
#include <xentara/utils/cbor/SimpleValue.hpp>
Enumerator
False 

Represents the boolean value false

True 

Represents the boolean value true

Null 

Represents a CBOR null value.

Undefined 

Represents a undefined CBOR value.

See also
section 5.7 of RFC 8949.

◆ Tag

A CBOR data item tag.

Include file
#include <xentara/utils/cbor/DataType.hpp>
See also
section 3.4 of RFC 8949.
Concise Binary Object Representation (CBOR) Tags at iana
Enumerator
StandardDateTimeString 

Standard date/time string.

EpochBasedDateTime 

Epoch-based date/time.

PositiveBignum 

Positive bignum.

NegativeBignum 

Negative bignum.

DecimalFraction 

Decimal fraction.

Bigfloat 

Bigfloat.

CoseSingleRecipientEncryptedDataObject 

COSE Single Recipient Encrypted Data Object.

CoseMacWithoutRecipientsObject 

COSE Mac w/o Recipients Object.

CoseSingleSignerDataObject 

COSE Single Signer Data Object.

CoseStandaloneV2Countersignature 

COSE standalone V2 countersignature.

ExpectedConversionToBase64urlEncoding 

Expected conversion to base64url encoding.

ExpectedConversionToBase64Encoding 

Expected conversion to base64 encoding.

ExpectedConversionToBase16Encoding 

Expected conversion to base16 encoding.

EncodedCborDataItem 

Encoded CBOR data item.

ReferenceTheNthPreviouslySeenString 

reference the nth previously seen string

SerialisedPerlObjectWithClassnameAndConstructorArguments 

Serialised Perl object with classname and constructor arguments.

SerialisedLanguageIndependentObjectWithTypeNameAndConstructorArguments 

Serialised language-independent object with type name and constructor arguments.

MarkValueAsPotentiallyShared 

mark value as (potentially) shared

ReferenceNthMarkedValue 

reference nth marked value

RationalNumber 

Rational number.

AbsentValueInACborArray 

Absent value in a CBOR Array.

Uri 

URI.

Base64url 

base64url

Base64 

base64

RegularExpression 

Regular expression.

MimeMessage 

MIME message.

BinaryUuid 

Binary UUID ([RFC4122, Section 4.1.2])

LanguageTaggedString 

Language-tagged string.

Identifier 

Identifier.

MultiDimensionalArrayRowMajorOrder 

Multi-dimensional Array, row-major order.

HomogeneousArray 

Homogeneous Array.

IpldContentIdentifier 

IPLD content identifier.

YangBitsDatatype 

YANG bits datatype.

YangEnumerationDatatype 

YANG enumeration datatype.

YangIdentityrefDatatype 

YANG identityref datatype.

YangInstanceIdentifierDatatype 

YANG instance-identifier datatype.

YangSchemaItemIdentifier 

YANG Schema Item iDentifier (sid)

Ipv4 

IPv4, [prefixlen,IPv4], [IPv4,prefixpart].

Ipv6 

IPv6, [prefixlen,IPv6], [IPv6,prefixpart].

CborWebToken 

CBOR Web Token (CWT)

EncodedCborSequence 

Encoded CBOR Sequence [RFC8742].

Uint8TypedArray 

uint8 Typed Array

Uint16BigEndianTypedArray 

uint16, big endian, Typed Array

Uint32BigEndianTypedArray 

uint32, big endian, Typed Array

Uint64BigEndianTypedArray 

uint64, big endian, Typed Array

Uint8TypedArrayClampedArithmetic 

uint8 Typed Array, clamped arithmetic

Uint16LittleEndianTypedArray 

uint16, little endian, Typed Array

Uint32LittleEndianTypedArray 

uint32, little endian, Typed Array

Uint64LittleEndianTypedArray 

uint64, little endian, Typed Array

Sint8TypedArray 

sint8 Typed Array

Sint16BigEndianTypedArray 

sint16, big endian, Typed Array

Sint32BigEndianTypedArray 

sint32, big endian, Typed Array

Sint64BigEndianTypedArray 

sint64, big endian, Typed Array

Sint16LittleEndianTypedArray 

sint16, little endian, Typed Array

Sint32LittleEndianTypedArray 

sint32, little endian, Typed Array

Sint64LittleEndianTypedArray 

sint64, little endian, Typed Array

Ieee754Binary16BigEndianTypedArray 

IEEE 754 binary16, big endian, Typed Array.

Ieee754Binary32BigEndianTypedArray 

IEEE 754 binary32, big endian, Typed Array.

Ieee754Binary64BigEndianTypedArray 

IEEE 754 binary64, big endian, Typed Array.

Ieee754Binary128BigEndianTypedArray 

IEEE 754 binary128, big endian, Typed Array.

Ieee754Binary16LittleEndianTypedArray 

IEEE 754 binary16, little endian, Typed Array.

Ieee754Binary32LittleEndianTypedArray 

IEEE 754 binary32, little endian, Typed Array.

Ieee754Binary64LittleEndianTypedArray 

IEEE 754 binary64, little endian, Typed Array.

Ieee754Binary128LittleEndianTypedArray 

IEEE 754 binary128, little endian, Typed Array.

CoseEncryptedDataObject 

COSE Encrypted Data Object.

CoseMacedDataObject 

COSE MACed Data Object.

CoseSignedDataObject 

COSE Signed Data Object.

NumberOfDaysSinceTheEpochDate 

Number of days since the epoch date 1970-01-01.

GeographicCoordinates 

Geographic Coordinates.

GeographicCoordinateReferenceSystemWktOrEpsgNumber 

Geographic Coordinate Reference System WKT or EPSG number.

RelativeObjectIdentifier 

relative object identifier (BER encoding); SDNV [RFC6256] sequence

ObjectIdentifier 

object identifier (BER encoding)

ObjectIdentifierRelativeTo1_3_6_1_4_1 

object identifier (BER encoding), relative to 1.3.6.1.4.1

InternetOfThingsDataPoint 

Internet of Things Data Point.

MarkValueAsHavingStringReferences 

mark value as having string references

BinaryMimeMessage 

Binary MIME message.

MathematicalFiniteSet 

Mathematical finite set.

MapDatatypeWithKeyValueOperations 

Map datatype with key-value operations (e.g. .get()/.set()/.delete())

NetworkAddress 

Network Address (IPv4 or IPv6 or MAC Address) (DEPRECATED in favor of 52 and 54 for IP addresses)

NetworkAddressPrefix 

Network Address Prefix (IPv4 or IPv6 Address + Mask Length) (DEPRECATED in favor of 52 and 54 for IP addresses)

EmbeddedJsonObject 

Embedded JSON Object.

HexadecimalString 

Hexadecimal string.

DecimalFractionWithArbitraryExponent 

Decimal fraction with arbitrary exponent.

BigfloatWithArbitraryExponent 

Bigfloat with arbitrary exponent.

InternationalizedResourceIdentifier 

Internationalized resource identifier (IRI)

InternationalizedResourceIdentifierReference 

Internationalized resource identifier reference (IRI reference)

ExtendedDecimalFraction 

Extended decimal fraction.

ExtendedBigfloat 

Extended bigfloat.

ExtendedRationalNumber 

Extended rational number.

DotsSignalChannelObjectAsDefinedIn 

DDoS Open Threat Signaling (DOTS) signal channel object, as defined in [RFC9132].

NonUtf8Cesu8String 

Non-UTF-8 CESU-8 string.

NonUtf8Wtf8String 

Non-UTF-8 WTF-8 string.

NonUtf8Mutf8String 

Non-UTF-8 MUTF-8 string.

MapContainsOnlyKeysThatAreOfTypeTextString 

Map contains only keys that are of type Text String (major type 3)

ErisBinaryReadCapability 

ERIS binary read capability.

GadShape 

Universal Geographical Area Description (GAD) shape.

GadDescriptionOfVelocity 

Universal Geographical Area Description (GAD) description of velocity.

ExtendedTime 

extended time

Duration 

duration

Period 

period

FullDateString 

[RFC3339] full-date string

MultiDimensionalArrayColumnMajorOrder 

Multi-dimensional Array, column-major order.

HintThatIndicatesAnAdditionalLevelOfIndirection 

hint that indicates an additional level of indirection

Capture 

Capture [3].

IdentifierForAFhirConstant 

Identifier for a FHIR constant.

ExternalReference 

External reference.

ConfidentialityClearance 

A confidentiality clearance. The key value pairs of the map are defined in ADatP-4774.4.

MetadataBinding 

A metadata binding. The elements of the array are defined in AdatP-4778.5. The tag is also used as part of the magic number in on-disk detached and encapsulating bindings.

CollectionOfNcmsMetadataElements 

A collection of NCMS metadata elements. The key value pairs of the map are defined in AdatP-5636.4.

SingleComplexNumber 

Single complex number: array elements are real (I) and imaginary (Q) components.

ArrayOfComplexNumbersInInterleavedForm 

Array of complex numbers in interleaved form: complex value k is stored with real (I) part at array index 2k and imaginary (Q) part at index (2k + 1)

PlatformVIsId 

PlatformV_IS_ID.

PlatformVIsName 

PlatformV_IS_NAME.

PlatformVIsValue 

PlatformV_IS_VALUE.

PlatformVHasCompositeValue 

PlatformV_HAS_COMPOSITE_VALUE.

PlatformVHasMappedValue 

PlatformV_HAS_MAPPED_VALUE.

PlatformVHasObjId 

PlatformV_HAS_OBJ_ID.

PlatformVHasObjTag 

PlatformV_HAS_OBJ_TAG.

PlatformVHasChild 

PlatformV_HAS_CHILD.

PlatformVHasProperty 

PlatformV_HAS_PROPERTY.

PlatformVHasMeta 

PlatformV_HAS_META.

PlatformVHasEvent 

PlatformV_HAS_EVENT.

PlatformVHasAction 

PlatformV_HAS_ACTION.

PlatformVIsType 

PlatformV_IS_TYPE.

SelfDescribedCbor 

Self-described CBOR.

FileContainsCborSequences 

indicates that the file contains CBOR Sequences

FileStartsWithACborLabeledNonCborDataLabel 

indicates that the file starts with a CBOR-Labeled Non-CBOR Data label.

CompressedByteString 

Compressed byte string.

SetOfRecordStructures 

Identify and define a set of record structures (each a sequence of property names) that can be referenced as tags in the included value (and the scope for the record tag definitions)

RecordStructure 

Identify and define a record structure (a sequence of property names), and use that record structure definition to interpret the included values.

ArrayOfAttestationEvidenceDataWithIntelTeeQuote 

The tagged CBOR array contains attestation evidence data with an Intel TEE quote.

ArrayOfAttestationEvidenceDataWithIntelTeeReport 

The tagged CBOR array contains attestation evidence data with an Intel TEE report.

ArrayOfAttestationEvidenceDataWithIntelSgxReport 

The tagged CBOR array contains attestation evidence data with an Intel SGX report.

RainsMessage 

RAINS Message.

CborEncodedOpenswanConfigurationFile 

A CBOR encoded Openswan configuration file, as stored on disk for unit test cases.

ConciseSoftwareIdentifier 

Concise Software Identifier (CoSWID)

ArrayOfContentAddressedBlocksAndErisReadCapabilities 

Array of content-addressed blocks and ERIS read capabilities.

IntelFpgaSpdmManifest 

Intel FPGA SPDM Manifest.

Function Documentation

◆ operator==()

constexpr auto xentara::utils::cbor::operator== ( std::size_t  size,
IndefiniteTag  tag 
) -> bool
constexprnoexcept

Checks whether a length value represents an indefinite length array or map.

Include file
#include <xentara/utils/cbor/Types.hpp>
Parameters
sizeThe length of the array, as returned by Array::Size() or MapHeader::size().
tagAlways pass kIndefinite as this parameter
Returns
Rteurns true if size represents an indefinite length, or false if it represents a definite length.

◆ throwCorruptDataError()

auto xentara::utils::cbor::throwCorruptDataError ( ) -> void

Throws an exception denoting a corrupt data error in a CBOR stream.

◆ throwRangeError()

auto xentara::utils::cbor::throwRangeError ( ) -> void

Throws an exception denoting a range error in a CBOR stream.

Variable Documentation

◆ kBreak

constexpr BreakTag xentara::utils::cbor::kBreak
constexpr

A marker for special CBOR value 31 (break)

This marker is used to read and write special value 31 (break) from or to a CBOR stream

Include file
#include <xentara/utils/cbor/Manipulators.hpp>
See also
section 3.2.1) RFC 8949.

◆ kIndefinite

constexpr IndefiniteTag xentara::utils::cbor::kIndefinite
constexpr

A helper object used to determine whether an array or a map has indefinite length.

This object can be used to construct arrays and maps of indefinite length. It can also be compared to and std::size_t to determine if it represents the length of an indefinite length array or map.

Include file
#include <xentara/utils/cbor/Types.hpp>
See also
Array
MapHeader
section 3.2.2 of RFC 8949.

◆ kNull

constexpr NullTag xentara::utils::cbor::kNull
constexpr

A marker for special CBOR value 22 (null)

This marker is used to read and write special value 22 (null) from or to a CBOR stream

Include file
#include <xentara/utils/cbor/Manipulators.hpp>

◆ kUndefined

constexpr UndefinedTag xentara::utils::cbor::kUndefined
constexpr

A marker for special CBOR value 23 (undefined)

This marker is used to read and write special value 23 (undefined) from or to a CBOR stream

Include file
#include <xentara/utils/cbor/Manipulators.hpp>
See also
section 5.7 of RFC 8949.