libbio
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
bio::physical::CborAxis Class Reference

#include <CborAxis.h>

Inheritance diagram for bio::physical::CborAxis:
Inheritance graph
[legend]
Collaboration diagram for bio::physical::CborAxis:
Collaboration graph
[legend]

Public Member Functions

 CborAxis ()
 
virtual ~CborAxis ()
 
virtual Pointer< SymmetryRotate (std::string encoded) const
 
virtual ::std::string Rotate (Pointer< const Symmetry > symmetry) const
 
virtual Pointer< SymmetryRotate (std::string) const
 
- Public Member Functions inherited from bio::physical::Axis
 Axis ()
 
virtual ~Axis ()
 
virtual ::std::string Rotate (Pointer< const Symmetry > symmetry) const
 
virtual ::std::string operator| (Pointer< Wave > particle) const
 
virtual Pointer< Symmetryoperator() (std::string encoded) const
 

Protected Member Functions

virtual ::std::string Encode (Pointer< const Symmetry > symmetry) const
 
- Protected Member Functions inherited from bio::physical::Axis
virtual ::std::string Encode (Pointer< const Symmetry > symmetry) const
 

Additional Inherited Members

- Static Public Member Functions inherited from bio::physical::Axis
::std::string Failed ()
 

Detailed Description

Raw CBOR Axis which maps canonical Symmetry kinds directly to RFC 8949 CBOR.

Kind mapping:
Null -> 0xf6
Bool -> 0xf4 / 0xf5
SignedInt -> major 0 if >= 0, major 1 if < 0
UnsignedInt -> major 0
Float32 -> shortest-form float (half 0xf9, else 0xfa)
Float64 -> shortest-form float (half 0xf9, else 0xfa, else 0xfb)
Text -> major 3
Bytes -> major 2
Simple -> major 7 simple value
Array -> major 4
Map -> major 5 (MapEntry children flattened to k,v pairs in insertion order)
Tag -> major 6 + wrapped value child

Integer lengths are encoded length-minimally. Floats are emitted in the shortest CBOR form that losslessly preserves the stored value, per RFC 8949 §4.2.2 — Float64 narrows to Float32 and then to half-precision when the round-trip is exact, and NaNs collapse to canonical half 0xf9 0x7e 0x00. On decode, half-precision values are materialised into a Float32 Symmetry slot. Map entries are emitted in bytewise lexicographic order of their deterministically-encoded keys, per RFC 8949 §4.2.1, so the wire output is spec-compliant deterministic CBOR regardless of the insertion order of the source Map's children.

The returned std::string is used as an opaque byte container and may contain embedded NUL bytes. Callers should use .size() rather than strlen().

Constructor & Destructor Documentation

◆ CborAxis()

bio::physical::CborAxis::CborAxis ( )

◆ ~CborAxis()

bio::physical::CborAxis::~CborAxis ( )
virtual

Member Function Documentation

◆ Encode()

std::string bio::physical::CborAxis::Encode ( Pointer< const Symmetry symmetry) const
protected

Encode a Symmetry to CBOR.

Parameters
symmetry
Returns
CBOR bytes or Failed().

◆ Rotate() [1/3]

std::string bio::physical::Axis::Rotate ( Pointer< const Symmetry symmetry) const

Express the given Symmetry into something intelligible by another system.

Parameters
symmetry
Returns
text, possibly a command (like mysql), structured values (like json), an entire program (like python), etc. or Failed().

◆ Rotate() [2/3]

Pointer< Symmetry > bio::physical::CborAxis::Rotate ( std::string  encoded) const
virtual

Decode CBOR bytes into a Symmetry.

Parameters
encodedCBOR bytes.
Returns
a new Symmetry or NULL on failure.

Reimplemented from bio::physical::Axis.

◆ Rotate() [3/3]

Pointer< Symmetry > bio::physical::Axis::Rotate ( std::string  ) const
virtual

Express the given text into something intelligible by this system.

Returns
Symmetry* which can be Reified or NULL.

Reimplemented from bio::physical::Axis.


The documentation for this class was generated from the following files: