MaterialX  1.36.0
Classes
XmlIo.h File Reference

Support for the MTLX file format. More...

#include <MaterialXCore/Library.h>
#include <MaterialXCore/Document.h>

Go to the source code of this file.

Classes

class  MaterialX::XmlReadOptions
 A set of options for controlling the behavior of XML read functions. More...
 
class  MaterialX::ExceptionParseError
 An exception that is thrown when a requested document cannot be parsed. More...
 
class  MaterialX::ExceptionFileMissing
 An exception that is thrown when a requested file cannot be opened. More...
 

Functions

Read Functions
void MaterialX::readFromXmlBuffer (DocumentPtr doc, const char *buffer, const XmlReadOptions *readOptions=nullptr)
 Read a Document as XML from the given character buffer. More...
 
void MaterialX::readFromXmlStream (DocumentPtr doc, std::istream &stream, const XmlReadOptions *readOptions=nullptr)
 Read a Document as XML from the given input stream. More...
 
void MaterialX::readFromXmlFile (DocumentPtr doc, const string &filename, const string &searchPath=EMPTY_STRING, const XmlReadOptions *readOptions=nullptr)
 Read a Document as XML from the given filename. More...
 
void MaterialX::readFromXmlString (DocumentPtr doc, const string &str, const XmlReadOptions *readOptions=nullptr)
 Read a Document as XML from the given string. More...
 
Write Functions
void MaterialX::writeToXmlStream (DocumentPtr doc, std::ostream &stream, bool writeXIncludes=true, const ElementPredicate &predicate=ElementPredicate())
 Write a Document as XML to the given output stream. More...
 
void MaterialX::writeToXmlFile (DocumentPtr doc, const string &filename, bool writeXIncludes=true, const ElementPredicate &predicate=ElementPredicate())
 Write a Document as XML to the given filename. More...
 
string MaterialX::writeToXmlString (DocumentPtr doc, bool writeXIncludes=true, const ElementPredicate &predicate=ElementPredicate())
 Write a Document as XML to a new string, returned by value. More...
 
Edit Functions
void MaterialX::prependXInclude (DocumentPtr doc, const string &filename)
 Add an XInclude reference to the top of a Document, creating a generic element to hold the reference filename. More...
 

Detailed Description

Support for the MTLX file format.

Function Documentation

◆ prependXInclude()

void MaterialX::prependXInclude ( DocumentPtr  doc,
const string &  filename 
)

Add an XInclude reference to the top of a Document, creating a generic element to hold the reference filename.

Parameters
docThe Document to be modified.
filenameThe filename of the XInclude reference to be added.

◆ readFromXmlBuffer()

void MaterialX::readFromXmlBuffer ( DocumentPtr  doc,
const char *  buffer,
const XmlReadOptions readOptions = nullptr 
)

Read a Document as XML from the given character buffer.

Parameters
docThe Document into which data is read.
bufferThe character buffer from which data is read.
readOptionsAn optional pointer to an XmlReadOptions object. If provided, then the given options will affect the behavior of the read function. Defaults to a null pointer.
Exceptions
ExceptionParseErrorif the document cannot be parsed.

◆ readFromXmlFile()

void MaterialX::readFromXmlFile ( DocumentPtr  doc,
const string &  filename,
const string &  searchPath = EMPTY_STRING,
const XmlReadOptions readOptions = nullptr 
)

Read a Document as XML from the given filename.

Parameters
docThe Document into which data is read.
filenameThe filename from which data is read.
searchPathA semicolon-separated sequence of file paths, which will be applied in order when searching for the given file and its includes. Defaults to the empty string.
readOptionsAn optional pointer to an XmlReadOptions object. If provided, then the given options will affect the behavior of the read function. Defaults to a null pointer.
Exceptions
ExceptionParseErrorif the document cannot be parsed.
ExceptionFileMissingif the file cannot be opened.

◆ readFromXmlStream()

void MaterialX::readFromXmlStream ( DocumentPtr  doc,
std::istream &  stream,
const XmlReadOptions readOptions = nullptr 
)

Read a Document as XML from the given input stream.

Parameters
docThe Document into which data is read.
streamThe input stream from which data is read.
readOptionsAn optional pointer to an XmlReadOptions object. If provided, then the given options will affect the behavior of the read function. Defaults to a null pointer.
Exceptions
ExceptionParseErrorif the document cannot be parsed.

◆ readFromXmlString()

void MaterialX::readFromXmlString ( DocumentPtr  doc,
const string &  str,
const XmlReadOptions readOptions = nullptr 
)

Read a Document as XML from the given string.

Parameters
docThe Document into which data is read.
strThe string from which data is read.
readOptionsAn optional pointer to an XmlReadOptions object. If provided, then the given options will affect the behavior of the read function. Defaults to a null pointer.
Exceptions
ExceptionParseErrorif the document cannot be parsed.

◆ writeToXmlFile()

void MaterialX::writeToXmlFile ( DocumentPtr  doc,
const string &  filename,
bool  writeXIncludes = true,
const ElementPredicate predicate = ElementPredicate() 
)

Write a Document as XML to the given filename.

Parameters
docThe Document to be written.
filenameThe filename to which data is written
writeXIncludesIf true, elements with source file markings will be written as XIncludes rather than explicit data. Defaults to true.
predicateIf provided, this function will be used to exclude specific elements (those returning false) from the write operation.

◆ writeToXmlStream()

void MaterialX::writeToXmlStream ( DocumentPtr  doc,
std::ostream &  stream,
bool  writeXIncludes = true,
const ElementPredicate predicate = ElementPredicate() 
)

Write a Document as XML to the given output stream.

Parameters
docThe Document to be written.
streamThe output stream to which data is written
writeXIncludesIf true, elements with source file markings will be written as XIncludes rather than explicit data. Defaults to true.
predicateIf provided, this function will be used to exclude specific elements (those returning false) from the write operation.

◆ writeToXmlString()

string MaterialX::writeToXmlString ( DocumentPtr  doc,
bool  writeXIncludes = true,
const ElementPredicate predicate = ElementPredicate() 
)

Write a Document as XML to a new string, returned by value.

Parameters
docThe Document to be written.
writeXIncludesIf true, elements with source file markings will be written as XIncludes rather than explicit data. Defaults to true.
predicateIf provided, this function will be used to exclude specific elements (those returning false) from the write operation.
Returns
The output string, returned by value