blob: 277de973dbf0ee0e8528a92b03112d202225b80e [file] [log] [blame]
Eugene Zelenko28db7e62017-03-01 01:14:23 +00001//===- SyntaxHighlighting.h -------------------------------------*- C++ -*-===//
Adrian Prantl0c36a752015-01-06 16:50:25 +00002//
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_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
11#define LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
12
Adrian Prantl0c36a752015-01-06 16:50:25 +000013namespace llvm {
Eugene Zelenko28db7e62017-03-01 01:14:23 +000014
15class raw_ostream;
16
Adrian Prantl0c36a752015-01-06 16:50:25 +000017namespace dwarf {
18namespace syntax {
19
20// Symbolic names for various syntax elements.
Amjad Aboude59cc3e2015-11-12 09:38:54 +000021enum HighlightColor { Address, String, Tag, Attribute, Enumerator, Macro };
Adrian Prantl0c36a752015-01-06 16:50:25 +000022
23/// An RAII object that temporarily switches an output stream to a
24/// specific color.
25class WithColor {
Eugene Zelenko28db7e62017-03-01 01:14:23 +000026 raw_ostream &OS;
Adrian Prantl0c36a752015-01-06 16:50:25 +000027
28public:
29 /// To be used like this: WithColor(OS, syntax::String) << "text";
Eugene Zelenko28db7e62017-03-01 01:14:23 +000030 WithColor(raw_ostream &OS, enum HighlightColor Type);
Adrian Prantl0c36a752015-01-06 16:50:25 +000031 ~WithColor();
32
Eugene Zelenko28db7e62017-03-01 01:14:23 +000033 raw_ostream& get() { return OS; }
34 operator raw_ostream& () { return OS; }
Adrian Prantl0c36a752015-01-06 16:50:25 +000035};
Adrian Prantl0c36a752015-01-06 16:50:25 +000036
Eugene Zelenko28db7e62017-03-01 01:14:23 +000037} // end namespace syntax
38} // end namespace dwarf
39
40} // end namespace llvm
41
42#endif // LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H