blob: 0f66d1f7c85fbc526ee820a00439bc865a52b7fe [file] [log] [blame]
Zachary Turner2d11c202015-02-27 09:15:59 +00001//===- LinePrinter.h ------------------------------------------ *- C++ --*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
11#define LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
12
13#include "llvm/ADT/Twine.h"
14#include "llvm/Support/raw_ostream.h"
15
16namespace llvm {
17
18class LinePrinter {
19 friend class WithColor;
20
21public:
22 LinePrinter(int Indent, raw_ostream &Stream);
23
24 void Indent();
25 void Unindent();
26
27 void NewLine();
28
29 raw_ostream &getStream() { return OS; }
30
31private:
32 raw_ostream &OS;
33 int IndentSpaces;
34 int CurrentIndent;
35};
36
37template <class T>
38inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
39 Printer.getStream() << Item;
40 return Printer.getStream();
41}
42
43enum class PDB_ColorItem {
44 None,
45 Address,
46 Type,
47 Keyword,
48 Offset,
49 Identifier,
50 Path,
51 SectionHeader,
52 LiteralValue,
53};
54
55class WithColor {
56public:
57 WithColor(LinePrinter &P, PDB_ColorItem C);
58 ~WithColor();
59
60 raw_ostream &get() { return OS; }
61
62private:
63 void translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
64 bool &Bold) const;
65 raw_ostream &OS;
66};
67}
68
69#endif