0

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

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
Nikhil J Joshi
  • 1,177
  • 2
  • 12
  • 25

1 Answers1

1

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

Alex Wilson
  • 6,690
  • 27
  • 44
  • I like the "all-parameters-at-one-place" method, for then I can quickly make changes at one place. And adding this header, I could make the parameters globally available. I am considering boost::program_options right now. However, I am unable to figure out how to make one parameter declared in one class available to other, while not including the headers. I would really appreciate if you could help me giving some example on how to make variables accessible across different classes? - Nikhil – Nikhil J Joshi Jun 19 '12 at 21:12