Menu

#7 req: support for output to stream

open
7
2012-10-02
2008-01-13
No

the printf method is nice but i want to be able to output the whole options db for logging purposes. as a hack I moved STRING_VECTOR argv; to the public section so I could do that but I'm sure there's a more elegant way. I'm programming in c++ so I wanted to use "<<", but something that could be used in C also would be nice.

Discussion

  • Frank-Rene Schäfer

    Logged In: YES
    user_id=278191
    Originator: NO

    There is a member function 'print' which should do the
    charm. It's been a while that I went through the code.
    I'll look at it as soon as possible. Is it correct, that you
    want the output written in a format that allows GetPot's
    configuration file reader to parse it immediately?

    Best Regards

    Frank

     
  • Marc Lindahl

    Marc Lindahl - 2008-01-14

    Logged In: YES
    user_id=619807
    Originator: YES

    yes there's a print (i mistakenly called it printf above), but it's hardwired to output to stdout. So you can't really use it with cout, and especially can't use it with any old text output stream (I wanted to send it to a log file). I don't really care about being able to re-parse it although the print() output looks like it would. I'm using it in a benchmarking program and I want to document the options used in the benchmark in the log. (btw, great package, thanks!)

     
  • Frank-Rene Schäfer

    Logged In: YES
    user_id=278191
    Originator: NO

    Sorry for the delay. I did not get my hands on the code
    yesterday. For the moment, I'd propose, to introduce an optional
    argument with a pointer to a ios::ostream that is used for output.
    The step from there to the operator<<(...) is a no-brainer anyway.
    Paste some code, if you've done something in this direction.
    Hopefully, I'll get some stuff done today.

    Best Regards

    Frank

     
  • Frank-Rene Schäfer

    Logged In: YES
    user_id=278191
    Originator: NO

    Sorry for the delay. I did not get my hands on the code
    yesterday. For the moment, I'd propose, to introduce an optional
    argument with a pointer to a ios::ostream that is used for output.
    The step from there to the operator<<(...) is a no-brainer anyway.
    Paste some code, if you've done something in this direction.
    Hopefully, I'll get some stuff done today.

    Best Regards

    Frank

     
  • Marc Lindahl

    Marc Lindahl - 2008-01-21

    Logged In: YES
    user_id=619807
    Originator: YES

    i pretty much hacked it...
    in your source I moved the STRING_VECTOR argv up to a public declaration then in my code (where my GetPot instance is called ifile and EOL is a macro for std::endl:

    STRING_VECTOR::const_iterator it = ifile.argv.begin();
    report << "Config filename = ";
    for(; it != ifile.argv.end(); it++)
        report << *it << EOL;
    
     

Anonymous
Anonymous

Add attachments
Cancel