]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/tools/clang/include/clang/Basic/MacroBuilder.h
MFC r244628:
[FreeBSD/stable/9.git] / contrib / llvm / tools / clang / include / clang / Basic / MacroBuilder.h
1 //===--- MacroBuilder.h - CPP Macro building utility ------------*- 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 /// \file
11 /// \brief Defines the clang::MacroBuilder utility class.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_BASIC_MACROBUILDER_H
16 #define LLVM_CLANG_BASIC_MACROBUILDER_H
17
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/Support/raw_ostream.h"
20
21 namespace clang {
22
23 class MacroBuilder {
24   raw_ostream &Out;
25 public:
26   MacroBuilder(raw_ostream &Output) : Out(Output) {}
27
28   /// Append a \#define line for macro of the form "\#define Name Value\n".
29   void defineMacro(const Twine &Name, const Twine &Value = "1") {
30     Out << "#define " << Name << ' ' << Value << '\n';
31   }
32
33   /// Append a \#undef line for Name.  Name should be of the form XXX
34   /// and we emit "\#undef XXX".
35   void undefineMacro(const Twine &Name) {
36     Out << "#undef " << Name << '\n';
37   }
38
39   /// Directly append Str and a newline to the underlying buffer.
40   void append(const Twine &Str) {
41     Out << Str << '\n';
42   }
43 };
44
45 }  // end namespace clang
46
47 #endif