Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
danielaparker opened this issue Jan 23, 2025 · 1 comment
Closed

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

danielaparker opened this issue Jan 23, 2025 · 1 comment

Comments

@danielaparker
Copy link
Owner

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)

@danielaparker
Copy link
Owner Author

Writing and reading CBOR tags is supported 1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant