|
Last change
on this file since 3848 was
3848,
checked in by ymipsl, 10 years ago
|
|
Add XIOS in Aquaplanet configuration.
YM
|
-
Property svn:eol-style set to
native
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | #include "indent.hpp" |
|---|
| 2 | #include <ostream> |
|---|
| 3 | #include <iostream> |
|---|
| 4 | |
|---|
| 5 | using namespace std ; |
|---|
| 6 | |
|---|
| 7 | namespace xios |
|---|
| 8 | { |
|---|
| 9 | Cindent iendl ; |
|---|
| 10 | Cindent ireset(0,true) ; |
|---|
| 11 | int Cindent::defaultIncSize=2 ; |
|---|
| 12 | int Cindent::index=ios::xalloc() ; |
|---|
| 13 | |
|---|
| 14 | Cindent::Cindent(int i,bool r) : offset(i), reset(r), incSize(defaultIncSize) |
|---|
| 15 | { } |
|---|
| 16 | |
|---|
| 17 | Cindent Cindent::operator++() |
|---|
| 18 | { |
|---|
| 19 | return Cindent(incSize) ; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | Cindent Cindent::operator--() |
|---|
| 23 | { |
|---|
| 24 | return Cindent(-incSize) ; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | Cindent Cindent::operator++(int) |
|---|
| 28 | { |
|---|
| 29 | return Cindent(incSize) ; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | Cindent Cindent::operator--(int) |
|---|
| 33 | { |
|---|
| 34 | return Cindent(-incSize) ; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | Cindent Cindent::operator+=(int i) |
|---|
| 38 | { |
|---|
| 39 | return Cindent(incSize*i) ; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | Cindent Cindent::operator-=(int i) |
|---|
| 43 | { |
|---|
| 44 | return Cindent(-incSize*i) ; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | ostream& Cindent::iendl(ostream& o) const |
|---|
| 48 | { |
|---|
| 49 | if (reset) |
|---|
| 50 | { |
|---|
| 51 | o.iword(index)=0 ; |
|---|
| 52 | return o ; |
|---|
| 53 | } |
|---|
| 54 | else |
|---|
| 55 | { |
|---|
| 56 | o.iword(index)+=offset ; |
|---|
| 57 | if (o.iword(index)<0) o.iword(index)=0 ; |
|---|
| 58 | o<<"\n" ; |
|---|
| 59 | int mem=o.width(o.iword(index)) ; |
|---|
| 60 | o<<""; |
|---|
| 61 | o.width(mem) ; |
|---|
| 62 | return o ; |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | ostream& operator <<(ostream& o, const Cindent& indent) |
|---|
| 67 | { |
|---|
| 68 | return indent.iendl(o) ; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.