Commit aaacd0e4 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add test

parent 01c08c19
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(TEST_BASE_CONFIG)
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
TableParameters{
///Position on the x axis
float x;
///Position on the y axis
float y;
}
...@@ -28,7 +28,7 @@ std::string ph5_licenceSaveStr(){ ...@@ -28,7 +28,7 @@ std::string ph5_licenceSaveStr(){
* @return corresponding string * @return corresponding string
*/ */
std::string ph5_backendTableHeaderOffset(const PTable & table){ std::string ph5_backendTableHeaderOffset(const PTable & table){
std::string body("\t\t"); std::string body("");
const PVecAttribute & vecAttriute = table.getVecAttribute(); const PVecAttribute & vecAttriute = table.getVecAttribute();
for(PVecAttribute::const_iterator it(vecAttriute.begin()); it != vecAttriute.end(); ++it){ for(PVecAttribute::const_iterator it(vecAttriute.begin()); it != vecAttriute.end(); ++it){
body += "\t\tstatic size_t getOffset" + firstToUpper(it->getName()) + "();\n"; body += "\t\tstatic size_t getOffset" + firstToUpper(it->getName()) + "();\n";
...@@ -121,7 +121,7 @@ std::string ph5_backendTableHeader(const PTable & table){ ...@@ -121,7 +121,7 @@ std::string ph5_backendTableHeader(const PTable & table){
*/ */
std::string ph5_backendHeader(const PSource & source){ std::string ph5_backendHeader(const PSource & source){
std::string body(ph5_licenceSaveStr()); std::string body(ph5_licenceSaveStr());
std::string baseMacro("__" + strToUpper(source.getName()) + "_H__"); std::string baseMacro("__" + strToUpper(eraseExtension(source.getName())) + "_H__");
body += "#ifndef " + baseMacro + "\n"; body += "#ifndef " + baseMacro + "\n";
body += "#define " + baseMacro + "\n\n"; body += "#define " + baseMacro + "\n\n";
body += "#include \"H5Cpp.h\"\n\n"; body += "#include \"H5Cpp.h\"\n\n";
...@@ -354,7 +354,7 @@ std::string ph5_backendTableSource(const PTable & table){ ...@@ -354,7 +354,7 @@ std::string ph5_backendTableSource(const PTable & table){
*/ */
std::string ph5_backendSource(const PSource & source){ std::string ph5_backendSource(const PSource & source){
std::string body(ph5_licenceSaveStr()); std::string body(ph5_licenceSaveStr());
body += "#include \""+source.getName()+".h\"\n\n"; body += "#include \""+eraseExtension(source.getName())+".h\"\n\n";
const PVecTable & vecTable = source.getVecTable(); const PVecTable & vecTable = source.getVecTable();
for(PVecTable::const_iterator it(vecTable.begin()); it != vecTable.end(); ++it){ for(PVecTable::const_iterator it(vecTable.begin()); it != vecTable.end(); ++it){
body += ph5_backendTableSource(*it); body += ph5_backendTableSource(*it);
...@@ -370,14 +370,14 @@ std::string ph5_backendSource(const PSource & source){ ...@@ -370,14 +370,14 @@ std::string ph5_backendSource(const PSource & source){
bool ph5_backend(const PSource & source, const std::string & outputDir){ bool ph5_backend(const PSource & source, const std::string & outputDir){
std::string headerSrc(ph5_backendHeader(source)); std::string headerSrc(ph5_backendHeader(source));
std::string sourceSrc(ph5_backendSource(source)); std::string sourceSrc(ph5_backendSource(source));
std::string baseFileName(eraseExtension(source.getName()));
std::string outputHeaderFile(outputDir + "/" + source.getName() + ".h"); std::string outputHeaderFile(outputDir + "/" + baseFileName + ".h");
std::string outputSourceFile(outputDir + "/" + source.getName() + ".cpp"); std::string outputSourceFile(outputDir + "/" + baseFileName + ".cpp");
if(saveFileContent(outputHeaderFile, headerSrc)){ if(!saveFileContent(outputHeaderFile, headerSrc)){
std::cerr << "ph5_backend : cannot save header file '"<<outputHeaderFile<<"'" << std::endl; std::cerr << "ph5_backend : cannot save header file '"<<outputHeaderFile<<"'" << std::endl;
return false; return false;
} }
if(saveFileContent(outputSourceFile, sourceSrc)){ if(!saveFileContent(outputSourceFile, sourceSrc)){
std::cerr << "ph5_backend : cannot save source file '"<<outputSourceFile<<"'" << std::endl; std::cerr << "ph5_backend : cannot save source file '"<<outputSourceFile<<"'" << std::endl;
return false; return false;
} }
......
...@@ -55,6 +55,7 @@ bool ConfigParser::parseFile(){ ...@@ -55,6 +55,7 @@ bool ConfigParser::parseFile(){
p_lastDocString = ""; p_lastDocString = "";
PSource source; PSource source;
source.setName(getFileName(p_parser->getFileName())); source.setName(getFileName(p_parser->getFileName()));
p_parser->skipWhiteSpace();
//To parse the file we need to read char by char until we get something we know //To parse the file we need to read char by char until we get something we know
while(!p_parser->isEndOfFile() && p_run){ //If we are not at the end of the file while(!p_parser->isEndOfFile() && p_run){ //If we are not at the end of the file
PTable table; PTable table;
...@@ -66,6 +67,7 @@ bool ConfigParser::parseFile(){ ...@@ -66,6 +67,7 @@ bool ConfigParser::parseFile(){
errorAt(); errorAt();
std::cerr << "ConfigParser::parseFile : unexpected token '"<<p_parser->getNextToken()<<"'" << std::endl; std::cerr << "ConfigParser::parseFile : unexpected token '"<<p_parser->getNextToken()<<"'" << std::endl;
} }
p_parser->skipWhiteSpace();
} }
p_vecSource.push_back(source); p_vecSource.push_back(source);
return true; return true;
...@@ -104,6 +106,7 @@ bool ConfigParser::parseDocString(){ ...@@ -104,6 +106,7 @@ bool ConfigParser::parseDocString(){
*/ */
bool ConfigParser::parseTable(PTable & table){ bool ConfigParser::parseTable(PTable & table){
std::string tableName(p_parser->getNextToken()); std::string tableName(p_parser->getNextToken());
if(tableName == ""){return true;}
std::string dataSetName(tableName); std::string dataSetName(tableName);
table.setDocString(p_lastDocString); table.setDocString(p_lastDocString);
p_lastDocString = ""; p_lastDocString = "";
...@@ -129,6 +132,7 @@ bool ConfigParser::parseTable(PTable & table){ ...@@ -129,6 +132,7 @@ bool ConfigParser::parseTable(PTable & table){
std::cerr << "ConfigParser::parseTable : cannot parse attribute" << std::endl; std::cerr << "ConfigParser::parseTable : cannot parse attribute" << std::endl;
return true; return true;
} }
p_parser->skipWhiteSpace();
} }
return true; return true;
...@@ -185,6 +189,7 @@ bool ConfigParser::parseAttribute(PAttribute & attr){ ...@@ -185,6 +189,7 @@ bool ConfigParser::parseAttribute(PAttribute & attr){
} }
attr.setName(varName); attr.setName(varName);
attr.setColName(colName); attr.setColName(colName);
attr.setType(type);
return true; return true;
} }
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include "convertToString.h" #include "convertToString.h"
#include "OptionParser.h" #include "OptionParser.h"
#include "pxml_utils.h"
#include "FrontEnd/ConfigParser.h"
#include "BackEnd/backend.h"
using namespace std; using namespace std;
...@@ -34,8 +36,17 @@ OptionParser createOptionParser(){ ...@@ -34,8 +36,17 @@ OptionParser createOptionParser(){
* @return true on success, false otherwise * @return true on success, false otherwise
*/ */
bool createSourceFromConfig(const std::string & inputFile, const std::string & outputDir){ bool createSourceFromConfig(const std::string & inputFile, const std::string & outputDir){
//TODO ConfigParser parser;
return true; if(!parser.load(inputFile)){
std::cerr << "createSourceFromConfig : cannot parse the input file '"<<inputFile<<"'" << std::endl;
return false;
}
PVecSource vecSource = parser.getVecSource();
bool b(ph5_backend(vecSource, outputDir));
if(!b){
std::cerr << "createSourceFromConfig : cannot save source/header from input file '"<<inputFile<<"'" << std::endl;
}
return b;
} }
///Process all the input files ///Process all the input files
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment