MaterialX 1.38.2
XmlIo.h
Go to the documentation of this file.
1//
2// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3// All rights reserved. See LICENSE.txt for license.
4//
5
6#ifndef MATERIALX_XMLIO_H
7#define MATERIALX_XMLIO_H
8
11
13
15
18
19namespace MaterialX
20{
21
22class XmlReadOptions;
23
24extern MX_FORMAT_API const string MTLX_EXTENSION;
25
28using XmlReadFunction = std::function<void(DocumentPtr, const FilePath&, const FileSearchPath&, const XmlReadOptions*)>;
29
32class MX_FORMAT_API XmlReadOptions
33{
34 public:
36 ~XmlReadOptions() { }
37
41
45
49};
50
53class MX_FORMAT_API XmlWriteOptions
54{
55 public:
58
62
66};
67
70class MX_FORMAT_API ExceptionParseError : public Exception
71{
72 public:
73 using Exception::Exception;
74};
75
78class MX_FORMAT_API ExceptionFileMissing : public Exception
79{
80 public:
81 using Exception::Exception;
82};
83
86
94MX_FORMAT_API void readFromXmlBuffer(DocumentPtr doc, const char* buffer, const XmlReadOptions* readOptions = nullptr);
95
103MX_FORMAT_API void readFromXmlStream(DocumentPtr doc, std::istream& stream, const XmlReadOptions* readOptions = nullptr);
104
118MX_FORMAT_API void readFromXmlFile(DocumentPtr doc,
119 FilePath filename,
120 FileSearchPath searchPath = FileSearchPath(),
121 const XmlReadOptions* readOptions = nullptr);
122
130MX_FORMAT_API void readFromXmlString(DocumentPtr doc, const string& str, const XmlReadOptions* readOptions = nullptr);
131
135
142MX_FORMAT_API void writeToXmlStream(DocumentPtr doc, std::ostream& stream, const XmlWriteOptions* writeOptions = nullptr);
143
151MX_FORMAT_API void writeToXmlFile(DocumentPtr doc, const FilePath& filename, const XmlWriteOptions* writeOptions = nullptr);
152
159MX_FORMAT_API string writeToXmlString(DocumentPtr doc, const XmlWriteOptions* writeOptions = nullptr);
160
164
169MX_FORMAT_API void prependXInclude(DocumentPtr doc, const FilePath& filename);
170
172
173} // namespace MaterialX
174
175#endif
The top-level Document class.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:23
std::function< bool(ConstElementPtr)> ElementPredicate
A standard function taking an ElementPtr and returning a boolean.
Definition: Element.h:67
Cross-platform support for file and search paths.
Library-wide includes and types.
vector< string > StringVec
A vector of strings.
Definition: Library.h:56
Macros for declaring imported and exported symbols.
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:28
An exception that is thrown when a requested file cannot be opened.
Definition: XmlIo.h:79
The base class for exceptions that are propagated from the MaterialX library to the client applicatio...
Definition: Exception.h:23
An exception that is thrown when a requested document cannot be parsed.
Definition: XmlIo.h:71
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:28
A sequence of file paths, which may be queried to find the first instance of a given filename on the ...
Definition: File.h:213
A set of options for controlling the behavior of XML read functions.
Definition: XmlIo.h:33
bool readComments
If true, then XML comments will be read into documents as comment elements.
Definition: XmlIo.h:44
StringVec parentXIncludes
The vector of parent XIncludes at the scope of the current document.
Definition: XmlIo.h:48
XmlReadFunction readXIncludeFunction
If provided, this function will be invoked when an XInclude reference needs to be read into a documen...
Definition: XmlIo.h:40
A set of options for controlling the behavior of XML write functions.
Definition: XmlIo.h:54
bool writeXIncludeEnable
If true, elements with source file markings will be written as XIncludes rather than explicit data.
Definition: XmlIo.h:61
ElementPredicate elementPredicate
If provided, this function will be used to exclude specific elements (those returning false) from the...
Definition: XmlIo.h:65