//===- LinePrinter.h ------------------------------------------ *- C++ --*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H #define LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Regex.h" #include namespace llvm { namespace pdb { class ClassLayout; class LinePrinter { friend class WithColor; public: LinePrinter(int Indent, bool UseColor, raw_ostream &Stream); void Indent(); void Unindent(); void NewLine(); bool hasColor() const { return UseColor; } raw_ostream &getStream() { return OS; } int getIndentLevel() const { return CurrentIndent; } bool IsClassExcluded(const ClassLayout &Class); bool IsTypeExcluded(llvm::StringRef TypeName, uint32_t Size); bool IsSymbolExcluded(llvm::StringRef SymbolName); bool IsCompilandExcluded(llvm::StringRef CompilandName); private: template void SetFilters(std::list &List, Iter Begin, Iter End) { List.clear(); for (; Begin != End; ++Begin) List.emplace_back(StringRef(*Begin)); } raw_ostream &OS; int IndentSpaces; int CurrentIndent; bool UseColor; std::list ExcludeCompilandFilters; std::list ExcludeTypeFilters; std::list ExcludeSymbolFilters; std::list IncludeCompilandFilters; std::list IncludeTypeFilters; std::list IncludeSymbolFilters; }; template inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) { Printer.getStream() << Item; return Printer.getStream(); } enum class PDB_ColorItem { None, Address, Type, Comment, Padding, Keyword, Offset, Identifier, Path, SectionHeader, LiteralValue, Register, }; class WithColor { public: WithColor(LinePrinter &P, PDB_ColorItem C); ~WithColor(); raw_ostream &get() { return OS; } private: void applyColor(PDB_ColorItem C); raw_ostream &OS; bool UseColor; }; } } #endif