MaterialX 1.39.1
Loading...
Searching...
No Matches
XmlIo.h File Reference

Support for the MTLX file format. More...

Go to the source code of this file.

Classes

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

Typedefs

using XmlReadFunction = std::function< void(DocumentPtr, const FilePath &, const FileSearchPath &, const XmlReadOptions *)>
 A standard function that reads from an XML file into a Document, with optional search path and read options.
 

Functions

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

Variables

MX_FORMAT_API const string MTLX_EXTENSION
 

Detailed Description

Support for the MTLX file format.

Function Documentation

◆ prependXInclude()

MX_FORMAT_API void prependXInclude ( DocumentPtr  doc,
const FilePath 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()

MX_FORMAT_API void readFromXmlBuffer ( DocumentPtr  doc,
const char *  buffer,
FileSearchPath  searchPath = FileSearchPath(),
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.
searchPathAn optional sequence of file paths that will be applied in order when searching for the given file and its includes. This argument can be supplied either as a FileSearchPath, or as a standard string with paths separated by the PATH_SEPARATOR character.
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()

MX_FORMAT_API void readFromXmlFile ( DocumentPtr  doc,
FilePath  filename,
FileSearchPath  searchPath = FileSearchPath(),
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. This argument can be supplied either as a FilePath or a standard string.
searchPathAn optional sequence of file paths that will be applied in order when searching for the given file and its includes. This argument can be supplied either as a FileSearchPath, or as a standard string with paths separated by the PATH_SEPARATOR character.
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()

MX_FORMAT_API void readFromXmlStream ( DocumentPtr  doc,
std::istream &  stream,
FileSearchPath  searchPath = FileSearchPath(),
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.
searchPathAn optional sequence of file paths that will be applied in order when searching for the given file and its includes. This argument can be supplied either as a FileSearchPath, or as a standard string with paths separated by the PATH_SEPARATOR character.
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()

MX_FORMAT_API void readFromXmlString ( DocumentPtr  doc,
const string &  str,
const FileSearchPath searchPath = FileSearchPath(),
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.
searchPathAn optional sequence of file paths that will be applied in order when searching for the given file and its includes. This argument can be supplied either as a FileSearchPath, or as a standard string with paths separated by the PATH_SEPARATOR character.
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()

MX_FORMAT_API void writeToXmlFile ( DocumentPtr  doc,
const FilePath filename,
const XmlWriteOptions writeOptions = nullptr 
)

Write a Document as XML to the given filename.

Parameters
docThe Document to be written.
filenameThe filename to which data is written. This argument can be supplied either as a FilePath or a standard string.
writeOptionsAn optional pointer to an XmlWriteOptions object. If provided, then the given options will affect the behavior of the write function. Defaults to a null pointer.

◆ writeToXmlStream()

MX_FORMAT_API void writeToXmlStream ( DocumentPtr  doc,
std::ostream &  stream,
const XmlWriteOptions writeOptions = nullptr 
)

Write a Document as XML to the given output stream.

Parameters
docThe Document to be written.
streamThe output stream to which data is written
writeOptionsAn optional pointer to an XmlWriteOptions object. If provided, then the given options will affect the behavior of the write function. Defaults to a null pointer.

◆ writeToXmlString()

MX_FORMAT_API string writeToXmlString ( DocumentPtr  doc,
const XmlWriteOptions writeOptions = nullptr 
)

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

Parameters
docThe Document to be written.
writeOptionsAn optional pointer to an XmlWriteOptions object. If provided, then the given options will affect the behavior of the write function. Defaults to a null pointer.
Returns
The output string, returned by value