L
L
leanid2012-08-24 20:13:39
C++ / C#
leanid, 2012-08-24 20:13:39

Are there any libraries that allow you to serialize an object as C++ code for creating it?

I have a vector of a bunch of classes that are loaded from configs, I want to serialize them all into classes so that I can then rebuild the program directly with them without loading configs. Those. there were a hundred config objects, a hundred classes config_01, config_02 appeared ... so that they could then simply be compiled in the program. Are there any libraries that will make this task easier?

Let me explain, because made difficult.
There are 100 objects of the same class (c++) all loaded from xml with different parameters. I want to serialize each object not back to xml, but to the C++ code for its creation, so that later I can rebuild the program with additional files and get 100 necessary objects without loading from xml. I hope that's clearer.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nile1, 2012-08-24
@nile1

some crazy task.
I think you have serious problems understanding OOP. at least you are confusing the concept of "class" and "object" (an instance of a class), this can be seen from the phrase "I have a vector of a heap of classes."
Obviously, you will not find a ready-made solution for solving such a problem.
I will rephrase, as I understood the task that solves your problem (compiled configs). the base abstract class (a la "interface") is one in which a set of configs ("properties") is declared. and many class heirs that implement the "interface" through constants. in fact, even in this form it is not clear to me why this might be needed, but at least there is some logic.
Or do you need to access a specific config in your code, like config_01.property1, config_07.property6? very strange task.

A
Andrew, 2012-08-24
@xaoc80

You can look at the google protobuf side

S
sdevalex, 2012-08-24
@sdevalex

Use Qt, more precisely QObject ... it allows itself to be serialized (we generate metadata MOC)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question