Last change
on this file since c588acb was
c92bdcc,
checked in by Andrew Beach <ajbeach@…>, 6 months ago
|
Updated the rest of the names in src/ (except for the generated files).
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[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 | // |
---|
[c92bdcc] | 7 | // Indenter.hpp -- |
---|
[f7cb0bc] | 8 | // |
---|
[2006db0] | 9 | // Author : Rob Schluntz |
---|
| 10 | // Created On : Fri Jun 30 16:55:23 2017 |
---|
[f7cb0bc] | 11 | // Last Modified By : Andrew Beach |
---|
[9939dc3] | 12 | // Last Modified On : Fri May 13 14:10:00 2022 |
---|
| 13 | // Update Count : 2 |
---|
[f7cb0bc] | 14 | // |
---|
| 15 | |
---|
[9939dc3] | 16 | #pragma once |
---|
| 17 | |
---|
| 18 | #include <ostream> |
---|
[f7cb0bc] | 19 | |
---|
| 20 | struct Indenter { |
---|
[99d4584] | 21 | static unsigned tabsize; ///< default number of spaces in one level of indentation |
---|
[50377a4] | 22 | |
---|
[99d4584] | 23 | unsigned int indent; ///< number of spaces to indent |
---|
| 24 | unsigned int amt; ///< spaces in one level of indentation |
---|
[f7cb0bc] | 25 | |
---|
[4e5e6cc] | 26 | Indenter( unsigned int indent = 0, unsigned int amt = tabsize ) |
---|
| 27 | : indent( indent ), amt( amt ) {} |
---|
| 28 | |
---|
| 29 | Indenter & operator+=(int nlevels) { indent += nlevels; return *this; } |
---|
| 30 | Indenter & operator-=(int nlevels) { indent -= nlevels; return *this; } |
---|
[f7cb0bc] | 31 | Indenter operator+(int nlevels) { Indenter indenter = *this; return indenter += nlevels; } |
---|
| 32 | Indenter operator-(int nlevels) { Indenter indenter = *this; return indenter -= nlevels; } |
---|
| 33 | Indenter & operator++() { return *this += 1; } |
---|
| 34 | Indenter & operator--() { return *this -= 1; } |
---|
| 35 | }; |
---|
| 36 | |
---|
[50377a4] | 37 | inline std::ostream & operator<<( std::ostream & out, const Indenter & indent ) { |
---|
[4e5e6cc] | 38 | return out << std::string(indent.indent * indent.amt, ' '); |
---|
[f7cb0bc] | 39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.