blob: 6fd16b73f9c39fa6566c12e65a6ed77019244798 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#pragma once
#include <util/generic/algorithm.h>
#include <util/generic/vector.h>
#include <util/string/builder.h>
#include <util/memory/tempbuf.h>
namespace NLastGetopt {
/// Utility for printing indented lines. Used by completion generators.
class TFormattedOutput {
public:
struct IndentGuard {
explicit IndentGuard(TFormattedOutput* output);
virtual ~IndentGuard();
TFormattedOutput* Output;
};
public:
/// Increase indentation and return a RAII object that'll decrease it back automatically.
IndentGuard Indent();
/// Append a new indented line to the stream.
TStringBuilder& Line();
/// Collect all lines into a stream.
void Print(IOutputStream& out);
private:
int IndentLevel_ = 0;
TVector<std::pair<int, TStringBuilder>> Lines_;
};
}
|