Script generation from Objects using C++
-
Hello friends, I needed some hints/suggestion/brainstorm, so to go in a right direction. I have lot of different Objects, based on which I need to generate a Text-file. This text is nothing but a Scripting Language with some specific rules or grammars. ( Example, like a VB script ). A simple/legacy way could be, Iterate all the objects, and Append hard-coded text ( to a global string), with many if and else cases. Now, I am looking if any framework/design/principle is available, or I can make use of it, to make a clean design/code instead writing lot of if and else. One I found is boost karma, but looking for alternatives to make the best choice. Seeking your valuable advises. Thanks in advance,
-
Hello friends, I needed some hints/suggestion/brainstorm, so to go in a right direction. I have lot of different Objects, based on which I need to generate a Text-file. This text is nothing but a Scripting Language with some specific rules or grammars. ( Example, like a VB script ). A simple/legacy way could be, Iterate all the objects, and Append hard-coded text ( to a global string), with many if and else cases. Now, I am looking if any framework/design/principle is available, or I can make use of it, to make a clean design/code instead writing lot of if and else. One I found is boost karma, but looking for alternatives to make the best choice. Seeking your valuable advises. Thanks in advance,
-
Hello friends, I needed some hints/suggestion/brainstorm, so to go in a right direction. I have lot of different Objects, based on which I need to generate a Text-file. This text is nothing but a Scripting Language with some specific rules or grammars. ( Example, like a VB script ). A simple/legacy way could be, Iterate all the objects, and Append hard-coded text ( to a global string), with many if and else cases. Now, I am looking if any framework/design/principle is available, or I can make use of it, to make a clean design/code instead writing lot of if and else. One I found is boost karma, but looking for alternatives to make the best choice. Seeking your valuable advises. Thanks in advance,
Option B is to make a simple program to load them into a database either a standard spec or make your own format. If you need to do this a lot or need to edit and change the data and save it again then you are effectively dealing with a database you just don't realize it. Say for something like a game often you need leaderboards etc and if you want to deploy on a mobile app you really need to hit one of the cloud databases. So it depends a lot what you are trying to do. To really be able to give advice we need to know how often is the data accessed .. aka is speed of access an issue or alternatively is the data only ever read once and never touched again AKA its a straight load situation.
In vino veritas
-
Make the object classes inherit from a common interface exposing, say, a
toString
method an d then call it on all the object instances.Thank you for your advice. Sure it is part of the solution. I was looking more on making the script file ( that is the text of the scripts), as in how should I do that. Shall I simply make a hard-coded string with lot of if and else ( from the objects), and append them one by one, or do we have a fit design Pattern for this. Keeping in mind there would be some rules for the script generation, I would love to make it cleaner with some well design structure.
-
Option B is to make a simple program to load them into a database either a standard spec or make your own format. If you need to do this a lot or need to edit and change the data and save it again then you are effectively dealing with a database you just don't realize it. Say for something like a game often you need leaderboards etc and if you want to deploy on a mobile app you really need to hit one of the cloud databases. So it depends a lot what you are trying to do. To really be able to give advice we need to know how often is the data accessed .. aka is speed of access an issue or alternatively is the data only ever read once and never touched again AKA its a straight load situation.
In vino veritas
Thank you so much for your reply. FYI, there is no db involved, as at the time of making the script all the objects are already available in the memory. I just need to traverse them one by one, make the script out of it. Keeping in mind there would be rules to make the script, I wish I could do it in a cleaner way ( avoiding lot of if and else while making the text for the script)
-
Thank you for your advice. Sure it is part of the solution. I was looking more on making the script file ( that is the text of the scripts), as in how should I do that. Shall I simply make a hard-coded string with lot of if and else ( from the objects), and append them one by one, or do we have a fit design Pattern for this. Keeping in mind there would be some rules for the script generation, I would love to make it cleaner with some well design structure.