void CRXRCReader::ParseXmlDoc (CRXRCResource *resource, wxXmlDocument &doc) const { if (doc.GetRoot ()->GetName () != wxT("resource")) { throw sw::WxLogicErrorException (_("First element must be <resource>")); } wxXmlNode *child = doc.GetRoot ()->GetChildren (); RecursivelyParseXmlNode (child, resource); }
void ProjectManagerXML::writeCodeLine(wxXmlDocument &doc) { wxXmlNode *section, *item; int i; CodeViewItem *cvi; uint total_lines; if (CodeViewLines->GetCount() > 0) { section = new wxXmlNode(doc.GetRoot(), wxXML_ELEMENT_NODE, SECTION_CODEVIEWLINE_STR); total_lines = CodeViewLines->GetCount(); section->AddAttribute(ATTRIBUTE_TOTALLINES_STR, wxString::Format("%d", total_lines)); for (i = (total_lines - 1); i > -1; i--) { cvi = CodeViewLines->getData(i); item = new wxXmlNode(section, wxXML_ELEMENT_NODE, wxString::Format("%s_%d", SUBSECTION_LINE_STR, i)); if (cvi->Org >= 0) item->AddAttribute(ATTRIBUTE_ORG_STR, wxString::Format("%d", cvi->Org)); if (cvi->Dasmitem >= 0) item->AddAttribute(ATTRIBUTE_DASMITEM_STR, wxString::Format("%d", cvi->Dasmitem)); if (cvi->LabelProgAddr > 0) item->AddAttribute(ATTRIBUTE_LINEPROGRAMLABEL_STR, wxString::Format("%d", cvi->LabelProgAddr->Address)); if (cvi->LabelVarAddr > 0) item->AddAttribute(ATTRIBUTE_LINEVARLABEL_STR, wxString::Format("%d", cvi->LabelVarAddr->Address)); if (cvi->Comment) item->AddAttribute(ATTRIBUTE_COMMENT_STR, cvi->Comment->utf8_str()); } } }
void ProjectManagerXML::writeLabel(wxXmlDocument &doc, LabelListCtrl *current_label, const wxString §ion_name) { wxXmlNode *section, *items; wxString str; LabelItem *label; int i; uint j, total_lines; if (!current_label->IsEmpty()) { section = new wxXmlNode(doc.GetRoot(), wxXML_ELEMENT_NODE, section_name); total_lines = current_label->GetCount(); section->AddAttribute(ATTRIBUTE_TOTALLINES_STR, wxString::Format("%d", total_lines)); for (i = (total_lines - 1); i > -1; i--) { label = current_label->GetData(i); if (label) { items = new wxXmlNode(section, wxXML_ELEMENT_NODE, wxString::Format("%s_%d", SUBSECTION_LABEL_STR, i)); items->AddAttribute(label->LabelStr, wxString::Format("%X", label->Address)); if (label->LabelUsers) { str.Clear(); for (j = 0; j < label->LabelUsers->GetCount(); j++) str << wxString::Format(" %d",label->LabelUsers->Item(j)); str.Trim(false); items->AddAttribute(ATTRIBUTE_LABELUSERS_STR, str); } } } } }
/* Saves dasm structure * */ void ProjectManagerXML::writeDasmData(wxXmlDocument &doc) { wxXmlNode *section, *items; int i, c; uint j, arg_aux, total_lines; wxString aux_str; DisassembledItem *de; if (process->Disassembled->GetCount() != 0) { section = new wxXmlNode(doc.GetRoot(), wxXML_ELEMENT_NODE, SECTION_DISASSEMBLED_STR); total_lines = process->Disassembled->GetCount(); section->AddAttribute(ATTRIBUTE_TOTALLINES_STR, wxString::Format("%d", total_lines)); for (i = (total_lines - 1); i > -1; i--) { de = process->Disassembled->GetData(i); items = new wxXmlNode(section, wxXML_ELEMENT_NODE, wxString::Format("%s_%d", SUBSECTION_OPCODE_STR, i)); items->AddAttribute(ATTRIBUTE_OPCODETYPE_STR, wxString::Format("%.2X", de->GetType())); items->AddAttribute(ATTRIBUTE_OPCODELENGTH_STR, wxString::Format("%.2X", de->GetLength())); items->AddAttribute(ATTRIBUTE_OPCODEOFFSET_STR, wxString::Format("%.4X", de->GetOffset())); aux_str.Clear(); for(j = 0; j < de->GetLength(); j++) aux_str << wxString::Format("%.2X ", de->GetByteOpCode(j)); aux_str.Trim(); items->AddAttribute(ATTRIBUTE_OPCODE_STR, aux_str); if (de->GetArgumentCount() > 0) { items->AddAttribute(ATTRIBUTE_ARGUMENTNUM_STR, wxString::Format("%.2X", de->GetArgumentCount())); items->AddAttribute(ATTRIBUTE_ARGUMENTSIZE_STR, wxString::Format("%.2X", de->GetArgumentSize())); arg_aux = de->GetArgumentCount() * de->GetArgumentSize(); aux_str.Clear(); for(j = 0; j < arg_aux; j++) { c = de->GetByteArgument(j); c = c & 0xFF; aux_str << wxString::Format("%.2X ", c); } aux_str.Trim(); items->AddAttribute(ATTRIBUTE_ARGUMENTS_STR, aux_str); } } } }
bool ProjectManagerXML::readHeader(wxXmlDocument &doc) { wxXmlNode *node; wxString str; node = doc.GetRoot(); if (node->GetName() != ROOT_STR) return false; str = node->GetAttribute(ATTRIBUTE_VERSION_STR); if (str.IsEmpty()) LogIt("Version not found !!\n"); else LogIt("Version is " + str + ".\n"); return true; }
void ProjectManagerXML::readCodeLine(wxXmlDocument &doc) { wxXmlNode *section, *node; wxString str; uint total_lines, linecount; long conv; section = findSection(doc.GetRoot()->GetChildren(), SECTION_CODEVIEWLINE_STR); if (!section) { LogIt("Failed to load CodeViewLine section\n"); return; } else LogIt("Found CodeviewLines \n"); str = section->GetAttribute(ATTRIBUTE_TOTALLINES_STR); if (!str.IsEmpty() && str.ToLong(&conv)) { total_lines = static_cast<uint>(conv); } else { LogIt("Fatal error ! TotalLines attribute is missing !\n"); return; } node = section->GetChildren(); linecount = 0; while (node) { if (fillCodeViewLine(node)) linecount++; node = node->GetNext(); } if (linecount != total_lines) LogIt(wxString::Format("Failed code view lines = %d\n", (total_lines - linecount))); }
bool TabgroupManager::DoAddItemToTabgroup( wxXmlDocument& doc, wxXmlNode* node, const wxString& filepath, const wxString& nextitemfilepath) { wxXmlNode* TabInfoArrayNode = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("TabInfoArray")); if(!TabInfoArrayNode) { return false; } // If previousnode is valid, insert the new tab after it wxXmlNode* previousnode = NULL; if(!nextitemfilepath.IsEmpty()) { previousnode = FindTabgroupItem(doc, filepath, nextitemfilepath); } if(previousnode) { return TabInfoArrayNode->InsertChildAfter(node, previousnode); // >=2.8.8 has a convenient function to do this } else { TabInfoArrayNode->AddChild(node); } return true; }
void ProjectManagerXML::writeFileProperties(wxXmlDocument &doc) { wxXmlNode *section, *items; wxString str; section = new wxXmlNode(doc.GetRoot(), wxXML_ELEMENT_NODE, SECTION_FILEPROPERTIES_STR); items = new wxXmlNode(section, wxXML_ELEMENT_NODE, SUBSECTION_FILENAME_STR); items->AddAttribute(ATTRIBUTE_FILENAME_STR, process->Program->GetFileName()); items = new wxXmlNode(section, wxXML_ELEMENT_NODE, SUBSECTION_FILEPATH_STR); items->AddAttribute(ATTRIBUTE_ORIGINALPATH_STR, process->Program->GetFilePath()); switch (process->Program->GetFileType()) { case COM: str = "COM"; break; case BIN: str = "BIN"; break; case ROM: str = "ROM"; break; default: str = "UNKNOWN"; break; } items = new wxXmlNode(section, wxXML_ELEMENT_NODE, SUBSECTION_FILETYPE_STR); items->AddAttribute(ATTRIBUTE_FILETYPE_STR, str); if (process->Program->isCartridge()) { items = new wxXmlNode(section, wxXML_ELEMENT_NODE, SUBSECTION_CARTRIDGE_STR); } items = new wxXmlNode(section, wxXML_ELEMENT_NODE, SUBSECTION_ADDRESS_STR); items->AddAttribute(ATTRIBUTE_STARTADDRESS_STR, wxString::Format("%X", process->Program->StartAddress)); items->AddAttribute(ATTRIBUTE_EXECUTIONADDRESS_STR, wxString::Format("%X", process->Program->ExecAddress)); items->AddAttribute(ATTRIBUTE_ENDADDRESS_STR, wxString::Format("%X", process->Program->EndAddress)); }
void ProjectManagerXML::readLabel(wxXmlDocument &doc, LabelListCtrl *current_label, const wxString &labelstr) { wxXmlNode *node, *section; wxXmlAttribute *attribute; wxString str_name, str_addr, str_users; wxArrayString arrstr; wxArrayInt labelusers; uint addr, i, linecount, total_lines; long conv; section = findSection(doc.GetRoot()->GetChildren(), labelstr); if (section) LogIt("Found label [" + labelstr + "]\n"); else return; str_addr = section->GetAttribute(ATTRIBUTE_TOTALLINES_STR); if (!str_addr.IsEmpty() && str_addr.ToLong(&conv)) { total_lines = static_cast<uint>(conv); } else { LogIt("Fatal error ! TotalLines attribute is missing !\n"); return; } node = section->GetChildren(); linecount = 0; while (node) { attribute = node->GetAttributes(); if (attribute) { str_name = attribute->GetName(); str_addr = attribute->GetValue(); str_users = node->GetAttribute(ATTRIBUTE_LABELUSERS_STR); ParseString(str_users, arrstr); for(i = 0; i < arrstr.Count(); i++) if (arrstr.Item(i).ToLong(&conv)) labelusers.Add(static_cast<int>(conv)); } if (str_addr.ToLong(&conv, 16) && !labelusers.IsEmpty()) { addr = static_cast<uint>(conv); current_label->AddLabel(addr, str_name, labelusers); linkLabels(&labelusers); linecount++; } labelusers.Clear(); str_addr.Clear(); node = node->GetNext(); } if (linecount != total_lines) LogIt(wxString::Format("Failed Labels = %d\n", (total_lines - linecount))); }
bool ProjectManagerXML::readFileProperties(wxXmlDocument &doc) { wxXmlNode *node, *section; wxString str, fullfilename, typeStr; long conv; uint start_address, execution_address, end_address; section = findSection(doc.GetRoot()->GetChildren(), SECTION_FILEPROPERTIES_STR); if (section) { LogIt(wxString::Format("Found Configuration section in line %d !!\n", section->GetLineNumber())); } else { LogIt("Configuration section NOT found !!\n"); return false; } node = findSection(section->GetChildren(), SUBSECTION_FILENAME_STR); if (!node) return false; fullfilename = node->GetAttribute(ATTRIBUTE_FILENAME_STR); if (fullfilename.IsEmpty()) { LogIt("File name NOT found !!\n"); return false; } node = findSection(section->GetChildren(), SUBSECTION_FILEPATH_STR); if (!node) return false; str = node->GetAttribute(ATTRIBUTE_ORIGINALPATH_STR); if (str.IsEmpty()) { LogIt("Original path NOT found !!\n"); return false; } fullfilename = str + "\\" + fullfilename; if (wxFileExists(fullfilename)) LogIt("Original file:" + fullfilename + ", found !!\n"); else { LogIt("Original file NOT found !\n"); return false; } node = findSection(section->GetChildren(), SUBSECTION_FILETYPE_STR); if (!node) return false; typeStr = node->GetAttribute(ATTRIBUTE_FILETYPE_STR); LogIt("File type is " + typeStr + "\n"); node = findSection(section->GetChildren(), SUBSECTION_ADDRESS_STR); if (!node) return false; str = node->GetAttribute(ATTRIBUTE_STARTADDRESS_STR); if (!str.IsEmpty()) { if (!str.ToLong(&conv, 16)) { LogIt("Invalid Start(" + str +") address!\n"); return false; } } LogIt("Start =" + str + "\n"); start_address = conv; str = node->GetAttribute(ATTRIBUTE_EXECUTIONADDRESS_STR); if (!str.IsEmpty()) { if (!str.ToLong(&conv, 16)) { LogIt("Invalid Execution(" + str +") address!\n"); return false; } } LogIt("Execution =" + str + "\n"); execution_address = conv; str = node->GetAttribute(ATTRIBUTE_ENDADDRESS_STR); if (!str.IsEmpty() && !str.ToLong(&conv, 16)) { LogIt("Invalid End(" + str +") address!\n"); return false; } LogIt("End =" + str + "\n"); end_address = conv; process->Program->Open(fullfilename); process->Program->SetStrFileType(typeStr); process->Program->StartAddress = start_address; process->Program->ExecAddress = execution_address; process->Program->EndAddress = end_address; return true; }
wxVariant MacUninstallApp::GetPlistValue( const wxXmlDocument &doc, const wxString &docname, const wxString &keyname) { wxVariant ret; ret.Clear(); if (doc.GetRoot()->GetName() != wxT("plist")) { ::wxLogError(_("Not an XML plist: %s"), docname.c_str()); return ret; } wxXmlNode *child = doc.GetRoot()->GetChildren(); if (child->GetName() != wxT("dict")) { ::wxLogError( _("Invalid plist (missing toplevel <dict> in %s"), docname.c_str()); return ret; } child = child->GetChildren(); bool needkey = true; bool found = false; while (child) { if (needkey) { if (child->GetName() != wxT("key")) { ::wxLogError( _("Invalid plist (expected a key) in %s"), docname.c_str()); return ret; } if (child->GetNodeContent().IsSameAs(keyname)) found = true; } else { if (found) { if (child->GetName().IsSameAs(wxT("array"))) { ::wxLogError( _("Unsupported type array in %s"), docname.c_str()); return ret; } if (child->GetName().IsSameAs(wxT("real"))) { double val; if (!child->GetNodeContent().ToDouble(&val)) { ::wxLogError( _("Invalid plist (invalid real value %s) in %s"), child->GetNodeContent().c_str(), docname.c_str()); } else ret = val; return ret; } if (child->GetName().IsSameAs(wxT("integer"))) { long val; if (!child->GetNodeContent().ToLong(&val)) { ::wxLogError( _("Invalid plist (invalid integer value %s) in %s"), child->GetNodeContent().c_str(), docname.c_str()); } else ret = val; return ret; } if (child->GetName().IsSameAs(wxT("string"))) { ret = child->GetNodeContent(); return ret; } if (child->GetName().IsSameAs(wxT("true")) || child->GetName().IsSameAs(wxT("false"))) { ret = child->GetName().IsSameAs(wxT("true")); return ret; } if (child->GetName().IsSameAs(wxT("date"))) { wxDateTime dt; if (NULL == dt.ParseDateTime(child->GetNodeContent())) { ::wxLogError( _("Invalid plist (invalid date value %s) in %s"), child->GetNodeContent().c_str(), docname.c_str()); } else ret = dt; return ret; } ::wxLogError( _("Invalid plist (unexpected type %s) in %s"), child->GetName().c_str(), docname.c_str()); return ret; } } needkey = (!needkey); child = child->GetNext(); } return ret; }
void MyFrame::SaveConfigToFile() { wxXmlNode* root = config.GetRoot(); wxXmlNode* child = root->GetChildren(); lastCSVPath = toolPanel->GetLastCSVPath(); if (child != 0) { child->DeleteProperty("LastDatabasePath"); child->DeleteProperty("LastDatabaseFile"); child->DeleteProperty("LastCSVPath"); child->AddProperty("LastDatabasePath", lastDatabasePath); child->AddProperty("LastDatabaseFile", lastDatabaseFile); child->AddProperty("LastCSVPath", lastCSVPath); } else { wxASSERT(false); return; } // save page state wxXmlNode* pageState = child->GetNext(); if (pageState == 0) { wxASSERT(false); return; } wxXmlNode* pageChild = pageState->GetChildren(); while (pageChild != 0) { wxXmlNode* nextChild = pageChild->GetNext(); pageState->RemoveChild(pageChild); pageChild = nextChild; } size_t nPages = notebook->GetPageCount(); for (size_t n=0; n<nPages; n++) { wxNotebookPage* notebookPage = notebook->GetPage(n); if (tcBaseViewer* viewer = dynamic_cast<tcBaseViewer*>(notebookPage)) { wxXmlNode* page = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "Page"); page->AddProperty("Table", viewer->GetTable()); page->AddProperty("ItemName", viewer->GetPlatformName()); pageState->AddChild(page); } } // sonar calculation wxXmlNode* sonarConfig = pageState->GetNext(); if (sonarConfig == 0) { wxASSERT(false); return; } tcSonarCalculationControl::Get()->SaveXmlConfig(sonarConfig); // missile calculation wxXmlNode* missileConfig = pageState->GetNext(); if (missileConfig == 0) { wxASSERT(false); return; } tcMissileCalculationControl::Get()->SaveXmlConfig(missileConfig); config.Save("config/config.xml", 4); }
void MyFrame::LoadConfigFromFile() { if (wxFile::Exists("config/config.xml")) { bool success = config.Load("config/config.xml"); } wxXmlNode* root = config.GetRoot(); if (root == 0) { config.SetRoot(new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "Root")); root = config.GetRoot(); } wxXmlNode* child = root->GetChildren(); if (child == 0) { wxXmlNode* pathInfo = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "LastPath"); pathInfo->AddProperty("LastDatabasePath", ""); pathInfo->AddProperty("LastDatabaseFile", ""); pathInfo->AddProperty("LastCSVPath", ""); root->AddChild(pathInfo); } else { lastDatabasePath = child->GetPropVal("LastDatabasePath", ""); lastDatabaseFile = child->GetPropVal("LastDatabaseFile", ""); lastCSVPath = child->GetPropVal("LastCSVPath", ""); toolPanel->SetCSVPath(lastCSVPath); } if (child != 0) child = child->GetNext(); if (child == 0) { wxXmlNode* pageState = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "PageState"); root->AddChild(pageState); } else { wxXmlNode* nextPage = child->GetChildren(); while (nextPage != 0) { wxString table = nextPage->GetPropVal("Table", ""); wxString itemName = nextPage->GetPropVal("ItemName", ""); if (tcBaseViewer* viewer = FindViewerForTable(table)) { viewer->InitializeDatabaseClass(itemName); } nextPage = nextPage->GetNext(); } } // sonar calculation if (child != 0) child = child->GetNext(); if (child == 0) { wxXmlNode* sonarConfig = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "SonarCalculation"); root->AddChild(sonarConfig); } else { wxXmlNode* sonarConfig = child; tcSonarCalculationControl::Get()->LoadXmlConfig(sonarConfig); } // missile calculation if (child != 0) child = child->GetNext(); if (child == 0) { wxXmlNode* missileConfig = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "MissileCalculation"); root->AddChild(missileConfig); } else { wxXmlNode* missileConfig = child; tcMissileCalculationControl::Get()->LoadXmlConfig(missileConfig); } }