diff options
Diffstat (limited to 'llvm/tools/llvm-pdbutil/LinePrinter.h')
| -rw-r--r-- | llvm/tools/llvm-pdbutil/LinePrinter.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/llvm/tools/llvm-pdbutil/LinePrinter.h b/llvm/tools/llvm-pdbutil/LinePrinter.h index 1a922feb1e6..f4fd22bcb6f 100644 --- a/llvm/tools/llvm-pdbutil/LinePrinter.h +++ b/llvm/tools/llvm-pdbutil/LinePrinter.h @@ -10,10 +10,12 @@ #ifndef LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H #define LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Regex.h" +#include "llvm/Support/raw_ostream.h" #include <list> @@ -28,10 +30,22 @@ class LinePrinter { public: LinePrinter(int Indent, bool UseColor, raw_ostream &Stream); - void Indent(); - void Unindent(); + void Indent(uint32_t Amount = 0); + void Unindent(uint32_t Amount = 0); void NewLine(); + void printLine(const Twine &T); + void print(const Twine &T); + template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { + printLine(formatv(Fmt, std::forward<Ts>(Items)...)); + } + template <typename... Ts> void format(const char *Fmt, Ts &&... Items) { + print(formatv(Fmt, std::forward<Ts>(Items)...)); + } + + void formatBinary(StringRef Label, ArrayRef<uint8_t> Data, + uint32_t StartOffset); + bool hasColor() const { return UseColor; } raw_ostream &getStream() { return OS; } int getIndentLevel() const { return CurrentIndent; } @@ -63,6 +77,17 @@ private: std::list<Regex> IncludeSymbolFilters; }; +struct AutoIndent { + explicit AutoIndent(LinePrinter &L, uint32_t Amount = 0) + : L(L), Amount(Amount) { + L.Indent(Amount); + } + ~AutoIndent() { L.Unindent(Amount); } + + LinePrinter &L; + uint32_t Amount = 0; +}; + template <class T> inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) { Printer.getStream() << Item; |

