[78a794ab] | 1 | /*
|
---|
| 2 | * Copyright (c) 2018 Jaroslav Jindrak
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[b57a3ee] | 29 | #include <__bits/io/iomanip_objs.hpp>
|
---|
[78a794ab] | 30 | #include <iomanip>
|
---|
| 31 |
|
---|
| 32 | namespace std
|
---|
| 33 | {
|
---|
| 34 | namespace aux
|
---|
| 35 | {
|
---|
| 36 | /**
|
---|
| 37 | * Manipulator return types:
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | resetiosflags_t::resetiosflags_t(ios_base::fmtflags m)
|
---|
| 41 | : mask{m}
|
---|
| 42 | { /* DUMMY BODY */ }
|
---|
| 43 |
|
---|
| 44 | void resetiosflags_t::operator()(ios_base& str) const
|
---|
| 45 | {
|
---|
| 46 | str.setf(ios_base::fmtflags{0}, mask);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | setiosflags_t::setiosflags_t(ios_base::fmtflags m)
|
---|
| 50 | : mask{m}
|
---|
| 51 | { /* DUMMY BODY */ }
|
---|
| 52 |
|
---|
| 53 | void setiosflags_t::operator()(ios_base& str) const
|
---|
| 54 | {
|
---|
| 55 | str.setf(mask);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | setbase_t::setbase_t(int b)
|
---|
| 59 | : base{b}
|
---|
| 60 | { /* DUMMY BODY */ }
|
---|
| 61 |
|
---|
| 62 | void setbase_t::operator()(ios_base& str) const
|
---|
| 63 | {
|
---|
| 64 | str.setf(
|
---|
| 65 | base == 8 ? ios_base::oct :
|
---|
| 66 | base == 10 ? ios_base::dec :
|
---|
| 67 | base == 16 ? ios_base::hex :
|
---|
| 68 | ios_base::fmtflags{0},
|
---|
| 69 | ios_base::basefield
|
---|
| 70 | );
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | setprecision_t::setprecision_t(int p)
|
---|
| 74 | : prec{p}
|
---|
| 75 | { /* DUMMY BODY */ }
|
---|
| 76 |
|
---|
| 77 | void setprecision_t::operator()(ios_base& str) const
|
---|
| 78 | {
|
---|
| 79 | str.precision(prec);
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | setw_t::setw_t(int w)
|
---|
| 83 | : width{w}
|
---|
| 84 | { /* DUMMY BODY */ }
|
---|
| 85 |
|
---|
| 86 | void setw_t::operator()(ios_base& str) const
|
---|
| 87 | {
|
---|
| 88 | str.width(width);
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /**
|
---|
| 93 | * Manipulators:
|
---|
| 94 | */
|
---|
| 95 |
|
---|
| 96 | aux::manip_wrapper<aux::resetiosflags_t> resetiosflags(ios_base::fmtflags mask)
|
---|
| 97 | {
|
---|
| 98 | return aux::manip_wrapper<aux::resetiosflags_t>{mask};
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | aux::manip_wrapper<aux::setiosflags_t> setiosflags(ios_base::fmtflags mask)
|
---|
| 102 | {
|
---|
| 103 | return aux::manip_wrapper<aux::setiosflags_t>{mask};
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | aux::manip_wrapper<aux::setbase_t> setbase(int base)
|
---|
| 107 | {
|
---|
| 108 | return aux::manip_wrapper<aux::setbase_t>{base};
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | aux::manip_wrapper<aux::setprecision_t> setprecision(int prec)
|
---|
| 112 | {
|
---|
| 113 | return aux::manip_wrapper<aux::setprecision_t>{prec};
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | aux::manip_wrapper<aux::setw_t> setw(int width)
|
---|
| 117 | {
|
---|
| 118 | return aux::manip_wrapper<aux::setw_t>{width};
|
---|
| 119 | }
|
---|
| 120 | }
|
---|