How to visualize data from google protocol buffer?

2019-03-14 14:40发布

问题:

I would like to store data using google protocol buffers (another serialized format would work, too), and then have an UI to browse that data. Is there a C++ framework/API that would allow me to do this?

For example, it could use the reflection interface of protobuf, and then fill in the data into Qt's QTableView (or from another toolkit). I could write such code myself -- however, much rather I would re-use existing code, which is why I am asking for advice here!

Or are there more general UI toolkits that can visualize data which is accessible via some reflection API?

回答1:

One GUI I just came across is protobufeditor -- it seems pretty powerful for browsing generic data. It is written in Java, so one cannot easily use/extend it from C++. (And it is not particularly polished at this point, e.g., one needs to maximize the main window to get a semi-useful layout of the sub-windows.) So this is a rather temporary solution.



回答2:

Wireshark has a protobuf plugin that lets you visualize the contents of protobuf messages. I'd also dig in to the DebugString() in google/protobuf/message.h or message_lite.h (I forget which off the top of my head) and see if you can easily dress that up for presentation to a user.

http://code.google.com/p/protobuf-wireshark/



回答3:

If you want to write it yourself, one option could be to use Python/PySide together with QML, process your data and store it in a QAbstractListModel which is connected to your QML ListView. Depending on the complexity of your data, the list view delegate should hopefully be able to visualize it.

This question might be useful in that case: How to provide data from PySide QAbstractItemModel subclass to QML ListView?

If XML is an option, the QML XmlListModel is very neat and easy to use.



回答4:

I was working on such a solution last year using Qt. Unfortunately, the application is not yet complete, but I think I was at the point where one could more or less successfully visualize data from a generic protocol buffer stream. You can check out the code at

https://github.com/oneamtu/QProtoViewer

Again this is not a out-of-the-box solution, and you'll have to work to make it fit your own needs/project. I'd be more than happy to help if you choose to do so.



回答5:

One option is Protocol Buffer Workbench. A nice feature with this tool is that you can use it to easily convert JSON to an encoded protocol buffer and vice versa.



回答6:

Hope this app can help you [Only for macOS]

https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/1165908879/osx/versioninfo/deliverable



回答7:

If you want you can use web ui to compose a protobuf message

https://github.com/Groterik/protobuf-webui

It is python project and it has a sample that executes http server composing desired message type of imported protobuf module. But it is python, so you can write simple workaround that imports compiled protobuf module dynamically and chooses message type in runtime.

You can overload postprocessing method so it would do some useful work with message (store to file, send by network, etc)



回答8:

To resolve binary representation without schema is hard. But if you'd like just to have a better view of pb's text format or DebugString(), you can try the Protobuf Visualizer:

http://codingstory.com/pv