Пример #1
0
void AnswerGenerator::SaveAnswer( AnswerList & answerList )
{
	XmlDocument xmlDoc;
	XmlNode * resNode = xmlDoc.AddNode( "resource" );

	int count = answerList.size();
	for( int num = 0; num < count; num++ )
	{
		AnswerData & answer = answerList[ num ];

		std::string ans = answer._answer;
		std::string ref = answer._reference;

		XmlNode * qsNode = resNode->AddNode( "question" );
		
		char buf[8]; itoa(num, buf, 10);
		qsNode->SetAttribute( "no", buf );

		XmlNode * referenceNode = qsNode->AddNode( "table" );
		referenceNode->SetText( ref.c_str(), XmlNode::NUMBER );

		XmlNode * answerNode = qsNode->AddNode( "answer" );
		answerNode->SetText( ans.c_str(), XmlNode::NUMBER );
	}

	std::string path = "./resource/ResultAnswer.xml";
	xmlDoc.SaveFile( path.c_str() );
}
Пример #2
0
//==============================================================================
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;
}
Пример #3
0
/**
*  @brief
*    Parse incoming stream data
*/
void InputStream::ParseStream(const String &sStream)
{
	// Has the document been initialized yet?
	if (!m_pStream) {
		// Parse beginning of document
		m_cXml.Parse(sStream.GetASCII());

		// Get root element
		XmlElement *pRoot = m_cXml.GetRootElement();
		if (pRoot && pRoot->GetValue() == "stream:stream") {
			// Save stream element
			m_pStream = pRoot;

			// Callback function for stream element
			m_pJabberConnection->OnStreamStarted(*m_pStream);
		}
	} else {
		// Parse XML part
		XmlDocument cXml;
		cXml.Parse(sStream.GetASCII());
		XmlElement *pRoot = cXml.GetRootElement();
		if (pRoot) {
			// Add element
			XmlElement *pElement = static_cast<XmlElement*>(pRoot->Clone());
			m_pStream->LinkEndChild(*pElement);

			// Callback function for element
			m_pJabberConnection->OnElement(*pElement);
		}
	}
}
Пример #4
0
bool CXmlDocument::TransformNodeToObject(CXmlDocument*pNode,CXmlDocument*pOutDOM)
{
	XmlDocument pXmlDoc;

	HRESULT hr = pXmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument));
	if ( hr == S_OK )
	{
		CComQIPtr<IDispatch> pDisp = pXmlDoc;
		if ( !pDisp ) return false;

		CComVariant vOut;
		vOut.vt = VT_DISPATCH;
		vOut.pdispVal = pDisp.Detach();
		hr = m_pDoc->transformNodeToObject(pNode->m_pDoc,vOut);
		if ( hr == S_OK )
		{
			bool bLogin=false;
			hr = pOutDOM->SetXmlDocument(&vOut,bLogin);

			return true;
		}
	}

	return false;

}
Пример #5
0
XmlOutcome AWSXMLClient::MakeRequest(const Aws::String& uri,
    const Aws::AmazonWebServiceRequest& request,
    Http::HttpMethod method) const
{
    HttpResponseOutcome httpOutcome(BASECLASS::AttemptExhaustively(uri, request, method));
    if (!httpOutcome.IsSuccess())
    {
        return XmlOutcome(httpOutcome.GetError());
    }

    if (httpOutcome.GetResult()->GetResponseBody().tellp() > 0)
    {
        XmlDocument xmlDoc = XmlDocument::CreateFromXmlStream(httpOutcome.GetResult()->GetResponseBody());

        if (!xmlDoc.WasParseSuccessful())
        {
            AWS_LOG_ERROR(LOG_TAG, "Xml parsing for error failed with message %s", xmlDoc.GetErrorMessage().c_str());
            return AWSError<CoreErrors>(CoreErrors::UNKNOWN, "Xml Parse Error", xmlDoc.GetErrorMessage(), false);
        }

        return XmlOutcome(AmazonWebServiceResult<XmlDocument>(std::move(xmlDoc),
            httpOutcome.GetResult()->GetHeaders(), httpOutcome.GetResult()->GetResponseCode()));
    }

    return XmlOutcome(AmazonWebServiceResult<XmlDocument>(XmlDocument(), httpOutcome.GetResult()->GetHeaders()));
}
Пример #6
0
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;
}
Пример #7
0
void DbXmlUpdateFactory::applyPut(const PendingUpdate &update, DynamicContext *context)
{
	DbXmlUri uri(update.getValue().first()->
		     asString(context), true);
	if (uri.isDbXmlScheme()) {
		const DbXmlNodeImpl *content =
			(const DbXmlNodeImpl*)update.getTarget().get();
		string cname = uri.getContainerName();
		string docname = uri.getDocumentName();
		DbXmlConfiguration *conf = GET_CONFIGURATION(context);
		XmlManager &mgr = conf->getManager();
		XmlContainer cont = ((Manager&)mgr).getOpenContainer(cname);
		if (cont.isNull()) {
			string msg = "Target container for fn:put -- ";
			msg += cname;
			msg += " -- must be open";
			throw XmlException(XmlException::INVALID_VALUE,
					   msg);
		}
		OperationContext &oc = conf->getOperationContext();
		XmlDocument doc = mgr.createDocument();
		doc.setName(docname);
		XmlEventReader *reader =
			(XmlEventReader*)content->getEventReader(context);
		DBXML_ASSERT(reader);
		doc.setContentAsEventReader(*reader);
		XmlUpdateContext uc = mgr.createUpdateContext();
		// use internal interface to avoid additional transaction
		int err = ((Container &)cont).addDocumentInternal(oc.txn(), doc, uc, 0);
		if (err != 0)
			throw XmlException(err);
	}
}
Пример #8
0
//==============================================================================
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, {});
}
Пример #9
0
void
MyScene1::loadSceneFile(const char *filePath)
{
	// load XML scene file
	XmlDocument doc;
	doc.fromFile(File::getPath(filePath));

	// make sure the root element is named correctly
	const XmlElement *root = doc.getRootElement();
	if(root->getName() != "dromescene")
		throw Exception("MyScene1::loadSceneFile(): Invalid root element name");

	vector < RefPtr <Texture> > textures;

	// loop through each child element
	for(unsigned int i = 0; i < root->getNumChildren(); ++i) {
		const XmlElement *child = root->getChild(i);

		if(child->getName() == "texture") {
			// create texture
			const XmlAttribute *attr = child->getAttribute("filePath");
			if(!attr)
				throw Exception("MyScene1::loadSceneFile(): Texture without filePath");
			textures.push_back(Texture::create(Image::create(attr->getValue())));
		} else if(child->getName() == "block") {
			// parse position
			const XmlAttribute *attr = child->getAttribute("position");
			if(!attr)
				throw Exception("MyScene1::loadSceneFile(): Block without position");
			Vector3 position(attr->getValue());

			// parse bounds
			attr = child->getAttribute("bounds");
			if(!attr)
				throw Exception("MyScene1::loadSceneFile(): Block without bounds");
			Vector3 bounds(attr->getValue());

			// parse texture index
			attr = child->getAttribute("textureIndex");
			unsigned int index = (attr != NULL) ? (unsigned int)String(attr->getValue()).toInt() : 0;
			if(index >= textures.size())
				throw Exception("MyScene1::loadSceneFile(): Block with invalid texture index");

			// parse normalmap index
			RefPtr <Texture> normalmap;
			attr = child->getAttribute("normalmapIndex");
			if(attr != NULL) {
				unsigned int tmp = (unsigned int)String(attr->getValue()).toInt();
				if(tmp >= textures.size())
					throw Exception("MyScene1::loadSceneFile(): Block with invalid normalmap index");
				normalmap = textures[tmp];
			}

			// create block
			m_sceneObjects.push_back(new Block(position, bounds, textures[index], normalmap));
		} else {
			throw Exception("MyScene1::loadSceneFile(): Invalid element name '" + child->getName() + "'");
		}
	}
}
Пример #10
0
		bool Save()
		{
			std::ostringstream o;

			o << "<agenda>" << std::endl;
			o << "<notes>" << std::endl;

			for (int i=0; i<(int)events.size(); i++) {
				struct agenda_t *t = events[i];

				o << "<event day=\"" << t->day << "\" month=\"" << t->month << "\" year=\"" << t->year << "\">" << std::endl;
				o << t->event << std::endl;
				o << "</event>" << std::endl;
			}

			o << "</notes>" << std::endl;
			o << "</agenda>" << std::endl;

			XmlDocument doc;

			doc.Parse(o.str().c_str());

			if (doc.Error()) {
				return false;
			}

			doc.SaveFile(_file.c_str());

			return true;
		}
