blob: c2a3ab60d90f56d800be6ef887b211c00ce05305 [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
Zachary Turner98162462015-03-01 06:59:57 +000013#include "llvm/ADT/StringRef.h"
Zachary Turner2d11c202015-02-27 09:15:59 +000014#include "llvm/ADT/Twine.h"
15#include "llvm/Support/raw_ostream.h"
Zachary Turnerf5abda22015-03-01 06:49:49 +000016#include "llvm/Support/Regex.h"
17
18#include <list>
Zachary Turner2d11c202015-02-27 09:15:59 +000019
20namespace llvm {
21
22class LinePrinter {
23 friend class WithColor;
24
25public:
26 LinePrinter(int Indent, raw_ostream &Stream);
27
28 void Indent();
29 void Unindent();
Zachary Turner2d11c202015-02-27 09:15:59 +000030 void NewLine();
31
32 raw_ostream &getStream() { return OS; }
Zachary Turner7797c722015-03-02 04:39:56 +000033 int getIndentLevel() const { return CurrentIndent; }
Zachary Turner2d11c202015-02-27 09:15:59 +000034
Zachary Turnerf5abda22015-03-01 06:49:49 +000035 bool IsTypeExcluded(llvm::StringRef TypeName);
36 bool IsSymbolExcluded(llvm::StringRef SymbolName);
37 bool IsCompilandExcluded(llvm::StringRef CompilandName);
38
Zachary Turner2d11c202015-02-27 09:15:59 +000039private:
Zachary Turner7797c722015-03-02 04:39:56 +000040 template <typename Iter>
41 void SetFilters(std::list<Regex> &List, Iter Begin, Iter End) {
42 List.clear();
43 for (; Begin != End; ++Begin)
44 List.push_back(StringRef(*Begin));
45 }
46
Zachary Turner2d11c202015-02-27 09:15:59 +000047 raw_ostream &OS;
48 int IndentSpaces;
49 int CurrentIndent;
Zachary Turnerf5abda22015-03-01 06:49:49 +000050
51 std::list<Regex> CompilandFilters;
52 std::list<Regex> TypeFilters;
53 std::list<Regex> SymbolFilters;
Zachary Turner2d11c202015-02-27 09:15:59 +000054};
55
56template <class T>
57inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
58 Printer.getStream() << Item;
59 return Printer.getStream();
60}
61
62enum class PDB_ColorItem {
63 None,
64 Address,
65 Type,
66 Keyword,
67 Offset,
68 Identifier,
69 Path,
70 SectionHeader,
71 LiteralValue,
Zachary Turner7797c722015-03-02 04:39:56 +000072 Register,
Zachary Turner2d11c202015-02-27 09:15:59 +000073};
74
75class WithColor {
76public:
77 WithColor(LinePrinter &P, PDB_ColorItem C);
78 ~WithColor();
79
80 raw_ostream &get() { return OS; }
81
82private:
83 void translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
84 bool &Bold) const;
85 raw_ostream &OS;
86};
87}
88
89#endif