-
Notifications
You must be signed in to change notification settings - Fork 187
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 cbor_encode_cbor #162
Comments
The problem will be that we still need to decode and re-encode in order to keep the state in CborEncoder: it tries to keep the count of elements added, so it can tell you if you made a mistake. Copying without decoding would be only possible if the array or map has unknown length. Would that be acceptable? |
I was thinking about adding the cbor as a single value e.g.
I see that it will give some problems if the encoded cbor is containing multiple values. |
That we could easily do, yes. |
There is a tag for a Cbor byte string. Sometimes it is beneficial to carry an embedded CBOR data item that If we do use cbor encode cbor that tag should be used. |
Using a tag and a byte string is possible with the current api, but it was not the intended semantics with this request. So the name is probably not the best. |
Right, something like |
I'll like to vote for this feature. I have two use cases where i have a hard coded cbor map or array that i would like to put into a high level map. E.g., i have a framework that receives a request to query for capabilities. An application on top of this layers defines the capabilities array.
I realize this was quite a bad example. But i have maps and arrays defined elsewhere and want to write them into the encoder. |
This method allows for writing raw data directly to the encoding buffer. This can be useful if you have something stored as CBOR encoded data. Fixes intel#162. Signed-off-by: Tofik Sonono <tofiksonono@msn.com>
Hello. I tried to use TSonono solution and it gave me an error. What I am trying to do is. I want to add cbor tagged data into array. Please see my below code. It gave me an error when i try to close the container.
This is the code for cbor_encode_raw |
Your code is not correct, unless you're certain that the buffer you got contains exactly one item. What error did you get? |
This method allows for writing raw data directly to the encoding buffer. This can be useful if you have something stored as CBOR encoded data. Fixes intel#162. Signed-off-by: Tofik Sonono <tofiksonono@msn.com>
I propose adding a function which can encode encoded cbor into a CborEncoder.
Lets assume you have a system where chunks of data is encoded as cbor. If you are going to merge these chunks into a new cbor map they have to be decoded and then encoded again into the map. If instead one can just make a map and insert the binary cbor directly into this map then a decoding and reencoding is unneccessary.
CborError cbor_encode_cbor(CborEncoder* encoder, uint8_t* cbor, size_t size);
Regards, Michael
The text was updated successfully, but these errors were encountered: