Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Script generation from Objects using C++

Script generation from Objects using C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++designtoolstutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FrankStar89
    wrote on last edited by
    #1

    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,

    CPalliniC L 2 Replies Last reply
    0
    • F FrankStar89

      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,

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Make the object classes inherit from a common interface exposing, say, a toString method an d then call it on all the object instances.

      In testa che avete, signor di Ceprano?

      F 1 Reply Last reply
      0
      • F FrankStar89

        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,

        L Offline
        L Offline
        leon de boer
        wrote on last edited by
        #3

        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

        F 1 Reply Last reply
        0
        • CPalliniC CPallini

          Make the object classes inherit from a common interface exposing, say, a toString method an d then call it on all the object instances.

          F Offline
          F Offline
          FrankStar89
          wrote on last edited by
          #4

          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.

          CPalliniC 1 Reply Last reply
          0
          • L leon de boer

            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

            F Offline
            F Offline
            FrankStar89
            wrote on last edited by
            #5

            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)

            1 Reply Last reply
            0
            • F FrankStar89

              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.

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              If chains can be avoided, if feasible, leveraging on polymorphism.

              In testa che avete, signor di Ceprano?

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups