PhoenixGenerator  2.0.0
Set of tools to generate code
header_generator.h File Reference
#include <fstream>
#include "PPath.h"
+ Include dependency graph for header_generator.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void licenceSave (std::ofstream &fs)
 Saves the policy. More...
 
PString licenceSaveStr ()
 Get the licence in string. More...
 
PString makeMultiIncludeDefineMacro (const PString &fileName)
 Create the macro of multi inclusion file name. More...
 
void saveHeaderFile (const PPath &fileName)
 Fonction qui sauve le fichier header. More...
 
void saveHeaderSourceFile (const PPath &headerName, const PPath &sourceName)
 Fonction qui sauve le fichier header. More...
 
void saveSourceFile (const PPath &fileName, const PString &headerName)
 Fonction qui sauve le fichier source. More...
 

Function Documentation

◆ licenceSave()

void licenceSave ( std::ofstream &  fs)

Saves the policy.

Parameters
fs: file in witch to write

Definition at line 26 of file header_generator.cpp.

26  {
27  fs << licenceSaveStr() << std::endl;
28 }
PString licenceSaveStr()
Get the licence in string.

References licenceSaveStr().

Referenced by saveClassDecl(), saveClassImpl(), saveClassTemplate(), PClassGenerator::saveFileDef(), PClassGenerator::saveFileImpl(), saveHeaderFile(), and saveSourceFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ licenceSaveStr()

PString licenceSaveStr ( )

Get the licence in string.

Returns
licence in string

Definition at line 13 of file header_generator.cpp.

13  {
14  PString body("");
15  body += "/***************************************\n";
16  body += "\tAuteur : Pierre Aubert\n";
17  body += "\tMail : pierre.aubert@lapp.in2p3.fr\n";
18  body += "\tLicence : CeCILL-C\n";
19  body += "****************************************/\n";
20  return body;
21 }
Extends the std::string.
Definition: PString.h:16

Referenced by licenceSave(), project_wrapper_moduleGeneratorMain(), project_wrapper_moduleGeneratorWrapperHeader(), project_wrapper_moduleGeneratorWrapperImpl(), and saveClassTestMain().

+ Here is the caller graph for this function:

◆ makeMultiIncludeDefineMacro()

PString makeMultiIncludeDefineMacro ( const PString fileName)

Create the macro of multi inclusion file name.

Parameters
fileName: header file name
Returns
macro of multi inclusion file name

Definition at line 34 of file header_generator.cpp.

34  {
35  return "__" + fileName.replace(".", "_").toUpper() + "__";
36 }
PString replace(const PString &pattern, const PString &replaceStr) const
Replace a PString into an other PString.
Definition: PString.cpp:204
PString toUpper() const
Convert std::string in upper case.
Definition: PString.cpp:639

References PString::replace(), and PString::toUpper().

Referenced by saveClassDecl(), saveClassTemplate(), PClassGenerator::saveFileDef(), and saveHeaderFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveHeaderFile()

void saveHeaderFile ( const PPath fileName)

Fonction qui sauve le fichier header.

Parameters
fileName: header file name

Definition at line 41 of file header_generator.cpp.

41  {
42  std::ofstream fs;
43  fs.open(fileName.c_str());
44  if(!fs.is_open()){
45  std::cerr << "saveHeaderFile : can't open file '" << fileName << "'" << std::endl;
46  return;
47  }
48  PString defineStr(makeMultiIncludeDefineMacro(fileName));
49  licenceSave(fs);
50  fs << "#ifndef " << defineStr << std::endl;
51  fs << "#define " << defineStr << std::endl;
52  fs << std::endl << std::endl << std::endl << std::endl << std::endl << std::endl;
53  fs << "#endif" << std::endl;
54  fs.close();
55 }
PString makeMultiIncludeDefineMacro(const PString &fileName)
Create the macro of multi inclusion file name.
void licenceSave(std::ofstream &fs)
Saves the policy.

References licenceSave(), and makeMultiIncludeDefineMacro().

Referenced by saveHeaderSourceFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveHeaderSourceFile()

void saveHeaderSourceFile ( const PPath headerName,
const PPath sourceName 
)

Fonction qui sauve le fichier header.

Parameters
headerName: header file name
sourceName: source file name

Definition at line 77 of file header_generator.cpp.

77  {
78  saveHeaderFile(headerName);
79  saveSourceFile(sourceName, headerName);
80 }
void saveSourceFile(const PPath &fileName, const PString &headerName)
Fonction qui sauve le fichier source.
void saveHeaderFile(const PPath &fileName)
Fonction qui sauve le fichier header.

References saveHeaderFile(), and saveSourceFile().

+ Here is the call graph for this function:

◆ saveSourceFile()

void saveSourceFile ( const PPath fileName,
const PString headerName 
)

Fonction qui sauve le fichier source.

Parameters
fileName: source file name
headerName: header file name

Definition at line 61 of file header_generator.cpp.

61  {
62  std::ofstream fs;
63  fs.open(fileName.c_str());
64  if(!fs.is_open()){
65  std::cerr << "saveSourceFile : can't open file '" << fileName << "'" << std::endl;
66  return;
67  }
68  licenceSave(fs);
69  fs << std::endl << "#include \"" << headerName << "\"" << std::endl << std::endl << std::endl << std::endl << std::endl << std::endl;
70  fs.close();
71 }

References licenceSave().

Referenced by saveHeaderSourceFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: