CtrlrIDManager::CtrlrIDManager() : ctrlrIdTree(Ids::ctrlr) { XmlDocument contstantsDoc (String (BinaryData::CtrlrIDs_xml, BinaryData::CtrlrIDs_xmlSize)); XmlDocument vendorsDoc (String (BinaryData::CtrlrMIDIVendors_xml, BinaryData::CtrlrMIDIVendors_xmlSize)); { ScopedPointer <XmlElement> xml (contstantsDoc.getDocumentElement()); if (xml) { ctrlrIdTree = ValueTree::fromXml (*xml); if (ctrlrIdTree.isValid()) constantsTree = ctrlrIdTree.getChildWithName ("constants"); } } { ScopedPointer <XmlElement> xml (vendorsDoc.getDocumentElement()); if (xml) { vendorTree = ValueTree::fromXml (*xml); if (vendorTree.isValid()) { /* let's sort it alphabeticaly */ VendorComparator c; vendorTree.sort (c, nullptr, false); } } } }
//============================================================================== Drawable* Drawable::createFromImageData (const void* data, const size_t numBytes) { Drawable* result = 0; Image image (ImageFileFormat::loadFrom (data, (int) numBytes)); if (image.isValid()) { DrawableImage* const di = new DrawableImage(); di->setImage (image); result = di; } else { const String asString (String::createStringFromData (data, (int) numBytes)); XmlDocument doc (asString); ScopedPointer <XmlElement> outer (doc.getDocumentElement (true)); if (outer != 0 && outer->hasTagName ("svg")) { ScopedPointer <XmlElement> svg (doc.getDocumentElement()); if (svg != 0) result = Drawable::createFromSVG (*svg); } } return result; }
void TextEditorWindow::importTrigger() { TextBuffer* buf=getTextBuffer(); String str=(buf->isRegion()) ? buf->getRegion() : buf->getLineAtPoint(); int a=str.indexOf(T("<trigger")); int b=str.lastIndexOf(T("/>")); if (a>=0 && a<b) { XmlDocument doc (str.substring(a,b)); XmlElement* xml=doc.getDocumentElement(); int type=TriggerIDs::fromString(xml->getStringAttribute(T("type"))); if (xml->hasTagName(T("trigger")) && type>TriggerIDs::Empty) { Trigger* trig=new Trigger(type); trig->initFromXml(xml); ((EditorComponent*)getContentComponent())->setTrigger(trig); // clear the region if successful so that we don't start // triggering just the left over selection buf->clearRegion(); } else Console::getInstance()->printError(T("Buffer region does not contain a valid '<trigger .../>' XML description.\n")); } else Console::getInstance()->printError(T("Buffer region does not contain a '<trigger .../>' XML description.\n")); }
//============================================================================== void ProjucerAnalyticsDestination::saveUnloggedEvents (const std::deque<AnalyticsEvent>& eventsToSave) { XmlDocument previouslySavedEvents (savedEventsFile); std::unique_ptr<XmlElement> xml (previouslySavedEvents.getDocumentElement()); if (xml.get() == nullptr || xml->getTagName() != "events") xml.reset (new XmlElement ("events")); for (auto& event : eventsToSave) { auto* xmlEvent = new XmlElement ("google_analytics_event"); xmlEvent->setAttribute ("name", event.name); xmlEvent->setAttribute ("type", event.eventType); xmlEvent->setAttribute ("timestamp", (int) event.timestamp); xmlEvent->setAttribute ("user_id", event.userID); auto* parameters = new XmlElement ("parameters"); for (auto& key : event.parameters.getAllKeys()) parameters->setAttribute (key, event.parameters[key]); xmlEvent->addChildElement (parameters); auto* userProperties = new XmlElement ("user_properties"); for (auto& key : event.userProperties.getAllKeys()) userProperties->setAttribute (key, event.userProperties[key]); xmlEvent->addChildElement (userProperties); xml->addChildElement (xmlEvent); } xml->writeToFile (savedEventsFile, {}); }
void XmlParser::readConfig() { XmlDocument* xmlConfigDoc = new XmlDocument(File(File::getCurrentWorkingDirectory().getChildFile(configFile))); XmlElement* xmlConfigElem = xmlConfigDoc->getDocumentElement(); if (xmlConfigElem != NULL) { XmlElement* pictures = xmlConfigElem->getChildByName(T("pictures")); if (pictures != NULL) { if (pictures->hasAttribute(T("path"))) { m_picturePath = pictures->getStringAttribute(T("path")); } else { LOG_ERROR(T("Element \"pictures\" is incomplete")); } } else { LOG_ERROR(T("Element \"pictures\" not found")); } delete xmlConfigElem; } else { LOG_ERROR((T("XML load failed: %ls"), (const juce_wchar*)xmlConfigDoc->getLastParseError())); } delete xmlConfigDoc; }
String BirdID::returnSpeciesName(int predictedClass) { XmlDocument myDocument (File ("C:/Users/Aneesh/Desktop/BirdID_Data/species.xml")); ScopedPointer<XmlElement> element = myDocument.getDocumentElement(); XmlElement* speciesElement = element->getChildElement(0); int numSpecies = speciesElement->getAllSubText().getIntValue(); speciesElement = element->getChildElement(1); String speciesText = speciesElement->getAllSubText(); int startIndex = 0; String tempString; for(int i=0;i<numSpecies;i++) { int endIndex = speciesText.indexOfChar(startIndex+1,','); if(i==predictedClass-1) { tempString = speciesText.substring(startIndex,endIndex); break; } startIndex = endIndex+1; } element = nullptr; return tempString; }
const String FilterGraph::loadDocument (const File& file) { XmlDocument doc (file); ScopedPointer<XmlElement> xml (doc.getDocumentElement()); if (xml == nullptr || ! xml->hasTagName ("FILTERGRAPH")) return "Not a valid filter graph file"; restoreFromXml (*xml); return String::empty; }
Result FilterGraph::loadDocument (const File& file) { XmlDocument doc (file); ScopedPointer<XmlElement> xml (doc.getDocumentElement()); if (xml == nullptr || ! xml->hasTagName ("FILTERGRAPH")) return Result::fail ("Not a valid filter graph file"); restoreFromXml (*xml); return Result::ok(); }
Result PMixDocument::loadDocument (const File& file) { XmlDocument doc (file); ScopedPointer<XmlElement> xml (doc.getDocumentElement()); if (xml == nullptr || ! xml->hasTagName ("PMIXDOC")) return Result::fail ("Not a valid pMix file"); restoreFromXml (*xml); return Result::ok(); }
bool pspSpatConfig::loadXml(File xmlFile){ XmlDocument myDocument (xmlFile); XmlElement* mainElement = myDocument.getDocumentElement(); if(!mainElement->hasTagName("SpatConfig")){ AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "xml file doesn't contain room config data", "", "OK"); //delete mainElement; return false; } else{ if(XmlElement* myConfig = mainElement->getChildElement(0)){ getAttributesFromElement(myConfig); } } delete mainElement; return true; }
bool pspRoomConfigGUI::loadXmlRoomConfig(File xmlFile){ XmlDocument myDocument (xmlFile); XmlElement* mainElement = myDocument.getDocumentElement(); if (mainElement == nullptr) { AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "error loading room config xml file !", "", "OK"); delete mainElement; return false; } else{ if(!mainElement->hasTagName("RoomConfig")){ AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "xml file doesn't contain room config data", "", "OK"); delete mainElement; return false; } else{ XmlElement* roomSize = mainElement->getChildByName("roomSize"); if(roomSize){ static_cast<roomConfigSlider*>(roomDimensions[0])->setValue(roomSize->getDoubleAttribute("width")); } XmlElement* speakers = mainElement->getChildByName("speakers"); if(speakers != nullptr){ int ns = speakers->getNumChildElements(); setNumSpeakers(ns); nss->setValue(ns); cout<<endl<<speakersPosition.size(); /* for(int i=0; i<ns; i++){ static_cast<speakerPositionSlider*>(speakersPosition[3*i+0])->setValue(speakers->getChildElement(i)->getDoubleAttribute("x")); static_cast<speakerPositionSlider*>(speakersPosition[3*i+1])->setValue(speakers->getChildElement(i)->getDoubleAttribute("y")); static_cast<speakerPositionSlider*>(speakersPosition[3*i+2])->setValue(speakers->getChildElement(i)->getDoubleAttribute("z")); } */ } //delete speakers; } } delete mainElement; return true; }
void ComponentLayout::paste() { XmlDocument clip (SystemClipboard::getTextFromClipboard()); ScopedPointer<XmlElement> doc (clip.getDocumentElement()); if (doc != nullptr && doc->hasTagName (clipboardXmlTag)) { selected.deselectAll(); forEachXmlChildElement (*doc, e) if (Component* newComp = addComponentFromXml (*e, true)) selected.addToSelection (newComp); startDragging(); dragSelectedComps (Random::getSystemRandom().nextInt (40), Random::getSystemRandom().nextInt (40)); endDragging(); }
void pspRandomSystem::loadXml(juce::File xmlFile){ XmlDocument myDocument (xmlFile); XmlElement* mainElement = myDocument.getDocumentElement(); if (mainElement == nullptr) { AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "error loading randomTrajectory xml file !", "", "OK"); delete mainElement; return; } else{ if(!mainElement->hasTagName("RandomTrajectory")){ AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "xml file doesn't randomTrajectory data", "", "OK"); delete mainElement; return; } else{ XmlElement* params = mainElement->getChildByName("parameterValues"); if(params){ int np = params->getIntAttribute("numParticles"); changeNumParticles(np); static_cast<pspParticleSystemGUIGenericComponent*>(myGui->getGenericComponent())->getNumParticleSlider()->setValue(np); setBounds(1, params->getDoubleAttribute("lxMin")); setBounds(2, params->getDoubleAttribute("lxMax")); setBounds(3, params->getDoubleAttribute("lyMin")); setBounds(4, params->getDoubleAttribute("lyMax")); setBounds(5, params->getDoubleAttribute("lzMin")); setBounds(6, params->getDoubleAttribute("lzMax")); static_cast<pspRandomSystemSpecificGUI*>(mySpecificGui)->setSliderValues(params->getDoubleAttribute("lxMin"), params->getDoubleAttribute("lxMax"), params->getDoubleAttribute("lyMin"), params->getDoubleAttribute("lxMax"), params->getDoubleAttribute("lzMin"), params->getDoubleAttribute("lzMax")); } } } delete mainElement; }
XmlElement* AudioProcessor::getXmlFromBinary (const void* data, const int sizeInBytes) { if (sizeInBytes > 8 && ByteOrder::littleEndianInt ((const char*) data) == magicXmlNumber) { const int stringLength = (int) ByteOrder::littleEndianInt (((const char*) data) + 4); if (stringLength > 0) { XmlDocument doc (String (((const char*) data) + 8, jmin ((sizeInBytes - 8), stringLength))); return doc.getDocumentElement(); } } return 0; }
void ProjucerAnalyticsDestination::restoreUnloggedEvents (std::deque<AnalyticsEvent>& restoredEventQueue) { XmlDocument savedEvents (savedEventsFile); std::unique_ptr<XmlElement> xml (savedEvents.getDocumentElement()); if (xml.get() == nullptr || xml->getTagName() != "events") return; auto numEvents = xml->getNumChildElements(); for (int iEvent = 0; iEvent < numEvents; ++iEvent) { auto* xmlEvent = xml->getChildElement (iEvent); StringPairArray parameters; auto* xmlParameters = xmlEvent->getChildByName ("parameters"); auto numParameters = xmlParameters->getNumAttributes(); for (int iParam = 0; iParam < numParameters; ++iParam) parameters.set (xmlParameters->getAttributeName (iParam), xmlParameters->getAttributeValue (iParam)); StringPairArray userProperties; auto* xmlUserProperties = xmlEvent->getChildByName ("user_properties"); auto numUserProperties = xmlUserProperties->getNumAttributes(); for (int iProp = 0; iProp < numUserProperties; ++iProp) userProperties.set (xmlUserProperties->getAttributeName (iProp), xmlUserProperties->getAttributeValue (iProp)); restoredEventQueue.push_back ({ xmlEvent->getStringAttribute ("name"), xmlEvent->getIntAttribute ("type"), static_cast<uint32> (xmlEvent->getIntAttribute ("timestamp")), parameters, xmlEvent->getStringAttribute ("user_id"), userProperties }); } savedEventsFile.deleteFile(); }
//============================================================================== void VstPluginWindow::loadPreset () { File lastPresetDirectory = File (plugin->getValue (PROP_PLUGPRESETDIR, String::empty)); if (! lastPresetDirectory.exists()) lastPresetDirectory = Config::getInstance ()->lastPresetDirectory; FileChooser myChooser (T("Load a preset file..."), lastPresetDirectory, JOST_PRESET_WILDCARD, JOST_USE_NATIVE_FILE_CHOOSER); if (myChooser.browseForFileToOpen()) { File fileToLoad = myChooser.getResult(); if (fileToLoad.existsAsFile()) { XmlDocument xmlDoc (fileToLoad.loadFileAsString ()); XmlElement* xml = xmlDoc.getDocumentElement(); if (xml == 0 || ! xml->hasTagName (JOST_PRESET_PRESETTAG)) { String errString = xmlDoc.getLastParseError(); printf ("Error parsing preset: %s \n", (const char*) errString); } else { plugin->loadPresetFromXml (xml); updateParameters (); repaint (); Config::getInstance()->addRecentPreset (fileToLoad); plugin->setValue (PROP_PLUGPRESETDIR, fileToLoad.getParentDirectory().getFullPathName()); } } } }
XmlElement* XmlDocument::parse (const String& xmlData) { XmlDocument doc (xmlData); return doc.getDocumentElement(); }
XmlElement* XmlDocument::parse (const File& file) { XmlDocument doc (file); return doc.getDocumentElement(); }
DescriptorTreeView::DescriptorTreeView(File* DescriptorFile) { outStream = new MemoryOutputStream; // get info building-blocks from built-in file const String infoBlocksXmlString (BinaryData::info_blocks_xml); XmlDocument ib_parser (infoBlocksXmlString); infoBlocksXml = ib_parser.getDocumentElement()->getFirstChildElement(); // populate the tree from file or from default if ( (DescriptorFile != 0) && (DescriptorFile->exists()) ) { const String treeXmlString (DescriptorFile->loadFileAsString()); XmlDocument parser (treeXmlString); treeXml = parser.getDocumentElement(); rootItem = new DescriptorTreeViewItem (treeXml, treeXml, infoBlocksXml, -1); } else { const String treeXmlString (BinaryData::musicsusd_xml); XmlDocument parser (treeXmlString); treeXml = parser.getDocumentElement(); rootItem = new DescriptorTreeViewItem (treeXml, treeXml, infoBlocksXml, -1); } MessageManager::getInstance()->registerBroadcastListener(this); // add and configure the treeview addAndMakeVisible( treeView = new TreeView()); treeView->setDefaultOpenness(true); treeView->setRootItem (rootItem); treeView->addMouseListener(this, true); treeView->setBounds(10, 60, 600, treeView->getParentHeight()-70); rootItem->setLinesDrawnForSubItems(false); treeView->setIndentSize(20); rootItem->setOpen(true); // the hex output area addAndMakeVisible(hexText = new TextEditor(), -1); hexText->setBounds(20 + treeView->getWidth(), 60, treeView->getParentWidth()-treeView->getWidth()-30, treeView->getHeight()); //-200); hexText->setMultiLine(true); hexText->setScrollbarsShown(true); hexText->setReturnKeyStartsNewLine(true); Font font = hexText->getFont(); #if JUCE_MAC font.setTypefaceName("Monaco"); font.setHeight(13.0f); #else font.setTypefaceName("Lucida Console"); font.setHeight(10.0f); #endif hexText->applyFontToAllText(font); // refresh button addAndMakeVisible(refreshButton = new TextButton("Refresh", "Refresh descriptor tree and data struct views.")); refreshButton->addListener(this); // comments button addAndMakeVisible(commentsButton = new TextButton("On", "Comments in data struct.")); commentsButton->setBounds(hexText->getX()+100, 20, 80, 25); commentsButton->addListener(this); commentsButton->setClickingTogglesState(true); // commentsButton->setToggleState(true, true); // comments label addAndMakeVisible(commentsLabel = new Label(String::empty, "Comments:")); commentsLabel->setBounds(hexText->getX(), 20, 80, 25); // bytes button addAndMakeVisible(bytesButton = new TextButton("Hex", "Hex or bytestream display")); bytesButton->setBounds(hexText->getX()+200, 20, 80, 25); bytesButton->addListener(this); bytesButton->setClickingTogglesState(true); bytesButton->setToggleState(true, true); bytesButton->setState(Button::buttonDown); // notes addAndMakeVisible(notesText = new TextEditor(), -1); notesText->setBounds(refreshButton->getRight() + 20, 20, treeView->getRight()-refreshButton->getRight()-40, 25); notesText->setMultiLine(false); notesText->setColour( TextEditor::backgroundColourId, Colours::darkseagreen); notesText->setTextToShowWhenEmpty("Add a brief description of the descriptor here.", Colours::blue); notesText->setText(treeXml->getStringAttribute("notes")); notesText->addListener(this); Font notesFont = notesText->getFont(); notesFont.setTypefaceName("Arial"); notesFont.setHeight(16.0f); notesText->applyFontToAllText(notesFont); }