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

text format serialization and deserialization #8

Open
timotheecour opened this issue May 8, 2018 · 1 comment
Open

text format serialization and deserialization #8

timotheecour opened this issue May 8, 2018 · 1 comment

Comments

@timotheecour
Copy link
Contributor

timotheecour commented May 8, 2018

text format is very useful for debugging, or for cross language, human readable,, type safe, configuration files:

https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.text_format

example of text format

https://github.com/BVLC/caffe/blob/master/models/bvlc_reference_caffenet/solver.prototxt

usage

let message = newTest1()
message.a = 150

## serialize
let data = protoToText(message)
echo data # a : 150
echo message # would use `$` as alias to serializeText

## deserialize
let message2 = Test1.deserializeText(data)
assert message2 == message

## serialize with option
let data = serializeText(message, oneline = false)

WORKAROUND

same as msoucy/dproto#71 (comment) : shell out to protoc eg:

## serializeText
serialize message to /tmp/z01.pb
protoc --decode=Test1 --proto_path=tests/t29_nimpb/ tests/t29_nimpb/test1.proto < /tmp/z01.pb > /tmp/z01.txt
read /tmp/z01.txt

## deserializeText
TODO

workaround is not great, as not as efficient, and requires passing the proto file; the proper solution should involve using reflection

@oskaritimperi
Copy link
Owner

This could be a nice addition. Need to take a look at some point.

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

No branches or pull requests

2 participants