Menu

basic_record_ostream interface

2013-11-26
2013-11-26
  • Dmitry Sokolov

    Dmitry Sokolov - 2013-11-26

    Hello!

    I guess it could be useful to add own stream operators in basic_record_ostream. Template forward to base + manips, just to keep record_ostream reference through streaming sequence.
    This would allow to write stream based direct log record modifiers, i.e. attribute assignment:

    record_ostream& operator<<(record_ostream& os, const add_very_special_attribute& attr)
    {
        log_record rec = os.get_record(); // add get_record_no_flush()?
        // add some very special attribute
        rec.attribute_values().insert(...);
        return os;
    }
    ...
    LOG << "AAA" << add_very_special_attribute(...);
    

    Though... now it can be done with upcast from basic_formatting_ostream.

     
  • Andrey Semashev

    Andrey Semashev - 2013-11-26

    You can use the add_value manipulator, although it should be in the beginning of the streaming expression.

     
  • Dmitry Sokolov

    Dmitry Sokolov - 2013-11-26

    Anyway this doesn't lessen modification utility.
    Apropos in case of add_value stream flush in get_record is also not obligatory.

     

Log in to post a comment.