MaterialX  1.36.1
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 
12 #include <MaterialXCore/Library.h>
13 
14 #include <MaterialXCore/Document.h>
15 
16 namespace MaterialX
17 {
18 
19 class XmlReadOptions;
20 
23 using XmlReadFunction = std::function<void(DocumentPtr, string, string, const XmlReadOptions*)>;
24 
28 {
29  public:
31  ~XmlReadOptions() { }
32 
36 
39  std::set<string> parentFilenames;
40 };
41 
45 {
46  public:
48  ~XmlWriteOptions() { }
49 
53 
57 };
58 
62 {
63  public:
64  using Exception::Exception;
65 };
66 
70 {
71  public:
72  using Exception::Exception;
73 };
74 
77 
85 void readFromXmlBuffer(DocumentPtr doc, const char* buffer, const XmlReadOptions* readOptions = nullptr);
86 
94 void readFromXmlStream(DocumentPtr doc, std::istream& stream, const XmlReadOptions* readOptions = nullptr);
95 
107 void readFromXmlFile(DocumentPtr doc,
108  const string& filename,
109  const string& searchPath = EMPTY_STRING,
110  const XmlReadOptions* readOptions = nullptr);
111 
119 void readFromXmlString(DocumentPtr doc, const string& str, const XmlReadOptions* readOptions = nullptr);
120 
124 
131 void writeToXmlStream(DocumentPtr doc, std::ostream& stream, const XmlWriteOptions* writeOptions = nullptr);
132 
139 void writeToXmlFile(DocumentPtr doc, const string& filename, const XmlWriteOptions* writeOptions = nullptr);
140 
147 string writeToXmlString(DocumentPtr doc, const XmlWriteOptions* writeOptions = nullptr);
148 
152 
157 void prependXInclude(DocumentPtr doc, const string& filename);
158 
160 
161 } // namespace MaterialX
162 
163 #endif
A set of options for controlling the behavior of XML read functions.
Definition: XmlIo.h:27
Definition: Definition.cpp:10
std::set< string > parentFilenames
The set of parent filenames at the scope of the current document.
Definition: XmlIo.h:39
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:25
std::function< void(DocumentPtr, string, string, 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:23
The top-level Document class.
A set of options for controlling the behavior of XML write functions.
Definition: XmlIo.h:44
The base class for exceptions that are propagated from the MaterialX library to the client applicatio...
Definition: Library.h:40
XmlReadFunction readXIncludeFunction
If provided, this function will be invoked when an XInclude reference needs to be read into a documen...
Definition: XmlIo.h:35
A set of options for controlling the behavior of element copy operations.
Definition: Element.h:1242
bool writeXIncludeEnable
If true, elements with source file markings will be written as XIncludes rather than explicit data...
Definition: XmlIo.h:52
Library-wide includes and types.
ElementPredicate elementPredicate
If provided, this function will be used to exclude specific elements (those returning false) from the...
Definition: XmlIo.h:56
An exception that is thrown when a requested document cannot be parsed.
Definition: XmlIo.h:61
An exception that is thrown when a requested file cannot be opened.
Definition: XmlIo.h:69
std::function< bool(ElementPtr)> ElementPredicate
A standard function taking an ElementPtr and returning a boolean.
Definition: Element.h:57