예제 #1
0
void CheckWellFormed(const wxExFileName& fn)
{
  if (fn.GetLexer().GetLanguage() == "xml")
  {
    if (!wxXmlDocument(fn.GetFullPath()).IsOk())
    {
      wxLogStatus("not a valid XML document");
    }
  }
}
예제 #2
0
void clCxxWorkspace::CloseWorkspace()
{
    m_buildMatrix.Reset(NULL);
    if(m_doc.IsOk()) {
        SaveXmlFile();
        m_doc = wxXmlDocument();
    }

    m_fileName.Clear();
    // reset the internal cache objects
    m_projects.clear();

    TagsManagerST::Get()->CloseDatabase();
}
예제 #3
0
bool LocalWorkspace::Create()
{
    m_doc = wxXmlDocument();
    // The idea is to make a name in the format foo.workspace.frodo
    m_fileName = DoGetFilePath();
    m_fileName.MakeAbsolute();

    // Load any previous options. If none, create a blank entry
    m_doc.Load(m_fileName.GetFullPath());
    if(!m_doc.IsOk()) {
        wxXmlNode* root = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("Workspace"));
        m_doc.SetRoot(root);
    }
    return true;
}
예제 #4
0
void clCxxWorkspace::ReloadWorkspace()
{
    m_doc = wxXmlDocument();

    wxLogNull noLog;
    // reset the internal cache objects
    m_projects.clear();

    TagsManager* mgr = TagsManagerST::Get();
    mgr->CloseDatabase();

    wxString err_msg;
    if(!OpenWorkspace(m_fileName.GetFullPath(), err_msg)) {
        wxLogMessage(wxT("Reload workspace: ") + err_msg);
    }
}
예제 #5
0
bool FilesSets::Save(const wxString& filename)
{
    wxXmlDocument *xmldoc = WXDEBUG_NEW wxXmlDocument();
    wxXmlNode *root = WXDEBUG_NEW wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("sets"));
    wxXmlNode *set, *node, *set2;
    wxString value;
    wxString eol = wxT("\012");
    int id1, id2, id3;
    FilesSet *fset;
    NamesSet *nset;

//    root->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));

    fset = GetLastFS(&id1);
    while ( (id1 > 0) && (id1 < GetNextId()) )
    {
        value.Empty();
        value.Printf(wxT("%d"), id1);
        set = WXDEBUG_NEW wxXmlNode(root, wxXML_ELEMENT_NODE, wxT("set"), wxEmptyString, WXDEBUG_NEW wxXmlProperty(wxT("id"), value));
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        nset = fset->GetLastNS(&id2);
        while ( (id2 > 0) && (id2 < fset->GetNextNSId()) )
        {
            value.Empty();
            value.Printf(wxT("%d"), id2);
            set2 = WXDEBUG_NEW wxXmlNode(set, wxXML_ELEMENT_NODE, wxT("names-set"), wxEmptyString, WXDEBUG_NEW wxXmlProperty(wxT("id"), value));
//            set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
            value = nset->GetLastName(&id3);
            while ( (id3 > 0) && (id3 < nset->GetNextId()) )
            {
                node = WXDEBUG_NEW wxXmlNode(set2, wxXML_ELEMENT_NODE, wxT("item"));
                node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, value));
                value.Empty();
                value.Printf(wxT("%d"), id3);
                node->SetProperties(WXDEBUG_NEW wxXmlProperty(wxT("id"), value));
//                set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
                value = nset->GetPrevName(&id3);
            }
            node = WXDEBUG_NEW wxXmlNode(set2, wxXML_ELEMENT_NODE, wxT("path"));
            node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, nset->GetDir()));
//            set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
            node = WXDEBUG_NEW wxXmlNode(set2, wxXML_ELEMENT_NODE, wxT("title"));
            node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, nset->GetTitle()));
//            set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
            nset = fset->GetPrevNS(&id2);
        }
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        node = WXDEBUG_NEW wxXmlNode(set, wxXML_ELEMENT_NODE, wxT("files-set"));
        value.Empty();
        value.Printf(wxT("%d"), fset->GetMainId());
        node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, value));
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        node = WXDEBUG_NEW wxXmlNode(set, wxXML_ELEMENT_NODE, wxT("title"));
        node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, fset->GetTitle()));
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
//        root->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        fset = GetPrevFS(&id1);
    }
    xmldoc->SetRoot(root);

    bool rv = xmldoc->Save(filename, 1);

    delete(xmldoc);

    return rv;
}
예제 #6
0
bool FilesSets::Load(const wxString& filename)
{
    DeleteAllSets();

    wxXmlDocument *xmldoc = WXDEBUG_NEW wxXmlDocument(filename);
    wxXmlNode *root;

    if ( !xmldoc->IsOk() )
    {
        m_error = 100;
        delete(xmldoc);
        return false;
    }

// checking data
    root = xmldoc->GetRoot();
    if (( root->GetType() != wxXML_ELEMENT_NODE ) ||
        ( root->GetName().Cmp(wxT("sets")) != 0 ))
    {
        m_error = 1;
        delete(xmldoc);
        wxLogError(filename + wxT(": Invalid document type. The root node must be 'sets'."));
        return false;
    }
    wxXmlNode *set = root->GetChildren();
    wxString value;
    long lid;
    FilesSet *fset;

    while (set != NULL)
    {
        if (( set->GetType() == wxXML_ELEMENT_NODE ) &&
            ( set->GetName().Cmp(wxT("set")) == 0 ) &&
            (( !set->GetPropVal(wxT("id"), &value) ) ||
            ( !value.ToLong(&lid) ) || ( lid <= 0 )))
        {
            m_error = 2;
            delete(xmldoc);
            wxLogError(filename + wxT(": Attribute 'id' having positive numeric value must be specified for each element 'set'."));
            return false;
        }
        if (( set->GetType() != wxXML_ELEMENT_NODE ) ||
            ( set->GetName().Cmp(wxT("set")) != 0 ))
        {
            set = set->GetNext();
            continue;
        }
        fset = WXDEBUG_NEW FilesSet();
        fset->SetId( (int) lid );
        m_error = CheckFilesSet(set, fset, filename);
        if (m_error)
        {
            delete(fset);
            delete(xmldoc);
            return false;
        }
        if ( !AddSet(fset) )
        {
            m_error = -3;
            delete(fset);
            delete(xmldoc);
            wxLogError(filename + wxT(": Duplicate set for id = %d."), lid);
            return false;
        }
        set = set->GetNext();
    }

    delete(xmldoc);
    return true;
}