My task is to call the C API functions with some complex data which comes in text form over the network. One may think of some form of RPC. The functions are called very frequently, therefore the performance requirements are very strict. Currently I directly parse the input stream to the corresponding POD structure with manually written parser. The problem is that this parser is huge. And yes, sometimes I find bugs in it. I would like to try to switch to boost in order to decrease the complexity of my code. Hopefully I could also increase the performance in case I could use the memory pools. In current solution adding such a complexity looks daunting taking into account that all this is multithreaded.
The simplified input data looks like functionName({x,x,x,{x,x,x},<null>,x})
where each x
is a primitive value of some type or a text string (represented like "blah"
or <null>
). Each missing structure is represented by <null>
.
The output data is a POD structure. In case of string or nested structure as a field, the pointer to the allocated data is stored in the outer one. It could be null in case the value is missing.
Digging through the SO answers and through the boost documentation I could not find how to accomplish this task efficiently, i.e. without rebuilding the structure into POD after parsing it into some internal "boost-friendly" form.
So again, repeating the subject, the question is how to parse the nested POD structures which have pointers?
Any help is appreciated.