Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 1 | //===- 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" |
Zachary Turner | f5abda2 | 2015-03-01 06:49:49 +0000 | [diff] [blame] | 15 | #include "llvm/Support/Regex.h" |
| 16 | |
| 17 | #include <list> |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 18 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | class LinePrinter { |
| 22 | friend class WithColor; |
| 23 | |
| 24 | public: |
| 25 | LinePrinter(int Indent, raw_ostream &Stream); |
| 26 | |
Zachary Turner | f5abda2 | 2015-03-01 06:49:49 +0000 | [diff] [blame] | 27 | template <typename Iter> void SetTypeFilters(Iter Begin, Iter End) { |
| 28 | TypeFilters.assign(Begin, End); |
| 29 | } |
| 30 | template <typename Iter> void SetSymbolFilters(Iter Begin, Iter End) { |
| 31 | SymbolFilters.assign(Begin, End); |
| 32 | } |
| 33 | template <typename Iter> void SetCompilandFilters(Iter Begin, Iter End) { |
| 34 | CompilandFilters.assign(Begin, End); |
| 35 | } |
| 36 | |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 37 | void Indent(); |
| 38 | void Unindent(); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 39 | void NewLine(); |
| 40 | |
| 41 | raw_ostream &getStream() { return OS; } |
| 42 | |
Zachary Turner | f5abda2 | 2015-03-01 06:49:49 +0000 | [diff] [blame] | 43 | bool IsTypeExcluded(llvm::StringRef TypeName); |
| 44 | bool IsSymbolExcluded(llvm::StringRef SymbolName); |
| 45 | bool IsCompilandExcluded(llvm::StringRef CompilandName); |
| 46 | |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 47 | private: |
| 48 | raw_ostream &OS; |
| 49 | int IndentSpaces; |
| 50 | int CurrentIndent; |
Zachary Turner | f5abda2 | 2015-03-01 06:49:49 +0000 | [diff] [blame] | 51 | |
| 52 | std::list<Regex> CompilandFilters; |
| 53 | std::list<Regex> TypeFilters; |
| 54 | std::list<Regex> SymbolFilters; |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | template <class T> |
| 58 | inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) { |
| 59 | Printer.getStream() << Item; |
| 60 | return Printer.getStream(); |
| 61 | } |
| 62 | |
| 63 | enum class PDB_ColorItem { |
| 64 | None, |
| 65 | Address, |
| 66 | Type, |
| 67 | Keyword, |
| 68 | Offset, |
| 69 | Identifier, |
| 70 | Path, |
| 71 | SectionHeader, |
| 72 | LiteralValue, |
| 73 | }; |
| 74 | |
| 75 | class WithColor { |
| 76 | public: |
| 77 | WithColor(LinePrinter &P, PDB_ColorItem C); |
| 78 | ~WithColor(); |
| 79 | |
| 80 | raw_ostream &get() { return OS; } |
| 81 | |
| 82 | private: |
| 83 | void translateColor(PDB_ColorItem C, raw_ostream::Colors &Color, |
| 84 | bool &Bold) const; |
| 85 | raw_ostream &OS; |
| 86 | }; |
| 87 | } |
| 88 | |
| 89 | #endif |