23
23
//////////////////////////////////////////////////////////////////////////////
24
24
//////////////////////////////////////////////////////////////////////////////
25
25
#include "project.h"
26
#include "fileextmanager.h"
26
27
#include "xmlutils.h"
27
28
#include <wx/tokenzr.h>
28
29
#include "wx/arrstr.h"
29
30
#include "dirsaver.h"
31
33
const wxString Project::STATIC_LIBRARY = wxT("Static Library");
32
34
const wxString Project::DYNAMIC_LIBRARY = wxT("Dynamic Library");
335
339
SetModified(true);
342
bool Project::SaveXmlFile()
344
bool ok = m_doc.Save(m_fileName.GetFullPath());
345
SetProjectLastModifiedTime(GetFileLastModifiedTime());
338
350
void Project::Save()
340
352
m_tranActive = false;
341
353
if ( m_doc.IsOk() )
342
m_doc.Save(m_fileName.GetFullPath());
345
357
void Project::GetFilesByVirtualDir(const wxString &vdFullPath, wxArrayString &files)
509
// wxXmlNode *deps = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("Dependencies"));
511
// doc.GetRoot()->RemoveChild(deps);
515
521
// add an empty deps node
516
522
deps = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("Dependencies"));
517
523
doc.GetRoot()->AddChild(deps);
537
543
wxFileName fn = files.at(i);
538
544
wxCopyFile(fn.GetFullPath(), new_path + wxT("/") + fn.GetFullName());
540
// add source file under the 'src' while headers are added under 'include'
541
wxString e(fn.GetExt());
544
546
wxXmlNode *file_node = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("File"));
545
547
file_node->AddProperty(wxT("Name"), fn.GetFullName());
547
if ( e == wxT("cpp") || e == wxT("cxx") || e == wxT("c") || e == wxT("c++") || e == wxT("cc") ) {
549
switch ( FileExtManager::GetType( fn.GetFullName() ) ) {
550
case FileExtManager::TypeSource:
549
553
if ( !srcNode ) {
550
554
srcNode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("VirtualDirectory"));
552
556
doc.GetRoot()->AddChild(srcNode);
554
558
srcNode->AddChild(file_node);
556
} else if ( e == wxT("h") || e == wxT("hpp") || e == wxT("h++") || e == wxT("hxx")|| e == wxT("hh") || e == wxT("inc") || e == wxT("inl") ) {
561
case FileExtManager::TypeHeader:
559
564
headNode = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("VirtualDirectory"));
896
904
return m_doc.GetRoot()->GetPropVal(wxT("InternalType"), wxEmptyString);
907
void Project::GetAllPluginsData(std::map<wxString, wxString>& pluginsDataMap)
913
// locate the 'Plugins' node
914
wxXmlNode *plugins = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("Plugins"));
919
wxXmlNode *child = plugins->GetChildren();
921
if( child->GetName() == wxT("Plugin") ) {
923
pluginsDataMap[child->GetPropVal(wxT("Name"), wxEmptyString)] = child->GetNodeContent();
925
child = child->GetNext();
929
wxString Project::GetPluginData(const wxString& pluginName)
932
return wxEmptyString;
935
// locate the 'Plugins' node
936
wxXmlNode *plugins = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("Plugins"));
938
return wxEmptyString;
941
// find the node and return its content
942
wxXmlNode *dataNode = XmlUtils::FindNodeByName(plugins, wxT("Plugin"), pluginName);
944
return dataNode->GetNodeContent();
946
return wxEmptyString;
949
void Project::SetPluginData(const wxString& pluginName, const wxString& data)
955
// locate the 'Plugins' node
956
wxXmlNode *plugins = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("Plugins"));
958
plugins = new wxXmlNode(m_doc.GetRoot(), wxXML_ELEMENT_NODE, wxT("Plugins"));
961
wxXmlNode *plugin = XmlUtils::FindNodeByName(plugins, wxT("Plugin"), pluginName);
963
plugin = new wxXmlNode(plugins, wxXML_ELEMENT_NODE, wxT("Plugin"));
964
plugin->AddProperty(wxT("Name"), pluginName);
967
XmlUtils::SetCDATANodeContent(plugin, data);
972
void Project::SetAllPluginsData(const std::map<wxString, wxString>& pluginsDataMap)
978
// locate the 'Plugins' node
979
wxXmlNode *plugins = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("Plugins"));
981
m_doc.GetRoot()->RemoveChild( plugins );
985
std::map<wxString, wxString>::const_iterator iter = pluginsDataMap.begin();
986
for(; iter != pluginsDataMap.end(); iter ++) {
987
SetPluginData( iter->first, iter->second );
992
time_t Project::GetFileLastModifiedTime() const
994
return GetFileModificationTime(GetFileName());