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