xref: /libCEED/rust/libceed-sys/c-src/include/ceed/gen-tools.h (revision 0183ed61035d97ff853cf8c8e722c0fda76e54df)
1*0183ed61SJeremy L Thompson #include <ceed.h>
2*0183ed61SJeremy L Thompson #include <sstream>
3*0183ed61SJeremy L Thompson 
4*0183ed61SJeremy L Thompson class Tab {
5*0183ed61SJeremy L Thompson  private:
6*0183ed61SJeremy L Thompson   CeedInt       _num_tabs{0};
7*0183ed61SJeremy L Thompson   const CeedInt _width{2};
8*0183ed61SJeremy L Thompson 
9*0183ed61SJeremy L Thompson   template <class OStream>
10*0183ed61SJeremy L Thompson   friend OStream &operator<<(OStream &os, const Tab &tab);
11*0183ed61SJeremy L Thompson 
12*0183ed61SJeremy L Thompson  public:
push()13*0183ed61SJeremy L Thompson   Tab &push() {
14*0183ed61SJeremy L Thompson     _num_tabs++;
15*0183ed61SJeremy L Thompson     return *this;
16*0183ed61SJeremy L Thompson   }
pop()17*0183ed61SJeremy L Thompson   Tab &pop() {
18*0183ed61SJeremy L Thompson     if (_num_tabs > 0) _num_tabs--;
19*0183ed61SJeremy L Thompson     return *this;
20*0183ed61SJeremy L Thompson   }
21*0183ed61SJeremy L Thompson };
22*0183ed61SJeremy L Thompson 
23*0183ed61SJeremy L Thompson template <class OStream>
24*0183ed61SJeremy L Thompson OStream &operator<<(OStream &os, const Tab &tab) {
25*0183ed61SJeremy L Thompson   os << std::string(tab._num_tabs * tab._width, ' ');
26*0183ed61SJeremy L Thompson   return os;
27*0183ed61SJeremy L Thompson }
28