mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-20 07:09:22 +08:00
rtems-utils.h: Create ostream_guard
This commit is contained in:
@@ -47,6 +47,26 @@ namespace rtems
|
|||||||
bool real = false,
|
bool real = false,
|
||||||
size_t line_length = 16,
|
size_t line_length = 16,
|
||||||
uint32_t offset = 0);
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user