00001 00002 /* 00003 | Author: Michael Schmidt; 00004 | Gunnar Jehl 00005 | 00006 | ************************* SOFTWARE LICENSE AGREEMENT *********************** 00007 | This source code is published under the BSD License. 00008 | 00009 | See file 'LICENSE.txt' that comes with this distribution or 00010 | http://dbis.informatik.uni-freiburg.de/index.php?project=GCX/license.php 00011 | for the full license agreement. 00012 | 00013 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00014 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00016 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00017 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00018 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00019 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00020 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00021 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 | POSSIBILITY OF SUCH DAMAGE. 00024 | **************************************************************************** 00025 */ 00026 00035 #ifndef OUTPUTSTREAMMANIP_H 00036 #define OUTPUTSTREAMMANIP_H 00037 00038 #include "outputstream.h" 00039 00048 class DecIndents { 00049 public: 00054 DecIndents(int _n = INDENT_SINGLE):n(_n) { 00055 } void operator () (OutputStream & out) const { 00062 out.decrementIndents(n); 00063 } private: 00069 int n; 00070 }; 00071 00078 inline DecIndents decrementIndents(int n = INDENT_SINGLE) { 00079 return DecIndents(n); 00080 } 00081 00089 inline OutputStream & operator<<(OutputStream & out, const DecIndents & dec) { 00090 dec(out); 00091 return (out); 00092 } 00093 00102 class IncIndents { 00103 public: 00108 IncIndents(int _n = INDENT_SINGLE):n(_n) { 00109 } void operator () (OutputStream & out) const { 00116 out.incrementIndents(n); 00117 } private: 00123 int n; 00124 }; 00125 00132 inline IncIndents incrementIndents(int n = INDENT_SINGLE) { 00133 return IncIndents(n); 00134 } 00135 00143 inline OutputStream & operator<<(OutputStream & out, const IncIndents & inc) { 00144 inc(out); 00145 return (out); 00146 } 00147 00156 class ResIndents { 00157 public: 00161 ResIndents() { 00162 } void operator () (OutputStream & out) const { 00169 out.resetIndents(); 00170 }}; 00171 00177 inline ResIndents resetIndents() { 00178 return ResIndents(); 00179 } 00180 00188 inline OutputStream & operator<<(OutputStream & out, const ResIndents & res) { 00189 res(out); 00190 return (out); 00191 } 00192 00201 class WriIndents { 00202 public: 00206 WriIndents() { 00207 } void operator () (OutputStream & out) const { 00214 out.writeIndents(); 00215 }}; 00216 00222 inline WriIndents writeIndents() { 00223 return WriIndents(); 00224 } 00225 00233 inline OutputStream & operator<<(OutputStream & out, const WriIndents & write) { 00234 write(out); 00235 return (out); 00236 } 00237 00238 #endif // OUTPUTSTREAMMANIP_H