Logo ROOT   6.18/05
Reference Guide
TModuleGenerator.h
Go to the documentation of this file.
1// @(#)root/utils:$Id$
2// Author: Axel Naumann, 2-13-07-02
3
4/*************************************************************************
5 * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12////////////////////////////////////////////////////////////////////////////////
13//
14// PCM writer.
15//
16////////////////////////////////////////////////////////////////////////////////
17
18#ifndef ROOT_TModuleGenerator
19#define ROOT_TModuleGenerator
20
21#include <ostream>
22#include <sstream>
23#include <fstream>
24#include <string>
25#include <map>
26#include <vector>
27
28namespace clang {
29 class CompilerInstance;
30 class SourceManager;
31}
32
33namespace ROOT {
34
35//______________________________________________________________________________
37 public:
43 };
44
45 TModuleGenerator(clang::CompilerInstance *CI,
46 bool inlineHeader,
47 const std::string &shLibFileName,
48 bool isInPCH);
50
51 // FIXME: remove once PCH is gone.
52 bool IsPCH() const {
53 return fIsPCH;
54 }
55 void ParseArgs(const std::vector<std::string> &args);
56
57 const std::string &GetDictionaryName() const {
58 return fDictionaryName;
59 }
60
61 const std::string &GetDemangledDictionaryName() const {
63 }
64
65 const std::string &GetModuleFileName() const {
66 return fModuleFileName;
67 }
68 const std::string &GetModuleDirName() const {
69 return fModuleDirName;
70 }
71
72 int GetErrorCount() const {
73 return fErrorCount;
74 }
75
76 const std::string &GetUmbrellaName() const {
77 return fUmbrellaName;
78 }
79 const std::string &GetContentName() const {
80 return fContentName;
81 }
82
83 const std::vector<std::string> &GetHeaders() const {
84 return fHeaders;
85 }
86
87 const std::vector<std::string> &GetIncludePaths() const {
88 return fCompI;
89 }
90
91 std::ostream &WritePPDefines(std::ostream &out) const;
92 std::ostream &WritePPUndefines(std::ostream &out) const;
93
94 void WriteRegistrationSource(std::ostream &out,
95 const std::string &fwdDeclnArgsToKeepString,
96 const std::string &headersClassesMapString,
97 const std::string &fwdDeclsString,
98 const std::string &extraIncludes) const;
99 void WriteContentHeader(std::ostream &out) const;
100 void WriteUmbrellaHeader(std::ostream &out) const;
101
102 private:
103 void ConvertToCppString(std::string &text) const;
104
105 std::ostream &WritePPIncludes(std::ostream &out) const;
106
107 std::ostream &WritePPCode(std::ostream &out) const {
108 // Write defines, undefiles, includes, corrsponding to a rootcling
109 // invocation with -c -DFOO -UBAR header.h.
110 WritePPDefines(out);
111 WritePPUndefines(out);
112 return WritePPIncludes(out);
113 }
114
115 std::ostream &WriteHeaderArray(std::ostream &out) const {
116 // Write "header1.h",\n"header2.h",\n0\n
117 return WriteStringVec(fHeaders, out);
118 }
119 std::ostream &WriteIncludePathArray(std::ostream &out) const {
120 // Write "./include",\n"/usr/include",\n0\n
121 return WriteStringVec(fCompI, out);
122 }
123 std::ostream &WriteDefinesArray(std::ostream &out) const {
124 // Write "DEFINED",\n"NAME=\"VALUE\"",\n0\n
125 return WriteStringPairVec(fCompD, out);
126 }
127 std::ostream &WriteUndefinesArray(std::ostream &out) const {
128 // Write "UNDEFINED",\n"NAME",\n0\n
129 return WriteStringVec(fCompU, out);
130 }
131
132 bool FindHeader(const std::string& hdrName, std::string& hdrFullPath) const;
133
134 typedef std::vector<std::pair<std::string, std::string> > StringPairVec_t;
135
136 ESourceFileKind GetSourceFileKind(const char *filename) const;
137 std::ostream &WriteStringVec(const std::vector<std::string> &vec,
138 std::ostream &out) const;
139 std::ostream &WriteStringPairVec(const StringPairVec_t &vecP,
140 std::ostream &out) const;
141
142 clang::CompilerInstance *fCI;
143 bool fIsPCH;
144 bool fIsInPCH; // whether the headers of this module are part of the PCH.
146
147 std::string fDictionaryName; // Name of the dictionary, e.g. "Base"
148 std::string fDemangledDictionaryName; // Demangled name of the dictionary
149 std::string fModuleFileName; // PCM file name
150 std::string fModuleDirName; // PCM output directory
151 std::string fUmbrellaName; // name of umbrella header in PCM
152 std::string fContentName; // name of content description header in PCM
153
154 std::vector<std::string> fHeaders; // exported headers in PCM
155 std::string fLinkDefFile; // The name of the linkdef file
156 std::vector<std::string> fCompI; // -I; needed only for ACLiC without PCMs
157
158 StringPairVec_t fCompD; // -Dfirst=second
159 std::vector<std::string> fCompU; // -Ufirst
160 mutable int fErrorCount;
161 };
162
163} // namespace ROOT
164
165#endif // ROOT_TModuleGenerator
std::vector< std::string > fCompU
void WriteUmbrellaHeader(std::ostream &out) const
Write a header file pulling in the content of this module through a series of #defined,...
std::ostream & WriteHeaderArray(std::ostream &out) const
std::vector< std::pair< std::string, std::string > > StringPairVec_t
std::ostream & WriteStringVec(const std::vector< std::string > &vec, std::ostream &out) const
std::ostream & WriteStringPairVec(const StringPairVec_t &vecP, std::ostream &out) const
void WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclnArgsToKeepString, const std::string &headersClassesMapString, const std::string &fwdDeclsString, const std::string &extraIncludes) const
const std::string & GetUmbrellaName() const
const std::vector< std::string > & GetIncludePaths() const
ESourceFileKind GetSourceFileKind(const char *filename) const
Check whether the file's extension is compatible with C or C++.
std::ostream & WritePPIncludes(std::ostream &out) const
Write #include "header1.h" #include "header2.h" or, if inlining of headers is requested,...
TModuleGenerator(clang::CompilerInstance *CI, bool inlineHeader, const std::string &shLibFileName, bool isInPCH)
void ConvertToCppString(std::string &text) const
std::ostream & WriteIncludePathArray(std::ostream &out) const
const std::vector< std::string > & GetHeaders() const
void WriteContentHeader(std::ostream &out) const
Write a header file describing the content of this module through a series of variables inside the na...
std::vector< std::string > fCompI
std::vector< std::string > fHeaders
const std::string & GetModuleFileName() const
std::ostream & WritePPUndefines(std::ostream &out) const
Write #ifdef FOO.
std::ostream & WritePPCode(std::ostream &out) const
const std::string & GetDictionaryName() const
std::string fDemangledDictionaryName
clang::CompilerInstance * fCI
std::ostream & WriteDefinesArray(std::ostream &out) const
bool FindHeader(const std::string &hdrName, std::string &hdrFullPath) const
Return true if the header is found in the include paths in this case also fill the full path variable...
std::ostream & WriteUndefinesArray(std::ostream &out) const
const std::string & GetDemangledDictionaryName() const
void ParseArgs(const std::vector< std::string > &args)
Parse -I -D -U headers.h SomethingLinkdef.h.
const std::string & GetContentName() const
const std::string & GetModuleDirName() const
std::ostream & WritePPDefines(std::ostream &out) const
Write #ifndef FOO.
TText * text
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21