Skip to content

Add library support for reading and writing raw CBOR tags #585

@danielaparker

Description

@danielaparker

My workarounds (for simple data) so far ...

Encoding example:

vector<uint8_t> data;
cbor::cbor_bytes_encoder encoder(data);
encoder.begin_array(1);
encoder.flush();
data.push_back(0xC1);   // tag value
encoder.uint64_value(1);  // actual data value
encoder.end_array();
encoder.flush();

Decoding (simplified) example:

cbor::cbor_bytes_cursor cursor(data);
cursor.next();
if (*(data.data() + cursor.column() - 2) == 0xC1) {
  // expected tag
  uint64_t myDataValue = cursor.current().get<uint64_t>();
}

I don't know whether there is a better way to deal with it, for me this seems to be sufficient at the moment.

Originally posted by @Pique7 in #567 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions