source: src/Common/Indenter.h @ f7cb0bc

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since f7cb0bc was f7cb0bc, checked in by Rob Schluntz <rschlunt@…>, 4 years ago

refactor indenter from CodeGen? and CurrentObject?

  • Property mode set to 100644
File size: 1.2 KB
Line 
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//
7// utility.h --
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Andrew Beach
12// Last Modified On : Fri May 5 11:03:00 2017
13// Update Count     : 32
14//
15
16#ifndef INDENTER_H
17#define INDENTER_H
18
19struct Indenter {
20        Indenter( unsigned int amt = 2 ) : amt( amt ) {}
21        unsigned int amt = 2;  // amount 1 level increases indent by (i.e. how much to increase by in operator++)
22        unsigned int indent = 0;
23
24        Indenter & operator+=(int nlevels) { indent += amt*nlevels; return *this; }
25        Indenter & operator-=(int nlevels) { indent -= amt*nlevels; return *this; }
26        Indenter operator+(int nlevels) { Indenter indenter = *this; return indenter += nlevels; }
27        Indenter operator-(int nlevels) { Indenter indenter = *this; return indenter -= nlevels; }
28        Indenter & operator++() { return *this += 1; }
29        Indenter & operator--() { return *this -= 1; }
30};
31
32inline std::ostream & operator<<( std::ostream & out, Indenter & indent ) {
33        return out << std::string(indent.indent, ' ');
34}
35
36#endif // INDENTER_H
Note: See TracBrowser for help on using the repository browser.