1 // This file is part of the ustl library, an STL implementation.
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
9 #ifndef UIOSFUNC_H_730C16E316F7650E3A02E1C6611B789A
10 #define UIOSFUNC_H_730C16E316F7650E3A02E1C6611B789A
16 class ios
: public ios_base
{
18 /// \class align uiosfunc.h ustl.h
19 /// \ingroup StreamFunctors
20 /// \brief Stream functor to allow inline align() calls.
22 /// Example: os << ios::align(sizeof(uint16_t));
26 inline explicit align (size_t grain
= c_DefaultAlignment
) : m_Grain(grain
) {}
27 inline istream
& apply (istream
& is
) const { is
.align (m_Grain
); return (is
); }
28 inline ostream
& apply (ostream
& os
) const { os
.align (m_Grain
); return (os
); }
29 inline void read (istream
& is
) const { apply (is
); }
30 inline void write (ostream
& os
) const { apply (os
); }
31 inline size_t stream_size (void) const { return (m_Grain
- 1); }
36 /// \class talign uiosfunc.h ustl.h
37 /// \ingroup StreamFunctors
38 /// \brief Stream functor to allow type-based alignment.
40 class talign
: public align
{
42 inline explicit talign (void) : align (alignof (NullValue
<T
>())) {}
45 /// \class skip uiosfunc.h ustl.h
46 /// \ingroup StreamFunctors
47 /// \brief Stream functor to allow inline skip() calls.
49 /// Example: os << ios::skip(sizeof(uint16_t));
53 inline explicit skip (size_t nBytes
) : m_nBytes(nBytes
) {}
54 inline istream
& apply (istream
& is
) const { is
.skip (m_nBytes
); return (is
); }
55 inline ostream
& apply (ostream
& os
) const { os
.skip (m_nBytes
); return (os
); }
56 inline void read (istream
& is
) const { apply (is
); }
57 inline void write (ostream
& os
) const { apply (os
); }
58 inline size_t stream_size (void) const { return (m_nBytes
); }
60 const size_t m_nBytes
;
63 /// \class width uiosfunc.h ustl.h
64 /// \ingroup StreamFunctors
65 /// \brief Stream functor to allow inline set_width() calls.
67 /// Example: os << ios::width(15);
71 inline explicit width (size_t nBytes
) : m_nBytes(nBytes
) {}
72 inline ostringstream
& apply (ostringstream
& os
) const { os
.set_width (m_nBytes
); return (os
); }
73 inline void text_write (ostringstream
& os
) const { apply (os
); }
75 const size_t m_nBytes
;
78 /// \class base uiosfunc.h ustl.h
79 /// \ingroup StreamFunctors
80 /// \brief Stream functor to allow inline set_base() calls.
82 /// Example: os << ios::base(15);
86 inline explicit base (size_t n
) : m_Base(n
) {}
87 inline ostringstream
& apply (ostringstream
& os
) const { os
.set_base (m_Base
); return (os
); }
88 inline void text_write (ostringstream
& os
) const { apply (os
); }
96 CAST_STREAMABLE(ustl::ios::fmtflags
, uint32_t)
97 NUMERIC_LIMITS(ustl::ios::fmtflags
, ustl::ios::boolalpha
, ustl::ios::floatfield
, false, true, true)