All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
9 /// @file
10 /// Format utility methods
12 #include <MaterialXCore/Document.h>
13 #include <MaterialXCore/Element.h>
16 #include <MaterialXFormat/Export.h>
17 #include <MaterialXFormat/File.h>
18 #include <MaterialXFormat/XmlIo.h>
22 /// Read the given file and return a string containing its contents; if the read is not
23 /// successful, then the empty string is returned.
24 MX_FORMAT_API string readFile(const FilePath& file);
26 /// Get all subdirectories for a given set of directories and search paths
27 MX_FORMAT_API void getSubdirectories(const FilePathVec& rootDirectories, const FileSearchPath& searchPath, FilePathVec& subDirectories);
29 /// Scans for all documents under a root path and returns documents which can be loaded
30 MX_FORMAT_API void loadDocuments(const FilePath& rootPath,
31  const FileSearchPath& searchPath,
32  const StringSet& skipFiles,
33  const StringSet& includeFiles,
34  vector<DocumentPtr>& documents,
35  StringVec& documentsPaths,
36  const XmlReadOptions* readOptions = nullptr,
37  StringVec* errors = nullptr);
39 /// Load a given MaterialX library into a document
40 MX_FORMAT_API void loadLibrary(const FilePath& file,
41  DocumentPtr doc,
42  const FileSearchPath& searchPath = FileSearchPath(),
43  const XmlReadOptions* readOptions = nullptr);
45 /// Load all MaterialX files within the given library folders into a document,
46 /// using the given search path to locate the folders on the file system.
47 MX_FORMAT_API StringSet loadLibraries(const FilePathVec& libraryFolders,
48  const FileSearchPath& searchPath,
49  DocumentPtr doc,
50  const StringSet& excludeFiles = StringSet(),
51  const XmlReadOptions* readOptions = nullptr);
53 /// Flatten all filenames in the given document, applying string resolvers at the
54 /// scope of each element and removing all fileprefix attributes.
55 /// @param doc The document to modify.
56 /// @param searchPath An optional search path for relative to absolute path conversion.
57 /// @param customResolver An optional custom resolver to apply.
58 MX_FORMAT_API void flattenFilenames(DocumentPtr doc, const FileSearchPath& searchPath = FileSearchPath(), StringResolverPtr customResolver = nullptr);
62 #endif
MX_FORMAT_API void getSubdirectories(const FilePathVec &rootDirectories, const FileSearchPath &searchPath, FilePathVec &subDirectories)
Get all subdirectories for a given set of directories and search paths.
MATERIALX_NAMESPACE_BEGIN MX_FORMAT_API string readFile(const FilePath &file)
Definition: File.h:26
Definition: Generated.h:23
vector< string > StringVec
A vector of strings.
Definition: Library.h:57
Definition: Export.h:18
MX_FORMAT_API void loadLibrary(const FilePath &file, DocumentPtr doc, const FileSearchPath &searchPath=FileSearchPath(), const XmlReadOptions *readOptions=nullptr)
Load a given MaterialX library into a document.
MX_FORMAT_API void loadDocuments(const FilePath &rootPath, const FileSearchPath &searchPath, const StringSet &skipFiles, const StringSet &includeFiles, vector< DocumentPtr > &documents, StringVec &documentsPaths, const XmlReadOptions *readOptions=nullptr, StringVec *errors=nullptr)
Scans for all documents under a root path and returns documents which can be loaded.
MX_FORMAT_API StringSet loadLibraries(const FilePathVec &libraryFolders, const FileSearchPath &searchPath, DocumentPtr doc, const StringSet &excludeFiles=StringSet(), const XmlReadOptions *readOptions=nullptr)
MX_FORMAT_API void flattenFilenames(DocumentPtr doc, const FileSearchPath &searchPath=FileSearchPath(), StringResolverPtr customResolver=nullptr)
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
vector< FilePath > FilePathVec
Definition: File.h:19
shared_ptr< StringResolver > StringResolverPtr
A shared pointer to a StringResolver.
Definition: Element.h:60
std::set< string > StringSet
A set of strings.
Definition: Library.h:61
Definition: Generated.h:24