Пример #11
0
/**
*  @brief
*    Saves the material
*/
bool PLSceneMaterial::Save(const String &sApplicationDrive, const String &sApplicationDir)
{
	// Create XML document
	XmlDocument cDocument;

	// Add declaration
	XmlDeclaration *pDeclaration = new XmlDeclaration("1.0", "ISO-8859-1", "");
	cDocument.LinkEndChild(*pDeclaration);

	// Add material
	XmlElement *pMaterialElement = new XmlElement("Material");
	pMaterialElement->SetAttribute("Version", "1");

	// Save the parameters
	SaveParameters(*pMaterialElement);

	// Link material element
	cDocument.LinkEndChild(*pMaterialElement);

	// Get the absolute material filename
	const String sFilename = sApplicationDrive + sApplicationDir + PLTools::GetResourceFilename(PLTools::ResourceMaterial, m_sName);

	{ // Before we safe, we need to ensure that the target directory is there, else 'Save()' will fail!
		Url cUrl = sFilename;
		Directory cDirectory(cUrl.CutFilename());
		cDirectory.CreateRecursive();
	}

	// Save settings
	cDocument.Save(sFilename);

	// Done
	return true;
}
Пример #12
0
void MaterialManager::Initialise(char *materialXMLFile)
{
	// read through the xml file and load all materials
	XmlDocument doc;
	doc.Load(materialXMLFile);

	TiXmlHandle * hdoc = doc.Handle();
	TiXmlElement * root = hdoc->FirstChildElement().Element();

	TiXmlElement * child = root->FirstChildElement();

	// loop through our materials
	while(child)
	{
		// get the name of the material 
		const char * matName = XmlUtilities::ReadAttributeAsString(child, "", "name");
		
		// create the new material
		Material* mat = new Material(matName);
		mat->ReadXml(child); // read the properties

		m_materialMap[matName] = mat; // add to the material map

		// move to the next material
		child = child->NextSiblingElement();
	}
}
Пример #13
0
//==============================================================================
void Material::load(const CString& filename, ResourceInitializer& init)
{
	try
	{
		m_vars = std::move(ResourceVector<MaterialVariable*>(init.m_alloc));

		Dictionary<MaterialVariable*> dict(10, 
			Dictionary<MaterialVariable*>::hasher(),
			Dictionary<MaterialVariable*>::key_equal(),
			init.m_alloc);
		m_varDict = std::move(dict);

		m_progs = 
			std::move(ResourceVector<ProgramResourcePointer>(init.m_alloc));
		m_pplines = 
			std::move(ResourceVector<GlProgramPipelineHandle>(init.m_alloc));

		XmlDocument doc;
		doc.loadFile(filename, init.m_tempAlloc);
		parseMaterialTag(doc.getChildElement("material"), init);
	}
	catch(std::exception& e)
	{
		throw ANKI_EXCEPTION("Failed to load material") << e;
	}
}
Пример #14
0
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;
}
Aws::String UpdateTrafficPolicyInstanceRequest::SerializePayload() const
{
  XmlDocument payloadDoc = XmlDocument::CreateWithRootNode("UpdateTrafficPolicyInstanceRequest");

  XmlNode parentNode = payloadDoc.GetRootElement();
  parentNode.SetAttributeValue("xmlns", "https://route53.amazonaws.com/doc/2013-04-01/");

  Aws::StringStream ss;
  if(m_tTLHasBeenSet)
  {
   XmlNode tTLNode = parentNode.CreateChildElement("TTL");
  ss << m_tTL;
   tTLNode.SetText(ss.str());
  ss.str("");
  }

  if(m_trafficPolicyIdHasBeenSet)
  {
   XmlNode trafficPolicyIdNode = parentNode.CreateChildElement("TrafficPolicyId");
   trafficPolicyIdNode.SetText(m_trafficPolicyId);
  }

  if(m_trafficPolicyVersionHasBeenSet)
  {
   XmlNode trafficPolicyVersionNode = parentNode.CreateChildElement("TrafficPolicyVersion");
  ss << m_trafficPolicyVersion;
   trafficPolicyVersionNode.SetText(ss.str());
  ss.str("");
  }

  return payloadDoc.ConvertToString();
}
Пример #16
0
MgByteReader* MgResourceDefinitionManager::GetRepository(
    MgResourceIdentifier* resource)
{
    assert(NULL != resource && resource->IsRoot());
    Ptr<MgByteReader> byteReader;

    MG_RESOURCE_SERVICE_TRY()

    // Get the resource.

    XmlDocument xmlDoc = GetDocument(*resource);

    // Create a byte reader.

    string document;
    xmlDoc.getContent(document); // TODO: Improve performance by using getContentAsXmlInputStream?

    Ptr<MgByteSource> byteSource = new MgByteSource(
        (unsigned char*)document.c_str(), (INT32)document.length());

    byteSource->SetMimeType(MgMimeType::Xml);
    byteReader = byteSource->GetReader();

    MG_RESOURCE_CONTAINER_CATCH_AND_THROW(L"MgResourceDefinitionManager.GetRepository")

    return SAFE_ADDREF((MgByteReader*)byteReader);
}
Пример #17
0
XmlDocument* XmlParser::buildDocument()
{
  XmlDocument* pDoc = new XmlDocument(makeDocElement());
  using sPtr = std::shared_ptr < AbstractXmlElement >;
  sPtr pDocElem = pDoc->docElement();

  std::stack <sPtr> elemStack_;
  elemStack_.push(pDocElem);

  std::locale loc;
  XmlParts& xmlParts = *pXmlParts_;
  while (xmlParts.get())
  {
    if (xmlParts[0] == "<")
    {
      processMarkup(elemStack_);
      continue;
    }
    if (xmlParts[0][0] == '\"' || isalnum(xmlParts[0][0]) || isspace(xmlParts[0][0], loc))
    {
      processText(elemStack_);
      continue;
    }
    throw(std::exception("ill-formed XML"));
  }
  if(verbose_) std::cout << "\n";
  return pDoc;
}
Пример #18
0
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"));


}
Пример #19
0
bool Test::testCase2() const {
    if (m_verbose) cout << "\tCase 2: Parse and print\n";

    string text =
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
        "<element1 a=\"1\" b=\"2\">\n"
        "\t<element2 c=\"3\" d=\"true\"/>\n"
        "\t<element3>Hello World!</element3>\n"
        "\t<element4 a=\"123\">\n"
        "\t\t<element5 yes=\"no\">\n"
        "\t\t\t<element6 str=\"This is a string\" num=\"4.5\"/>\n"
        "\t\t\t<element7>99.8</element7>\n"
        "\t\t</element5>\n"
        "\t</element4>\n"
        "</element1>\n\n";

    XmlDocument doc;
    doc.parse(text.data(), text.length());

    string output;
    doc.print(output);

    bool pass = output.compare(text) == 0;

    if (m_verbose) cout << (pass ? "\tPASS\n" : "\tFAIL\n");
    return pass;
}
Пример #20
0
void MainWindowView::NewMainXmlFile()
{
    //Call the dialog for chose the file name and the path for the new xml
    QString& candidateFileName = QFileDialog::getSaveFileName(this, tr("Chose name and path for the new xml"),
                                                             "." ,tr("XML files (*.xml);; Text files (*.txt);; All files (*)"));

    //If the selection is valid
    if( !candidateFileName.isEmpty() )
    {
        //Add .xml extension if no extension is given by the user
        int lastIndexOfDot = candidateFileName.lastIndexOf('.');
        if(lastIndexOfDot == -1) //If has no extension
            candidateFileName.append(".xml");

        //Create a new XmlDocument
        XmlDocument* xmlDocument = new XmlDocument();
        xmlDocument->NewXmlFile(candidateFileName);

        //Clear all and add in the editor the new file
        ClearAllXml();

        //Add the correct open xml file in the editor
        AddNewXml(xmlDocument);

        //Change main file in order to give loaded all the previosly inserted associated files
        m_pAssociatedFiles->ChangeMainFile(candidateFileName);
    }
}
Пример #21
0
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);
            }
        }
    }
}
Пример #22
0
void Animation::ReadXml(const char* filename)
{
	m_animationParts.clear(); // clear our parts list first

	// create a new xml document 
	XmlDocument doc;
	doc.Load(filename);

	TiXmlHandle * hdoc = doc.Handle();
	TiXmlElement * root = hdoc->FirstChildElement().Element();

	if(root != 0)
	{
		TiXmlElement * child = root->FirstChildElement();

		// loop through children
		while(child)
		{
			// whats the name of this part
			string partName = (string)child->Value();

			// add this part to the part map
			m_animationParts[partName] = new AnimationPart(child);

			// move to the next game object
			child = child->NextSiblingElement();
		}
	}
}
Пример #23
0
bool OutXmlSerializer::save(Stream& stream)
{
	XmlDocument doc;

	XmlDeclaration* decl = zenic_new XmlDeclaration;
	decl->setValue("xml");
	decl->setAttribute("version","1.0");
	decl->setAttribute("encoding","ISO-8859-1");
	doc.addChild(decl);

	XmlComment* comment = new XmlComment;
	comment->setValue(" Cell XML Object Graph ");
	doc.addChild(comment);

	// add initial objects

	for (uint i = 0, n = count(); i < n; ++i)
	{
		Serializable* initial = (*this)[i];
		uint j,m;
		for (j = 0, m = m_objects.count(); j < m; ++j)
		{
			if (m_objects[j] == initial)
				break;
		}

		if (j == m_objects.count())
			m_objects.pushBack(initial);
	}

	// build xml tree

	XmlElement* root = new XmlElement;
	root->setValue("zenic");

	for (uint i = 0; i < m_objects.count(); ++i)
	{
		Serializable* object = m_objects[i];
		ZENIC_ASSERT(object);

		m_current = 0;
		m_currentIndex = i;
		object->serialize(*this);

		ZENIC_ASSERT(m_current);
		root->addChild(m_current);
	}

	doc.addChild(root);

	// write tree to stream
	if (!doc.save(stream))
		return false;

	return true;
}
Пример #24
0
//using namespace rapidxml;
EngineInfo::EngineInfo()
{       
    XmlDocument doc;
    XmlNode* decl = doc.allocate_node(rapidxml::node_declaration);
    decl->append_attribute(doc.allocate_attribute(L"version", L"1.0"));
    decl->append_attribute(doc.allocate_attribute(L"encoding", L"utf-8"));
    decl->append_attribute(doc.allocate_attribute(L"standalone", L"yes"));
    doc.append_node(decl);
    XmlNode* root = doc.allocate_node(rapidxml::node_element, L"EngineInfo");
    root->append_attribute(doc.allocate_attribute(L"version", L"1.0"));
    doc.append_node(root);

    XmlNode* resNodes = doc.allocate_node(rapidxml::node_element,L"SupportedResources");
    root->append_node(resNodes);
        
    // add supported 3d models.
    const wchar_t* modeltype = ResourceType::ToWString(ResourceType::Model);
    AddResNode(doc,resNodes,modeltype,L"Model",L"3d model",L".atgi,.dae");
        
    // add supported textures
    const wchar_t* textureType = ResourceType::ToWString(ResourceType::Texture);
    AddResNode(doc,resNodes,textureType,L"Texture",L"Texture file",L".dds,.bmp,.jpg,.png,.tga,.tif");

    // Add any other engine information 

    // print to string.
    rapidxml::print(back_inserter(m_data), doc, 0);   
}
Пример #25
0
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;
}
Пример #26
0
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();
}
Пример #27
0
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();
}
Пример #28
0
Error CollisionResource::load(const ResourceFilename& filename)
{
	XmlElement el;
	XmlDocument doc;
	ANKI_CHECK(openFileParseXml(filename, doc));

	XmlElement collEl;
	ANKI_CHECK(doc.getChildElement("collisionShape", collEl));

	ANKI_CHECK(collEl.getChildElement("type", el));
	CString type;
	ANKI_CHECK(el.getText(type));

	XmlElement valEl;
	ANKI_CHECK(collEl.getChildElement("value", valEl));

	PhysicsWorld& physics = getManager().getPhysicsWorld();
	PhysicsCollisionShapeInitInfo csInit;

	if(type == "sphere")
	{
		F64 tmp;
		ANKI_CHECK(valEl.getF64(tmp));
		m_physicsShape = physics.newInstance<PhysicsSphere>(csInit, tmp);
	}
	else if(type == "box")
	{
		Vec3 extend;
		ANKI_CHECK(valEl.getVec3(extend));
		m_physicsShape = physics.newInstance<PhysicsBox>(csInit, extend);
	}
	else if(type == "staticMesh")
	{
		CString meshfname;
		ANKI_CHECK(valEl.getText(meshfname));

		MeshLoader loader(&getManager());
		ANKI_CHECK(loader.load(meshfname));

		m_physicsShape = physics.newInstance<PhysicsTriangleSoup>(csInit,
			reinterpret_cast<const Vec3*>(loader.getVertexData()),
			loader.getVertexSize(),
			reinterpret_cast<const U16*>(loader.getIndexData()),
			loader.getHeader().m_totalIndicesCount);
	}
	else
	{
		ANKI_LOGE("Incorrect collision type");
		return ErrorCode::USER_DATA;
	}

	return ErrorCode::NONE;
}
Пример #29
0
void MainWindowView::OpenXmlFile(const QString& candidateFileNameNoDialog, bool isMainFile)
{
    QString candidateFileName = "";

    //If candidate file name in input is == "" it's needed to open a dialog for choose the file, otherwise there's no need to show it
    if( candidateFileNameNoDialog == "" )
    {
        candidateFileName = QFileDialog::getOpenFileName(this, tr("Chose a file to open"),
                                                                 "." ,tr("XML files (*.xml);; Text files (*.txt);; All files (*)"));
    }
    else //if the string it's already given
    {
        candidateFileName = candidateFileNameNoDialog;
    }

    //If the selection is valid
    if( !candidateFileName.isEmpty() )
    {
        //Open an xml document
        XmlDocument* xmlDocument = new XmlDocument();
        FILE_XML_ERR_CODE errCode = xmlDocument->OpenXmlFile(candidateFileName);

        if(errCode == FILE_XML_NO_ERR)
        {
            if(isMainFile)
            {
                ClearAllXml(); //Clear all and add in the editor the new file
            }

            //Add the correct open xml file in the editor
            AddNewXml(xmlDocument);

            //Change main file in order to give loaded all the previosly inserted associated files
            if(isMainFile)
            {
                m_pAssociatedFiles->ChangeMainFile(candidateFileName);
            }
        }
        else
        {
            //Initial string error
            QString error = "It was impossible open the file: \""+ candidateFileName +"\".\n\n";

            //Show the error
            ShowOpenSaveXmlError(error, errCode, xmlDocument);

            delete xmlDocument;
        }
    }

}
Пример #30
0
// create node for resource type
void AddResNode(XmlDocument& doc,
    XmlNode* parent,
    const wchar_t* type,
    const wchar_t* name,
    const wchar_t* description,
    const wchar_t* fileExt)
{   
    XmlNode* resnode = doc.allocate_node(rapidxml::node_element,L"ResourceDescriptor");
    resnode->append_attribute(doc.allocate_attribute(L"Type", type));
    resnode->append_attribute(doc.allocate_attribute(L"Name", name));
    resnode->append_attribute(doc.allocate_attribute(L"Description", description));
    resnode->append_attribute(doc.allocate_attribute(L"Ext", fileExt));
    parent->append_node(resnode);
}