SyntaxHighlighting.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===-- SyntaxHighlighting.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. #ifndef LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
  10. #define LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
  11. #include "llvm/Support/raw_ostream.h"
  12. namespace llvm {
  13. namespace dwarf {
  14. namespace syntax {
  15. // Symbolic names for various syntax elements.
  16. enum HighlightColor { Address, String, Tag, Attribute, Enumerator };
  17. /// An RAII object that temporarily switches an output stream to a
  18. /// specific color.
  19. class WithColor {
  20. llvm::raw_ostream &OS;
  21. public:
  22. /// To be used like this: WithColor(OS, syntax::String) << "text";
  23. WithColor(llvm::raw_ostream &OS, enum HighlightColor Type);
  24. ~WithColor();
  25. llvm::raw_ostream& get() { return OS; }
  26. operator llvm::raw_ostream& () { return OS; }
  27. };
  28. }
  29. }
  30. }
  31. #endif