本文整理汇总了C++中XmlElement::getFirstChildElement方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlElement::getFirstChildElement方法的具体用法?C++ XmlElement::getFirstChildElement怎么用?C++ XmlElement::getFirstChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlElement
的用法示例。
在下文中一共展示了XmlElement::getFirstChildElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restoreFromXml
void CDPlayer::restoreFromXml(const XmlElement& element, const File& /*projectDirectory*/)
{
setColor(Colour::fromString(element.getStringAttribute("color", "0xffffffff")));
repaint();
XmlElement* boundsXml = element.getChildByName("Bounds");
if (boundsXml)
{
String x = boundsXml->getStringAttribute("x", "0");
String y = boundsXml->getStringAttribute("y", "0");
String width = boundsXml->getStringAttribute("width", "150");
String height = boundsXml->getStringAttribute("height", "150");
getParentComponent()->setBounds(x.getIntValue(), y.getIntValue(), width.getIntValue(), height.getIntValue());
}
else
{
XmlElement* mdiDocumentPosXml = element.getChildByName("MdiDocumentPos");
if (mdiDocumentPosXml->getNumChildElements() > 0 && mdiDocumentPosXml->getFirstChildElement()->isTextElement())
{
getProperties().set("mdiDocumentPos_", mdiDocumentPosXml->getFirstChildElement()->getText());
}
}
XmlElement* nameXml = element.getChildByName("Name");
setName(nameXml->getAllSubText().trim());
XmlElement* driveXml = element.getChildByName("Drive");
m_availableCDsComboBox.selectDrive(driveXml->getAllSubText().trim());
}
示例2: downloadFromServer
bool OwlNestSettings::downloadFromServer(CommandID commandID) {
String nodeString, optionString, warningString;
PropertySet* props = ApplicationConfiguration::getApplicationProperties();
switch (commandID){
case ApplicationCommands::checkForFirmwareUpdates:
warningString = "Beware that this procedure can make your OWL unresponsive!";
nodeString = "firmwares";
optionString = props->getValue("firmware-dfu-options");
break;
case ApplicationCommands::checkForBootloaderUpdates:
warningString = "Beware that this procedure can brick your OWL!";
nodeString = "bootloaders";
optionString = props->getValue("bootloader-dfu-options");
break;
default:
return false;
}
String xmlFilename ("updates.xml");
URL url(props->getValue("owl-updates-dir-url")+xmlFilename);
ScopedPointer<XmlElement> xmlUpdates;
if(url.isWellFormed())
xmlUpdates = url.readEntireXmlStream(0);
if(xmlUpdates == NULL) {
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Connection Error", "Server connection failed");
return false;
}
XmlElement* filesNode = xmlUpdates->getChildByName(nodeString);
StringArray names;
XmlElement* child = filesNode->getFirstChildElement();
while(child != nullptr){
names.add(child->getStringAttribute("name"));
child = child->getNextElement();
}
AlertWindow popup("Download File From Server", "Choose file:", juce::AlertWindow::InfoIcon);
popup.addButton("Cancel", 0, juce::KeyPress(), juce::KeyPress());
popup.addButton("Download", 1, juce::KeyPress(), juce::KeyPress());
popup.addComboBox("box", names);
if(popup.runModalLoop()==0)
return false;
popup.setVisible(false);
String selectedFilename(popup.getComboBoxComponent("box")->getText());
URL fwUrl(props->getValue("owl-updates-dir-url")+selectedFilename);
ScopedPointer<InputStream> strm;
strm = fwUrl.createInputStream(0);
if(strm == NULL){
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Connection Error", "File unavailable", "Continue");
return false;
}
File theTargetFile(ApplicationConfiguration::getApplicationDirectory().getChildFile(selectedFilename));
FileChooser chooser("Save As", theTargetFile, "*.bin");
bool succeeded = false;
if(!chooser.browseForFileToSave(true))
return false;
theTargetFile = chooser.getResult();
TemporaryFile temp (theTargetFile);
ScopedPointer<FileOutputStream> out(temp.getFile().createOutputStream());
if(out != nullptr) {
out->writeFromInputStream(*strm, strm->getTotalLength());
out = nullptr; // deletes the stream
succeeded = temp.overwriteTargetFileWithTemporary();
}
if(!succeeded){
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "File Error", "Failed to save file", "Continue");
return false;
}
if(AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon, "Update Device",
"Would you like to update your OWL with this binary now? "+warningString, "Yes", "No"))
{
DBG("pathName"<< theTargetFile.getFullPathName());
DBG("optionString " << optionString);
return deviceFirmwareUpdate(theTargetFile, optionString);
}
return true;
}