Feature: Now reading CMakeLists in CDMUtilities as a data structure.
Fix: Dialog Format on Included Libraries section in Applications, Libraries, Packages.
return res;
}
+ CMLFile readCMLFile(const std::string& file_path)
+ {
+ CMLFile res;
+
+ std::ifstream file(file_path.c_str());
+ if (file.is_open())
+ {
+ char ch = file.get();
+ while (!file.eof())
+ {
+ syntaxElement element;
+ if (isspace(ch))
+ {
+ //std::cout << "space" << std::endl;
+ element.first = "space";
+ element.second.push_back(std::string(1,ch));
+ }
+ else if (ch == '#')
+ {
+ //std::cout << "comment" << std::endl;
+ element.first = "comment";
+ std::string commentValue;
+ while (ch != '\n')
+ {
+ commentValue.push_back(ch);
+
+ ch = file.get();
+ if (file.eof())
+ break;
+ };
+ if (!file.eof())
+ commentValue.push_back('\n');
+ element.second.push_back(commentValue);
+ }
+ else
+ {
+ //std::cout << "command" << std::endl;
+ element.first = "command";
+ std::string commandValue;
+ while (true)
+ {
+ //std::cout << ch;
+ //std::cout.flush();
+ while(!isspace(ch) && ch != '(' && ch != ')' && ch != '#')
+ {
+ if(ch == '"')
+ {
+ if (commandValue.size()) {
+ element.second.push_back(commandValue);
+ commandValue.clear();
+ }
+ commandValue.push_back(ch);
+ ch = file.get();
+ while(!file.eof() && ch != '"')
+ {
+ if(ch == '\\')
+ {
+ commandValue.push_back(ch);
+ ch = file.get();
+ if(!file.eof())
+ commandValue.push_back(ch);
+ }
+ else
+ {
+ commandValue.push_back(ch);
+ }
+ ch = file.get();
+ }
+ if(!file.eof())
+ commandValue.push_back(ch);
+ element.second.push_back(commandValue);
+ commandValue.clear();
+ }
+ else
+ commandValue.push_back(ch);
+
+ ch = file.get();
+ }
+
+ if (!file.eof() && (isspace(ch) || ch == '(' || ch == ')' || ch == '#'))
+ {
+ if (commandValue.size()) {
+ element.second.push_back(commandValue);
+ commandValue.clear();
+ }
+ commandValue.push_back(ch);
+ if (ch == '#') {
+ while (ch != '\n') {
+ ch = file.get();
+ if (file.eof())
+ break;
+ commandValue.push_back(ch);
+ };
+ }
+ element.second.push_back(commandValue);
+ if (commandValue == ")")
+ {
+ commandValue.clear();
+ break;
+ }
+ commandValue.clear();
+ }
+
+ ch = file.get();
+ if (file.eof())
+ break;
+ }
+ }
+ res.push_back(element);
+
+ ch = file.get();
+ if (file.eof())
+ break;
+ }
+
+ file.close();
+ }
+
+/*
+ std::cout << "CMakeLists: " << file_path << std::endl;
+ for (int i = 0; i < res.size(); ++i) {
+ if (res[i].first == "command")
+ std::cout << "@";
+ for (int j = 0; j < res[i].second.size(); ++j) {
+ std::cout << "~" << res[i].second[j];
+ }
+ if (res[i].first == "command")
+ std::cout << "@";
+ }
+ std::cout << "End of file" << std::endl;
+*/
+ return res;
+ }
+
+ bool writeCMLFile(const std::string& file_path, const CMLFile& data)
+ {
+ std::ofstream file(file_path.c_str());
+ if(file.is_open())
+ {
+ for (int i = 0; i < data.size(); ++i) {
+ for (int j = 0; j < data[i].second.size(); ++j) {
+ file << data[i].second[j];
+ }
+ }
+ file.close();
+ return true;
+ }
+ return false;
+ }
+
}
#define CDMUTILITIES_H_
#include<iostream>
+#include<vector>
#include<cstddef>
namespace CDMUtilities
* @return line stringified.
*/
std::string stringify(const std::string& line);
+
+ //CMakeLists file handling
+ /**
+ * Type definition for the value of a syntax element for CMakeLists files
+ */
+ typedef std::vector<std::string> cmdValue;
+
+ /**
+ * Type definition for the type of a syntax element for CMakeLists files
+ */
+ typedef std::string cmdType;
+
+ /**
+ * Type definition for syntax elements of a CMakeLists file
+ */
+ typedef std::pair<cmdType,cmdValue> syntaxElement;
+
+ /**
+ * Type definition for describing a CMakeLists file content
+ */
+ typedef std::vector<syntaxElement> CMLFile;
+
+ /**
+ * Reads a CMakeLists file and returns the read data.
+ * @param file_path Full path of the CMakeLists file.
+ * @return A CMLFile with the contents of the given file.
+ */
+ CMLFile readCMLFile(const std::string& file_path);
+
+ /**
+ * Writes the given data into specified CMakeLists file.
+ * @param file_path Full path of the CMakeLists file.
+ * @param data CMakeLists data.
+ * @return True if the operation was successful.
+ */
+ bool writeCMLFile(const std::string& file_path, const CMLFile& data);
+
};
#endif /* CDMUTILITIES_H_ */
if(this->HasCMakeLists())
{
+ CDMUtilities::readCMLFile(this->CMakeLists->GetPath().c_str());
std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
if (CMFile.is_open())
{
//Includes
wxStaticBoxSizer* includesBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Used Libraries"));
- wxPanel* includesPanel = new wxPanel(this);
+ includesBox->SetMinSize(250,250);
+ wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
//Third Party Libraries
wxFont font = Title1->GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
Title1->SetFont(font);
- includesPanelSizer->Add(Title1, 0, wxEXPAND | wxALL, 5);
+ includesPanelSizer->Add(Title1, 0, wxEXPAND);
//inclusion data
std::map<std::string, bool> inclusions = this->application->Get3rdPartyLibraries();
includesGridSizer->AddGrowableCol(1,1);
- includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND, 0);
+ includesPanelSizer->Add(includesGridSizer, 0, wxEXPAND | wxLEFT, 5);
//Custom Libraries
wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
font = Title2->GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
Title2->SetFont(font);
- includesPanelSizer->Add(Title2, 0, wxEXPAND | wxALL, 5);
+ includesPanelSizer->Add(Title2, 0, wxEXPAND);
//inclusion data
std::map<std::string, bool> inclusionsLibs = this->application->GetCustomLibraries();
includesLibGridSizer->AddGrowableCol(1,1);
- includesPanelSizer->Add(includesLibGridSizer, 1, wxEXPAND, 0);
+ includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
includesPanel->SetSizer(includesPanelSizer);
includesPanelSizer->Fit(includesPanel);
+
+ includesPanel->FitInside();
+ includesPanel->SetScrollRate(5,5);
+
includesBox->Add(includesPanel, 1, wxEXPAND);
sizer -> Add(includesBox, 0, wxALL | wxEXPAND, 10);
//Includes
wxStaticBoxSizer* includesBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Used Libraries"));
- wxPanel* includesPanel = new wxPanel(this);
+ includesBox->SetMinSize(250,250);
+ wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
//Third Party Libraries
wxFont font = Title1->GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
Title1->SetFont(font);
- includesPanelSizer->Add(Title1, 0, wxEXPAND | wxALL, 5);
+ includesPanelSizer->Add(Title1, 0, wxEXPAND);
//inclusion data
std::map<std::string, bool> inclusions = this->library->Get3rdPartyLibraries();
includesGridSizer->AddGrowableCol(1,1);
- includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND, 0);
+ includesPanelSizer->Add(includesGridSizer, 0, wxEXPAND | wxLEFT, 5);
//Custom Libraries
wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
font = Title2->GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
Title2->SetFont(font);
- includesPanelSizer->Add(Title2, 0, wxEXPAND | wxALL, 5);
+ includesPanelSizer->Add(Title2, 0, wxEXPAND);
//inclusion data
std::map<std::string, bool> inclusionsLibs = this->library->GetCustomLibraries();
includesLibGridSizer->AddGrowableCol(1,1);
- includesPanelSizer->Add(includesLibGridSizer, 1, wxEXPAND, 0);
+ includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
includesPanel->SetSizer(includesPanelSizer);
includesPanelSizer->Fit(includesPanel);
+
+ includesPanel->FitInside();
+ includesPanel->SetScrollRate(5,5);
+
includesBox->Add(includesPanel, 1, wxEXPAND);
sizer -> Add(includesBox, 0, wxALL | wxEXPAND, 10);
wxFont font = Title1->GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
Title1->SetFont(font);
- includesPanelSizer->Add(Title1, 0, wxEXPAND | wxALL, 5);
+ includesPanelSizer->Add(Title1, 0, wxEXPAND);
//inclusion data
std::map<std::string, bool> inclusions = this->package->Get3rdPartyLibraries();
includesGridSizer->AddGrowableCol(1,1);
- includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND, 0);
+ includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND | wxLEFT, 5);
//Custom Libraries
wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
font = Title2->GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
Title2->SetFont(font);
- includesPanelSizer->Add(Title2, 0, wxEXPAND | wxALL, 5);
+ includesPanelSizer->Add(Title2, 0, wxEXPAND);
//inclusion data
std::map<std::string, bool> inclusionsLibs = this->package->GetCustomLibraries();
includesLibGridSizer->AddGrowableCol(1,1);
- includesPanelSizer->Add(includesLibGridSizer, 1, wxEXPAND, 0);
+ includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
includesPanel->SetSizer(includesPanelSizer);
- v_sizer1->Add(includesPanel, 1, wxEXPAND);
+ v_sizer1->Add(includesPanel, 1, wxEXPAND | wxALL, 10);
v_sizer1->Add(new wxButton(this, wxID_OK, wxT("Close")), 0, wxALIGN_CENTER | wxRIGHT | wxBOTTOM, 30);