xref: /libCEED/include/ceed/gen-tools.h (revision 8a3c90c815d7c47d4c85d45b709b827586c3b9a0)
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:
13   Tab &push() {
14     _num_tabs++;
15     return *this;
16   }
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