本文整理汇总了C++中DataElement::toXml方法的典型用法代码示例。如果您正苦于以下问题:C++ DataElement::toXml方法的具体用法?C++ DataElement::toXml怎么用?C++ DataElement::toXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataElement
的用法示例。
在下文中一共展示了DataElement::toXml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
bool ModelExporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
Progress* pProgress = NULL;
FileDescriptor* pFileDescriptor = NULL;
DataElement* pElement = NULL;
StepResource pStep("Export model element", "app", "2BF48AAB-4832-4694-8583-882A8D584E97");
// get input arguments and log some useful info about them
{ // scope the MessageResource
MessageResource pMsg("Input arguments", "app", "1B02F950-2E04-4BEF-8561-BB8D993340F7");
pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
pMsg->addBooleanProperty("Progress Present", (pProgress != NULL));
pFileDescriptor = pInArgList->getPlugInArgValue<FileDescriptor>(Exporter::ExportDescriptorArg());
if (pFileDescriptor == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("No file specified", 100, ERRORS);
}
pStep->finalize(Message::Failure, "No file specified");
return false;
}
pMsg->addProperty("Destination", pFileDescriptor->getFilename());
pElement = pInArgList->getPlugInArgValueUnsafe<DataElement>(Exporter::ExportItemArg());
if (pElement == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("No model element specified", 100, ERRORS);
}
pStep->finalize(Message::Failure, "No model element specified");
return false;
}
pMsg->addProperty("Name", pElement->getName());
}
if (pProgress != NULL)
{
pProgress->updateProgress("Open output file", 10, NORMAL);
}
FILE* pFile = fopen(pFileDescriptor->getFilename().getFullPathAndName().c_str(), "w");
if (pFile == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("File can not be created", 100, ERRORS);
}
pStep->finalize(Message::Failure, "File can not be created");
return false;
}
DataDescriptor* pElementDescriptor = pElement->getDataDescriptor();
VERIFY(pElementDescriptor != NULL);
if (pProgress != NULL)
{
pProgress->updateProgress("Save element", 20, NORMAL);
}
string elementName = pElementDescriptor->getType();
XMLWriter xml(elementName.c_str(), Service<MessageLogMgr>()->getLog());
if (!pElement->toXml(&xml))
{
if (pProgress != NULL)
{
pProgress->updateProgress("Error saving model element", 100, ERRORS);
}
pStep->finalize(Message::Failure, "Error saving model element");
return false;
}
else
{
xml.writeToFile(pFile);
}
fclose(pFile);
if (pProgress != NULL)
{
pProgress->updateProgress("Finished saving the model element", 100, NORMAL);
}
pStep->finalize(Message::Success);
return true;
}