diff options
author | Ryan Long <ryan.long@oarcorp.com> | 2021-07-20 09:51:34 -0400 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2021-07-27 13:40:40 -0500 |
commit | 68348ad39f44255087d9aa3edcd9d91f935e9db6 (patch) | |
tree | 07bc477e447e75a9bee50563a3ccb8fc76362ac8 /rtemstoolkit | |
parent | AddressToLineMapper.h: Remove pointer to temporary string (diff) | |
download | rtems-tools-68348ad39f44255087d9aa3edcd9d91f935e9db6.tar.bz2 |
rtems-utils.h: Create ostream_guard
Diffstat (limited to 'rtemstoolkit')
-rw-r--r-- | rtemstoolkit/rtems-utils.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/rtemstoolkit/rtems-utils.h b/rtemstoolkit/rtems-utils.h index 4ce9c68..81bf913 100644 --- a/rtemstoolkit/rtems-utils.h +++ b/rtemstoolkit/rtems-utils.h @@ -47,6 +47,26 @@ namespace rtems bool real = false, size_t line_length = 16, uint32_t offset = 0); + + /* + * Save and restore the output stream's settings. + */ + struct ostream_guard { + std::ostream& o; + std::ios_base::fmtflags flags; + + ostream_guard (std::ostream& o_) + : o (o_), + flags (o_.flags ()) + { + } + + ~ostream_guard () + { + o.flags(flags); + } + }; + } } |