I have a C++ project in which I provide to the application a text file, that run-time is…
- User
I have a C++ project in which I provide to the application a text file, that run-time is parsed and analyzed. If no exceptions are thrown, the application runs applying the content of the text file. As a very general example, the application is more complex, however in the text file can be written 1, 2, or 3 and the application will run a function that corresponds to that id. So, essentially it is a code the parses an input and do something consequently. The code is OO and used polymorphism and inheritance. I am looking if something can be changed such that I can pass part of the code from run-time to compile-time, so uses more features of C++, especially the ones based on Compiler support. This should also reduce the issues related to virtual functions and run-time exceptions. However, the only idea I had is to parse the input, generate a C++ source code and then compile that one. Basically, to write C++ source code as an intermediary source code based on the input. However, it seems a huge task and I feel that I am overkilling the issue. Please provide any feedback on it. Additionally, if you know any alternative to it, or if it exists design pattern or other methodology to solve it, please provide them.
- Assistant
- User
Yes, the text files can only be determined at run-time. For this reason, apart generate C++ from that, I think there are few alternatives that I can use. However, consider the following case. I have an interface that is Interface, then I have several Derived class. I use then smart pointers to handle from the text files which to allocate. Are there alternatives in C++ to this practice that have some benefits to smooth the transition to compile-time?
- Assistant
- User
How much can be difficult to translate the input file in a C++ source code? Of course, it depends on the input file, however I am more interested in understanding the general issues that can be found during this task.
- Assistant