blob: 84afd37c540a0371db95c01e79bfcd651441e9d0 [file] [log] [blame]
Adrian Prantl0c36a752015-01-06 16:50:25 +00001//===-- 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
10#ifndef LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
11#define LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
12
13#include "llvm/Support/raw_ostream.h"
14
15namespace llvm {
16namespace dwarf {
17namespace syntax {
18
19// Symbolic names for various syntax elements.
20enum HighlightColor { Address, String, Tag, Attribute, Enumerator };
21
22/// An RAII object that temporarily switches an output stream to a
23/// specific color.
24class WithColor {
25 llvm::raw_ostream &OS;
26
27public:
28 /// To be used like this: WithColor(OS, syntax::String) << "text";
29 WithColor(llvm::raw_ostream &OS, enum HighlightColor Type);
30 ~WithColor();
31
32 llvm::raw_ostream& get() { return OS; }
33 operator llvm::raw_ostream& () { return OS; }
34};
Alexander Kornienko70bc5f12015-06-19 15:57:42 +000035} // namespace syntax
36} // namespace dwarf
37} // namespace llvm
Adrian Prantl0c36a752015-01-06 16:50:25 +000038
39#endif