source: src/Common/Indenter.h @ ca59826

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since ca59826 was 50377a4, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Refactor tree print code to use Indenter

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[f7cb0bc]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[2006db0]7// Indenter.h --
[f7cb0bc]8//
[2006db0]9// Author           : Rob Schluntz
10// Created On       : Fri Jun 30 16:55:23 2017
[f7cb0bc]11// Last Modified By : Andrew Beach
[2006db0]12// Last Modified On : Fri Aug 11 11:15:00 2017
13// Update Count     : 1
[f7cb0bc]14//
15
16#ifndef INDENTER_H
17#define INDENTER_H
18
19struct Indenter {
[50377a4]20        static unsigned tabsize;
21
22        Indenter( unsigned int amt = tabsize, unsigned int indent = 0 ) : amt( amt ), indent( indent ) {}
23        unsigned int amt;  // amount 1 level increases indent by (i.e. how much to increase by in operator++)
24        unsigned int indent;
[f7cb0bc]25
26        Indenter & operator+=(int nlevels) { indent += amt*nlevels; return *this; }
27        Indenter & operator-=(int nlevels) { indent -= amt*nlevels; return *this; }
28        Indenter operator+(int nlevels) { Indenter indenter = *this; return indenter += nlevels; }
29        Indenter operator-(int nlevels) { Indenter indenter = *this; return indenter -= nlevels; }
30        Indenter & operator++() { return *this += 1; }
31        Indenter & operator--() { return *this -= 1; }
32};
33
[50377a4]34inline std::ostream & operator<<( std::ostream & out, const Indenter & indent ) {
[f7cb0bc]35        return out << std::string(indent.indent, ' ');
36}
37
38#endif // INDENTER_H
Note: See TracBrowser for help on using the repository browser.