//fixing input parameters
std::vector<std::string> words;
- CDMUtilities::splitter::split(words,name," ",CDMUtilities::splitter::no_empties);
+ CDMUtilities::splitter::split(words,name," '/\"\\,.",CDMUtilities::splitter::no_empties);
std::string nameFixed = "";
for (int i = 0; i < (int)(words.size()); i++)
{
}
words.clear();
- CDMUtilities::splitter::split(words,authors," ",CDMUtilities::splitter::no_empties);
+ CDMUtilities::splitter::split(words,authors," '/\"\\,.",CDMUtilities::splitter::no_empties);
std::string authorFixed;
for (int i = 0; i < (int)(words.size()); i++)
{
words.clear();
std::string descriptionFixed;
- CDMUtilities::splitter::split(words,authorsEmail," ",CDMUtilities::splitter::no_empties);
+ CDMUtilities::splitter::split(words,authorsEmail," '/\"\\,",CDMUtilities::splitter::no_empties);
for (int i = 0; i < (int)(words.size()); i++)
{
- descriptionFixed += words[i];
+ descriptionFixed += words[i] + "/";
}
words.clear();
- CDMUtilities::splitter::split(words,description," ",CDMUtilities::splitter::no_empties);
+ CDMUtilities::splitter::split(words,description," '\"",CDMUtilities::splitter::no_empties);
for (int i = 0; i < (int)(words.size()); i++)
{
descriptionFixed += "_" + words[i];
return NULL;
}
+ //add library to project CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(bbtk_" << nameFixed << "_PKG)" << std::endl;
+ out1.close();
+ }
+
//add library to model
modelCDMPackage* package = new modelCDMPackage(this, this->path + CDMUtilities::SLASH + "bbtk_" + nameFixed + "_PKG", "bbtk_" + nameFixed + "_PKG", this->level + 1);
this->packages.push_back(package);
modelCDMIProjectTreeNode* modelCDMProject::CreateApplication(
const std::string& name,
+ const int& type,
std::string*& result,
const std::string& path
)
{
if(this->appli != NULL)
{
- return this->appli->CreateApplication(name, result);
+ return this->appli->CreateApplication(name, type, result);
}
result = new std::string("there is no appli folder in this project.");
return NULL;
return false;
}
//create plug command
- std::string plugComm = "bbPlugPackage \"" + this->buildPath + "\" > \"" + this->buildPath + CDMUtilities::SLASH + "plugging.log\" 2>&1";
- std::cout << "executing '" << plugComm << "'" << std::endl;
+ std::string plugComm = "bbPlugPackage \"" + this->buildPath + "\"";
+
+ std::string Comm = "gnome-terminal -e \"bash -c \\\"";
+ for (int i = 0; i < plugComm.size(); i++)
+ {
+ if(plugComm[i] == '"')
+ {
+ Comm+="\\\\\\\"";
+ }
+ else if(plugComm[i] == '\\')
+ {
+ Comm+="\\\\\\\\";
+ }
+ else
+ {
+ Comm.push_back(plugComm[i]);
+ }
+ }
+ Comm += "; echo -e '\\a'; bash";
+ Comm += "\\\"\"";
+
+
+ std::cout << "executing '" << Comm << "'" << std::endl;
//execute plug command
- if(system(plugComm.c_str()))
+ if(system(Comm.c_str()))
{
//if there was an error then report it
- result = new std::string("There was an error plugging the packages of the project, please check the plugging.log in the build folder file to read more about the problem.");
+ result = new std::string("There was an error plugging the packages of the project, please check the console to read more about the problem.");
return false;
}
#endif
this->packages[i]->CheckStructure(properties);
}
}
+
+bool modelCDMProject::IsPackageIncluded(const std::string& package_name)
+{
+ if(this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::string line;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ while(line[0]==' ')
+ line.erase(0);
+ if(line[0] != '#')
+ {
+ std::vector<std::string> lineSeg;
+ CDMUtilities::splitter::split(lineSeg,line,"()",CDMUtilities::splitter::no_empties);
+ if(lineSeg.size() > 0 && lineSeg[0] == "ADD_SUBDIRECTORY" && lineSeg[1] == package_name)
+ {
+ CMFile.close();
+ return true;
+ }
+ }
+ }
+ CMFile.close();
+ }
+ }
+ return false;
+}
+
+bool modelCDMProject::SetPackageInclude(const std::string& package_name, const bool& toInclude)
+{
+ if (this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::stringstream outs;
+ std::string line;
+ bool found = false;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ if (CMFile.eof()) {
+ break;
+ }
+ if(line != "")
+ {
+ std::vector<std::string> segs;
+ CDMUtilities::splitter::split(segs, line, " ", CDMUtilities::splitter::no_empties);
+ //is comment
+ if(segs.size() > 0 && segs[0][0] == '#')
+ {
+ if(toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " #()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+ {
+ found = true;
+ outs << "ADD_SUBDIRECTORY(" << package_name << ")\n";
+ }
+ else
+ outs << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ //is not comment
+ else
+ {
+ if (segs.size() > 0 && !toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+ {
+ outs << "#" << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ else
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+ {
+ found = true;
+ }
+ outs << line << "\n";
+ }
+ }
+ }
+ else
+ {
+ outs << "\n";
+ }
+ }
+
+ CMFile.close();
+
+ if(!found && toInclude)
+ outs << "ADD_SUBDIRECTORY(" << package_name << ")\n";
+
+ std::ofstream CMFileOut(this->CMakeLists->GetPath().c_str());
+ if (CMFileOut.is_open())
+ {
+ CMFileOut << outs.rdbuf();
+ CMFileOut.close();
+ return true;
+ }
+ }
+ }
+ return false;
+}