writing parameters to a file from a (declaration) header
-
15-06-2021 - |
문제
I wish to write the list of all parameter values used for the current run to a parameterFile.txt
in the output directory.
I have all the parameters declared in one of the header files say constants.hpp
. I was trying the boost::filesystem copy_file
method to merely copy the whole header "as-is" to a text file. The problem however is that if running on a remote machine, the header file is obviously not available for copying. And I do agree that dumping parameter values this way is stupid (when I can just put the header in the output).
Is there a better method to do so?
TIA, Nikhil
해결책
Instead of storing your parameter values in a header file, have you considered passing them in at runtime?
I see you are already using boost. Boost program options may fit your needs particularly well, because as well as allowing you to specify options on the command line - you can also put all your options in a configuration file and then run your code against this.
See here: http://www.boost.org/doc/libs/1_49_0/doc/html/program_options.html