Menu

Set_open_handler

2012-11-07
2013-06-03
  • Sebastian Videc

    Sebastian Videc - 2012-11-07

    I'm  trying to use the Set_open_handler function but I neither understand it nor find a suitable example. In the documentation a lambda  function is used:

    backend->set_open_handler(_1 << "<?xml version=\"1.0\"?>\n<log>\n");
    

    But I'd like to use a "real" one to generate a individual intro for each new file. How should a function look like to return a string to satisfy Set_open_handler / Set_close_handler.
    Does anyone have an example I understand?

    Thank you
    Sebastian

     
  • Andrey Semashev

    Andrey Semashev - 2012-11-07

    The callback you install with set_open/close_handler should have the following signature:

    void (stream_type&)
    

    Where stream_type is a typedef within the sink backend and essentially is std::ostream or std::wostream. The callback should put the file header/footer to the provided stream.

     
  • Sebastian Videc

    Sebastian Videc - 2012-11-07

    Thank you for the quick response. It works perfect now. Much easier than expected.

     

Log in to post a comment.