本文整理汇总了C++中TiXmlDocument::SetCondenseWhiteSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlDocument::SetCondenseWhiteSpace方法的具体用法?C++ TiXmlDocument::SetCondenseWhiteSpace怎么用?C++ TiXmlDocument::SetCondenseWhiteSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlDocument
的用法示例。
在下文中一共展示了TiXmlDocument::SetCondenseWhiteSpace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetXmlFile
// Opens the specified XML file if it exists or creates a new one otherwise.
// Returns 0 on error.
TiXmlElement* GetXmlFile(wxFileName file, bool create /*=true*/, wxString* error /*=0*/)
{
if (wxFileExists(file.GetFullPath()) && file.GetSize() > 0)
{
// File does exist, open it
TiXmlDocument* pXmlDocument = new TiXmlDocument;
pXmlDocument->SetCondenseWhiteSpace(false);
if (!LoadXmlDocument(pXmlDocument, file.GetFullPath(), error))
{
delete pXmlDocument;
return 0;
}
TiXmlElement* pElement = pXmlDocument->FirstChildElement("FileZilla3");
if (!pElement)
{
if (pXmlDocument->FirstChildElement())
{
// Not created by FileZilla3
delete pXmlDocument;
if (error)
*error = _("Unknown root element, the file does not appear to be generated by FileZilla.");
return 0;
}
pElement = pXmlDocument->LinkEndChild(new TiXmlElement("FileZilla3"))->ToElement();
}
return pElement;
}
else
{
// File does not exist
if (!create)
return 0;
// create new XML document
TiXmlDocument* pXmlDocument = new TiXmlDocument();
pXmlDocument->SetCondenseWhiteSpace(false);
pXmlDocument->LinkEndChild(new TiXmlDeclaration("1.0", "UTF-8", "yes"));
pXmlDocument->LinkEndChild(new TiXmlElement("FileZilla3"));
if (!SaveXmlFile(file, pXmlDocument, 0))
{
delete pXmlDocument;
return 0;
}
return pXmlDocument->FirstChildElement("FileZilla3");
}
}
示例2: GetXmlFile
// Opens the specified XML file if it exists or creates a new one otherwise.
// Returns 0 on error.
TiXmlElement* GetXmlFile(wxFileName file)
{
if (wxFileExists(file.GetFullPath()) && file.GetSize() > 0)
{
// File does exist, open it
TiXmlDocument* pXmlDocument = new TiXmlDocument();
pXmlDocument->SetCondenseWhiteSpace(false);
if (!pXmlDocument->LoadFile(file.GetFullPath().mb_str()))
{
delete pXmlDocument;
return 0;
}
if (!pXmlDocument->FirstChildElement("FileZilla3"))
{
delete pXmlDocument;
return 0;
}
TiXmlElement* pElement = pXmlDocument->FirstChildElement("FileZilla3");
if (!pElement)
{
delete pXmlDocument;
return 0;
}
else
return pElement;
}
else
{
// File does not exist, create new XML document
TiXmlDocument* pXmlDocument = new TiXmlDocument();
pXmlDocument->SetCondenseWhiteSpace(false);
pXmlDocument->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
pXmlDocument->InsertEndChild(TiXmlElement("FileZilla3"));
if (!pXmlDocument->SaveFile(file.GetFullPath().mb_str()))
{
delete pXmlDocument;
return 0;
}
return pXmlDocument->FirstChildElement("FileZilla3");
}
}
示例3: LoadXML
void CSvsFile::LoadXML()
{
UnloadXML();
TiXmlDocument XmlDoc;
XmlDoc.SetCondenseWhiteSpace(false);
ifstream iXML( m_strFile.c_str() );
if (!iXML)
{
GenErr("技能配置表转换文件读取错误", m_strFile);
}
iXML>>XmlDoc;
iXML.close();
TiXmlNode* pBody = XmlDoc.FirstChild("body");
TiXmlNode* pTable = pBody->FirstChild("table");
for ( TiXmlNode* pTr = pTable->FirstChild(); pTr; pTr = pTr->NextSibling() )
{
TiXmlElement* pElemet = pTr->ToElement();
if (!pElemet)
continue;
if(pElemet->ValueStr() != "tr")
continue;
m_vecTR.resize(m_vecTR.size() + 1);
TableRow& vecTD = m_vecTR.back();
for ( TiXmlNode* pTd = pTr->FirstChild(); pTd; pTd=pTd->NextSibling() )
{
TiXmlElement* pElemet = pTd->ToElement();
if (!pElemet)
continue;
if(pElemet->ValueStr() != "td")
continue;
TiXmlNode* pParagraph = pTd->FirstChild();
TiXmlElement* pParaElemet = pParagraph->ToElement();
if(!pParaElemet || pParaElemet->ValueStr() != "p")
{
GenErr("<td>读取<p>不存在");
}
TableData aTD;
aTD.m_eTDType = GetTableDataType(pParaElemet->Attribute("t"));
if(pParaElemet->FirstChild())
{
aTD.m_sTDValue = utf8_to_gbk(pParaElemet->GetText());
XMLDecode(aTD.m_sTDValue);
}
vecTD.push_back(aTD);
}
}
}
示例4: Save
bool WorkspaceLoader::Save(const wxString& title, const wxString& filename)
{
const char* ROOT_TAG = "CodeBlocks_workspace_file";
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
TiXmlElement* rootnode = static_cast<TiXmlElement*>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
if (!rootnode)
return false;
TiXmlElement* wksp = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("Workspace")));
wksp->SetAttribute("title", cbU2C(title));
ProjectsArray* arr = Manager::Get()->GetProjectManager()->GetProjects();
for (unsigned int i = 0; i < arr->GetCount(); ++i)
{
cbProject* prj = arr->Item(i);
wxFileName wfname(filename);
wxFileName fname(prj->GetFilename());
fname.MakeRelativeTo(wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
TiXmlElement* node = static_cast<TiXmlElement*>(wksp->InsertEndChild(TiXmlElement("Project")));
node->SetAttribute("filename", cbU2C( ExportFilename(fname) ) );
if (prj == Manager::Get()->GetProjectManager()->GetActiveProject())
node->SetAttribute("active", 1);
const ProjectsArray* deps = Manager::Get()->GetProjectManager()->GetDependenciesForProject(prj);
if (deps && deps->GetCount())
{
for (size_t i = 0; i < deps->GetCount(); ++i)
{
prj = deps->Item(i);
fname.Assign(prj->GetFilename());
fname.MakeRelativeTo(wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
TiXmlElement* dnode = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("Depends")));
dnode->SetAttribute("filename", cbU2C( ExportFilename(fname) ) );
}
}
}
return cbSaveTinyXMLDocument(&doc, filename);
}
示例5: parseXml
void MCF::parseXml(char* buff, uint32 buffLen)
{
if (m_bStopped)
return;
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.LoadBuffer(buff, buffLen);
TiXmlNode *fNode = doc.FirstChild("files");
if (!fNode)
throw gcException(ERR_XML_NOPRIMENODE);
TiXmlElement* pChild = fNode->FirstChildElement();
while (pChild)
{
if (m_bStopped)
return;
MCFCore::MCFFile* temp = new MCFCore::MCFFile();
try
{
temp->loadXmlData(pChild);
m_pFileList.push_back( temp );
}
catch (gcException &)
{
safe_delete(temp);
}
pChild = pChild->NextSiblingElement();
}
}
示例6: Save
bool ProjectLayoutLoader::Save(const wxString& filename)
{
const char* ROOT_TAG = "CodeBlocks_layout_file";
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
TiXmlElement* rootnode = static_cast<TiXmlElement*>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
if (!rootnode)
return false;
rootnode->InsertEndChild(TiXmlElement("FileVersion"));
rootnode->FirstChildElement("FileVersion")->SetAttribute("major", PROJECT_LAYOUT_FILE_VERSION_MAJOR);
rootnode->FirstChildElement("FileVersion")->SetAttribute("minor", PROJECT_LAYOUT_FILE_VERSION_MINOR);
TiXmlElement* tgtidx = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("ActiveTarget")));
tgtidx->SetAttribute("name", cbU2C(m_pProject->GetActiveBuildTarget()));
ProjectFile* active = nullptr;
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (ed)
active = ed->GetProjectFile();
for (FilesList::iterator it = m_pProject->GetFilesList().begin(); it != m_pProject->GetFilesList().end(); ++it)
{
ProjectFile* f = *it;
if (f->editorOpen || f->editorPos || f->editorPos_2 || f->editorTopLine || f->editorTopLine_2 || f->editorTabPos)
{
TiXmlElement* node = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("File")));
node->SetAttribute("name", cbU2C(f->relativeFilename));
node->SetAttribute("open", f->editorOpen);
node->SetAttribute("top", (f == active));
node->SetAttribute("tabpos", f->editorTabPos);
node->SetAttribute("split", f->editorSplit);
node->SetAttribute("active", f->editorSplitActive);
node->SetAttribute("splitpos", f->editorSplitPos);
node->SetAttribute("zoom_1", f->editorZoom);
node->SetAttribute("zoom_2", f->editorZoom_2);
TiXmlElement* cursor = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("Cursor")));
TiXmlElement* cursor_1 = static_cast<TiXmlElement*>(cursor->InsertEndChild(TiXmlElement("Cursor1")));
cursor_1->SetAttribute("position", f->editorPos);
cursor_1->SetAttribute("topLine", f->editorTopLine);
if(f->editorSplit != cbEditor::stNoSplit)
{
TiXmlElement* cursor_2 = static_cast<TiXmlElement*>(cursor->InsertEndChild(TiXmlElement("Cursor2")));
cursor_2->SetAttribute("position", f->editorPos_2);
cursor_2->SetAttribute("topLine", f->editorTopLine_2);
}
if (f->editorFoldLinesArray.GetCount() > 0)
{
TiXmlElement* folding = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("Folding")));
for (unsigned int i = 0; i < f->editorFoldLinesArray.GetCount(); i++)
{
TiXmlElement* line = static_cast<TiXmlElement*>(folding->InsertEndChild(TiXmlElement("Collapse")));
line->SetAttribute("line", f->editorFoldLinesArray[i]);
}
}
}
}
const wxArrayString& en = m_pProject->ExpandedNodes();
for (unsigned int i = 0; i < en.GetCount(); ++i)
{
if (!en[i].IsEmpty())
{
TiXmlElement* node = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("Expand")));
node->SetAttribute("folder", cbU2C(en[i]));
}
}
if (Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/enable_editor_layout"), false))
{
TiXmlElement *el =
static_cast<TiXmlElement*>(
rootnode->InsertEndChild( TiXmlElement("EditorTabsLayout") ) );
el->SetAttribute("layout", cbU2C( Manager::Get()->GetEditorManager()->GetNotebook()->SavePerspective(m_pProject->GetTitle()) ));
}
// else ?!
return cbSaveTinyXMLDocument(&doc, filename);
}
示例7: getDownloadProviders
void MCF::getDownloadProviders(const char* url, MCFCore::Misc::UserCookies *pCookies, bool *unauthed, bool local)
{
if (!pCookies)
throw gcException(ERR_INVALID, "Cookies are null (getDownloadProviders)");
HttpHandle wc(url);
pCookies->set(wc);
DesuraId id = m_sHeader->getDesuraId();
gcString type = id.getTypeString();
wc->addPostText("siteareaid", id.getItem());
wc->addPostText("sitearea", type.c_str());
wc->addPostText("branch", m_sHeader->getBranch());
MCFBuild build = m_sHeader->getBuild();
if (build != 0)
wc->addPostText("build", build);
if (local)
wc->addPostText("local", "yes");
wc->postWeb();
if (wc->getDataSize() == 0)
throw gcException(ERR_BADRESPONSE);
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
XML::loadBuffer(doc, const_cast<char*>(wc->getData()), wc->getDataSize());
TiXmlNode *uNode = doc.FirstChild("itemdownloadurl");
if (!uNode)
throw gcException(ERR_BADXML);
TiXmlNode* sNode = uNode->FirstChild("status");
if (!sNode)
throw gcException(ERR_BADXML);
uint32 status = 0;
TiXmlElement* sEl = sNode->ToElement();
if (sEl)
{
const char* statStr = sEl->Attribute("code");
if (statStr)
status = atoi(statStr);
else
throw gcException(ERR_BADXML);
}
else
{
throw gcException(ERR_BADXML);
}
if (status != 0)
throw gcException(ERR_BADSTATUS, status, gcString("Status: {0}", sEl->GetText()));
TiXmlNode* iNode = uNode->FirstChild("item");
if (!iNode)
{
throw gcException(ERR_BADXML);
}
TiXmlNode* mNode = iNode->FirstChild("mcf");
if (!mNode)
{
throw gcException(ERR_BADXML);
}
TiXmlElement *melNode = mNode->ToElement();
if (melNode)
{
const char* build = melNode->Attribute("build");
const char* branch = melNode->Attribute("branch");
//Debug(gcString("MCF: R: {0}.{1} G: {2}.{3}\n", m_sHeader->getBranch(), m_sHeader->getBuild(), build, branch));
if (build)
m_sHeader->setBuild(MCFBuild::BuildFromInt(atoi(build)));
if (branch)
m_sHeader->setBranch(MCFBranch::BranchFromInt(atoi(branch)));
}
safe_delete(m_pFileAuth);
char *szAuthCode = NULL;
XML::GetChild("authhash", szAuthCode, mNode);
if (!szAuthCode)
throw gcException(ERR_BADXML);
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
TiXmlDeclaration dec;
dec.Parse( "<?xml version='1.0' encoding='UTF-8'?>", 0, TIXML_ENCODING_UNKNOWN );
TiXmlDeclaration decCopy( dec );
TiXmlDeclaration decAssign;
decAssign = dec;
XmlTest( "Copy/Assign: declaration copy.", "UTF-8", decCopy.Encoding() );
XmlTest( "Copy/Assign: text assign.", "UTF-8", decAssign.Encoding() );
TiXmlDocument doc;
elementCopy.InsertEndChild( textCopy );
doc.InsertEndChild( decAssign );
doc.InsertEndChild( elementCopy );
doc.InsertEndChild( unknownAssign );
TiXmlDocument docCopy( doc );
TiXmlDocument docAssign;
docAssign = docCopy;
#ifdef TIXML_USE_STL
std::string original, copy, assign;
original << doc;
copy << docCopy;
assign << docAssign;
XmlTest( "Copy/Assign: document copy.", original.c_str(), copy.c_str(), true );
XmlTest( "Copy/Assign: document assign.", original.c_str(), assign.c_str(), true );
#endif
}
//////////////////////////////////////////////////////
#ifdef TIXML_USE_STL
printf ("\n** Parsing, no Condense Whitespace **\n");
TiXmlBase::SetCondenseWhiteSpace( false );
{
istringstream parse1( "<start>This is \ntext</start>" );
TiXmlElement text1( "text" );
parse1 >> text1;
XmlTest ( "Condense white space OFF.", "This is \ntext",
text1.FirstChild()->Value(),
true );
}
TiXmlBase::SetCondenseWhiteSpace( true );
#endif
//////////////////////////////////////////////////////
// GetText();
{
const char* str = "<foo>This is text</foo>";
TiXmlDocument doc;
doc.Parse( str );
const TiXmlElement* element = doc.RootElement();
XmlTest( "GetText() normal use.", "This is text", element->GetText() );
str = "<foo><b>This is text</b></foo>";
doc.Clear();
doc.Parse( str );
element = doc.RootElement();
XmlTest( "GetText() contained element.", element->GetText() == 0, true );
str = "<foo>This is <b>text</b></foo>";
doc.Clear();
TiXmlBase::SetCondenseWhiteSpace( false );
示例9: Show
void CImportDialog::Show()
{
wxFileDialog dlg(m_parent, _("Select file to import settings from"), _T(""),
_T("FileZilla.xml"), _T("XML files (*.xml)|*.xml"),
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
dlg.CenterOnParent();
if (dlg.ShowModal() != wxID_OK)
return;
wxFileName fn(dlg.GetPath());
const wxString& path = fn.GetPath();
const wxString& settings(COptions::Get()->GetOption(OPTION_DEFAULT_SETTINGSDIR));
if (path == settings)
{
wxMessageBox(_("You cannot import settings from FileZilla's own settings directory."), _("Error importing"), wxICON_ERROR, m_parent);
return;
}
TiXmlDocument* xmlDocument = new TiXmlDocument();
xmlDocument->SetCondenseWhiteSpace(false);
if (!LoadXmlDocument(xmlDocument, dlg.GetPath()))
{
delete xmlDocument;
wxMessageBox(_("Cannot load file, not a valid XML file."), _("Error importing"), wxICON_ERROR, m_parent);
return;
}
TiXmlElement* fz3Root = xmlDocument->FirstChildElement("FileZilla3");
TiXmlElement* fz2Root = xmlDocument->FirstChildElement("FileZilla");
if (fz3Root)
{
bool settings = fz3Root->FirstChildElement("Settings") != 0;
bool queue = fz3Root->FirstChildElement("Queue") != 0;
bool sites = fz3Root->FirstChildElement("Servers") != 0;
if (settings || queue || sites)
{
Load(m_parent, _T("ID_IMPORT"));
if (!queue)
XRCCTRL(*this, "ID_QUEUE", wxCheckBox)->Hide();
if (!sites)
XRCCTRL(*this, "ID_SITEMANAGER", wxCheckBox)->Hide();
if (!settings)
XRCCTRL(*this, "ID_SETTINGS", wxCheckBox)->Hide();
Fit();
if (ShowModal() != wxID_OK)
{
delete xmlDocument;
return;
}
if (queue && XRCCTRL(*this, "ID_QUEUE", wxCheckBox)->IsChecked())
{
m_pQueueView->ImportQueue(fz3Root->FirstChildElement("Queue"), true);
}
if (sites && XRCCTRL(*this, "ID_SITEMANAGER", wxCheckBox)->IsChecked())
{
ImportSites(fz3Root->FirstChildElement("Servers"));
}
if (settings && XRCCTRL(*this, "ID_SETTINGS", wxCheckBox)->IsChecked())
{
COptions::Get()->Import(fz3Root->FirstChildElement("Settings"));
wxMessageBox(_("The settings have been imported. You have to restart FileZilla for all settings to have effect."), _("Import successful"), wxOK, this);
}
wxMessageBox(_("The selected categories have been imported."), _("Import successful"), wxOK, this);
delete xmlDocument;
return;
}
}
else if (fz2Root)
{
bool sites_fz2 = fz2Root->FirstChildElement("Sites") != 0;
if (sites_fz2)
{
int res = wxMessageBox(_("The file you have selected contains site manager data from a previous version of FileZilla.\nDue to differences in the storage format, only host, port, username and password will be imported.\nContinue with the import?"),
_("Import data from older version"), wxICON_QUESTION | wxYES_NO);
if (res == wxYES)
ImportLegacySites(fz2Root->FirstChildElement("Sites"));
delete xmlDocument;
return;
}
}
delete xmlDocument;
wxMessageBox(_("File does not contain any importable data."), _("Error importing"), wxICON_ERROR, m_parent);
}
示例10: Save
// ----------------------------------------------------------------------------
bool BrowseTrackerLayout::Save(const wxString& filename, FileBrowse_MarksHash& m_FileBrowse_MarksArchive, FileBrowse_MarksHash& m_EdBook_MarksArchive)
// ----------------------------------------------------------------------------
{
////DumpBrowse_Marks(wxT("BookMarks"), m_FileBrowse_MarksArchive, m_EdBook_MarksArchive);
const char* ROOT_TAG = "BrowseTracker_layout_file";
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
TiXmlElement* rootnode = static_cast<TiXmlElement*>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
if (!rootnode)
return false;
TiXmlElement* tgtidx = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("ActiveTarget")));
tgtidx->SetAttribute("name", cbU2C(m_pProject->GetActiveBuildTarget()));
ProjectFile* active = 0L;
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (ed)
active = ed->GetProjectFile();
int count = m_pProject->GetFilesCount();
for (int i = 0; i < count; ++i)
{
ProjectFile* f = m_pProject->GetFile(i);
if (f->editorOpen || f->editorPos || f->editorTopLine || f->editorTabPos)
{
TiXmlElement* node = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("File")));
node->SetAttribute("name", cbU2C(f->relativeFilename));
node->SetAttribute("open", f->editorOpen);
node->SetAttribute("top", (f == active));
node->SetAttribute("tabpos", f->editorTabPos);
TiXmlElement* cursor = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("Cursor")));
cursor->SetAttribute("position", f->editorPos);
cursor->SetAttribute("topLine", f->editorTopLine);
EditorBase* eb = 0;
// write out a string of browse mark positions
#if defined(LOGGING)
////LOGIT( _T("ProjectFilename[%s]"),f->file.GetFullPath().c_str() );
#endif
eb = Manager::Get()->GetEditorManager()->GetEditor(f->file.GetFullPath());
#if defined(LOGGING)
////if (eb) LOGIT( _T("EditorBase Filename[%d][%s]"), i, eb->GetFilename().c_str() );
#endif
////if(eb) if (f->file.GetFullPath() != eb->GetFilename())
////{
//// #if defined(LOGGING)
//// LOGIT( _T("NAME MISSMATCH ProjectFile[%s]EditorBase[%s]"), f->file.GetFullPath().c_str(), eb->GetFilename().c_str() );
//// #endif
////}
//// #if defined(LOGGING)
//// if (m_FileBrowse_MarksArchive.find(eb) != m_FileBrowse_MarksArchive.end() )
//// LOGIT( _T("Found eb[%p][%s]"), eb, eb->GetShortName().c_str() );
//// else{
//// int i = 0;
//// for (EbBrowse_MarksHash::iterator it = m_FileBrowse_MarksArchive.begin();
//// it != m_FileBrowse_MarksArchive.end(); ++it)
//// {
//// #if defined(LOGGING)
//// LOGIT( _T("m_FileBrowse_MarksArchive[i][%d][%p]"), i, it->first );
//// #endif
//// ++i;
//// }
//// }
//// #endif
#if defined(LOGGING)
////LOGIT( _T("Layout processing for[%s]"),/*f->relativeFilename.c_str(),*/ f->file.GetFullPath().c_str() );
#endif
// Save the BrowseMarks
FileBrowse_MarksHash::iterator it = m_FileBrowse_MarksArchive.find(f->file.GetFullPath());
if (it != m_FileBrowse_MarksArchive.end() ) do
{
BrowseMarks* pBrowse_Marks = it->second;
if (not pBrowse_Marks) break;
wxString browseMarks = pBrowse_Marks->GetStringOfBrowse_Marks();
#if defined(LOGGING)
////LOGIT( _T("Layout writing BROWSEMarkString [%p]is[%s]"), pBrowse_Marks, browseMarks.c_str());
#endif
TiXmlElement* btMarks = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("BrowseMarks")));
btMarks->SetAttribute("positions", cbU2C(browseMarks));
}while(0);
////else{
//// #if defined(LOGGING)
//// LOGIT( _T("Browse_Marks failed find for[%s]"), f->file.GetFullPath().c_str() );
//// #endif
////}
// Save the Book_Marks
it = m_EdBook_MarksArchive.find(f->file.GetFullPath());
if (it != m_EdBook_MarksArchive.end() ) do
{
BrowseMarks* pBook_Marks = it->second;
if (not pBook_Marks) break;
wxString bookMarks = pBook_Marks->GetStringOfBrowse_Marks();
//.........这里部分代码省略.........
示例11: Save
// ----------------------------------------------------------------------------
bool BrowseTrackerLayout::Save(const wxString& filename, FileBrowse_MarksHash& m_FileBrowse_MarksArchive)
// ----------------------------------------------------------------------------
{
//DumpBrowse_Marks(wxT("BookMarks"), m_FileBrowse_MarksArchive, m_EdBook_MarksArchive);
const char* ROOT_TAG = "BrowseTracker_layout_file";
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
TiXmlElement* rootnode = static_cast<TiXmlElement*>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
if (!rootnode)
return false;
TiXmlElement* tgtidx = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("ActiveTarget")));
tgtidx->SetAttribute("name", cbU2C(m_pProject->GetActiveBuildTarget()));
ProjectFile* active = 0L;
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (ed)
active = ed->GetProjectFile();
for (FilesList::iterator it = m_pProject->GetFilesList().begin(); it != m_pProject->GetFilesList().end(); ++it)
{
ProjectFile* f = *it;
if (f->editorOpen || f->editorPos || f->editorTopLine || f->editorTabPos)
{
TiXmlElement* node = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("File")));
node->SetAttribute("name", cbU2C(f->relativeFilename));
node->SetAttribute("open", f->editorOpen);
node->SetAttribute("top", (f == active));
node->SetAttribute("tabpos", f->editorTabPos);
TiXmlElement* cursor = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("Cursor")));
cursor->SetAttribute("position", f->editorPos);
cursor->SetAttribute("topLine", f->editorTopLine);
// Save the BrowseMarks
FileBrowse_MarksHash::iterator it2 = m_FileBrowse_MarksArchive.find(f->file.GetFullPath());
if (it2 != m_FileBrowse_MarksArchive.end() ) do
{
const BrowseMarks* pBrowse_Marks = it2->second;
if (not pBrowse_Marks) break;
wxString browseMarks = pBrowse_Marks->GetStringOfBrowse_Marks();
#if defined(LOGGING)
//LOGIT( _T("Layout writing BROWSEMarkString [%p]is[%s]"), pBrowse_Marks, browseMarks.c_str());
#endif
TiXmlElement* btMarks = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("BrowseMarks")));
btMarks->SetAttribute("positions", cbU2C(browseMarks));
}while(0);
}
}//for
const wxArrayString& en = m_pProject->ExpandedNodes();
for (unsigned int i = 0; i < en.GetCount(); ++i)
{
if (!en[i].IsEmpty())
{
TiXmlElement* node = static_cast<TiXmlElement*>(rootnode->InsertEndChild(TiXmlElement("Expand")));
node->SetAttribute("folder", cbU2C(en[i]));
}
}
return cbSaveTinyXMLDocument(&doc, filename);
}