For example, if we have a JSON writing library. We want translate a protobuf message into a JSON version. And we would like to use protobuf and this JSON writing library to realize this idea. Then, for better performance, we will consider translating directly the message when parsing the message from the file. In this case, we then need a callback mechanism, which is that the parser can call back some unknown self-defined function to fill the parsed information directly into the correct data structure. If not, we will have to first of all parse the message into the protoc compiler generated data structure which is normally stored in the memory; then we translate this message from the generated data structure to a JSON writing library's data structure in order that the message can be written into JSON file afterwards. In this way, it will occupy 2 times the memory space which is not as efficient as the first method provided above. The question to know whether it is possible to call callback function in textformat parser.
Kind regards, Hao Le mercredi 10 septembre 2014 15:50:05 UTC+2, Hao HU a écrit : > > Hi All, > > Can we use callback function in the text format parser in order that the > parsing information can be easily stored into self-defined data structure? > As we know, if we define a protocol for the message that we need. We can > use the protocol buffer compiler to compile it to generate c++ code that > reads the textual format into generated data structure. > If we then need to fill the information of the data structure into another > corresponding data structure, could we let parsing steps provided by > TextFormat::parser to callback the function we newly defined to fill the > information into our desired data structure? > > Thanks ! > > kind regards, > > Hao Hu > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
