6#ifndef MATERIALX_XMLIO_H
7#define MATERIALX_XMLIO_H
19MATERIALX_NAMESPACE_BEGIN
23extern MX_FORMAT_API
const string MTLX_EXTENSION;
80 using Exception::Exception;
88 using Exception::Exception;
192MATERIALX_NAMESPACE_END
The top-level Document class.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
std::function< bool(ConstElementPtr)> ElementPredicate
A standard function taking an ElementPtr and returning a boolean.
Definition: Element.h:72
Cross-platform support for file and search paths.
Library-wide includes and types.
vector< string > StringVec
A vector of strings.
Definition: Library.h:55
std::function< void(DocumentPtr, const FilePath &, const FileSearchPath &, const XmlReadOptions *)> XmlReadFunction
A standard function that reads from an XML file into a Document, with optional search path and read o...
Definition: XmlIo.h:27
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.
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.
MX_FORMAT_API void writeToXmlFile(DocumentPtr doc, const FilePath &filename, const XmlWriteOptions *writeOptions=nullptr)
Write a Document as XML to the given filename.
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.
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 ...
MX_FORMAT_API string writeToXmlString(DocumentPtr doc, const XmlWriteOptions *writeOptions=nullptr)
Write a Document as XML to a new string, returned by value.
MX_FORMAT_API void writeToXmlStream(DocumentPtr doc, std::ostream &stream, const XmlWriteOptions *writeOptions=nullptr)
Write a Document as XML to the given output stream.
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.
An exception that is thrown when a requested file cannot be opened.
Definition: XmlIo.h:86
The base class for exceptions that are propagated from the MaterialX library to the client applicatio...
Definition: Exception.h:22
An exception that is thrown when a requested document cannot be parsed.
Definition: XmlIo.h:78
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:27
A sequence of file paths, which may be queried to find the first instance of a given filename on the ...
Definition: File.h:219
A set of options for controlling the behavior of XML read functions.
Definition: XmlIo.h:32
bool readNewlines
If true, then XML newlines will be read into documents as newline elements.
Definition: XmlIo.h:43
bool readComments
If true, then XML comments will be read into documents as comment elements.
Definition: XmlIo.h:39
StringVec parentXIncludes
The vector of parent XIncludes at the scope of the current document.
Definition: XmlIo.h:55
XmlReadFunction readXIncludeFunction
If provided, this function will be invoked when an XInclude reference needs to be read into a documen...
Definition: XmlIo.h:51
bool upgradeVersion
If true, then documents from earlier versions of MaterialX will be upgraded to the current version.
Definition: XmlIo.h:47
A set of options for controlling the behavior of XML write functions.
Definition: XmlIo.h:61
bool writeXIncludeEnable
If true, elements with source file markings will be written as XIncludes rather than explicit data.
Definition: XmlIo.h:68
ElementPredicate elementPredicate
If provided, this function will be used to exclude specific elements (those returning false) from the...
Definition: XmlIo.h:72