All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
usdzFileFormat.h
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_USD_USDZ_FILE_FORMAT_H
8#define PXR_USD_USD_USDZ_FILE_FORMAT_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/usd/api.h"
14
15#include <string>
16
17PXR_NAMESPACE_OPEN_SCOPE
18
20
21#define USD_USDZ_FILE_FORMAT_TOKENS \
22 ((Id, "usdz")) \
23 ((Version, "1.0")) \
24 ((Target, "usd"))
25
27 UsdUsdzFileFormatTokens, USD_API, USD_USDZ_FILE_FORMAT_TOKENS);
28
33{
34public:
36
37 USD_API
38 virtual bool IsPackage() const override;
39
40 USD_API
41 virtual std::string GetPackageRootLayerPath(
42 const std::string& resolvedPath) const override;
43
44 USD_API
45 virtual SdfAbstractDataRefPtr
46 InitData(const FileFormatArguments& args) const override;
47
48 USD_API
49 virtual bool CanRead(const std::string &file) const override;
50
51 USD_API
52 virtual bool Read(
53 SdfLayer* layer,
54 const std::string& resolvedPath,
55 bool metadataOnly) const override;
56
57 USD_API
58 virtual bool WriteToFile(
59 const SdfLayer& layer,
60 const std::string& filePath,
61 const std::string& comment = std::string(),
62 const FileFormatArguments& args = FileFormatArguments()) const override;
63
64 USD_API
65 virtual bool ReadFromString(
66 SdfLayer* layer,
67 const std::string& str) const override;
68
69 USD_API
70 virtual bool WriteToString(
71 const SdfLayer& layer,
72 std::string* str,
73 const std::string& comment = std::string()) const override;
74
75 USD_API
76 virtual bool WriteToStream(
77 const SdfSpecHandle &spec,
78 std::ostream& out,
79 size_t indent) const override;
80
81protected:
82 SDF_FILE_FORMAT_FACTORY_ACCESS;
83
85 SdfLayer* layer,
86 const std::string& resolvedPath,
87 bool metadataOnly) const override;
88
89private:
91 virtual ~UsdUsdzFileFormat();
92
93 template <bool Detached>
94 bool _ReadHelper(
95 SdfLayer* layer,
96 const std::string& resolvedPath,
97 bool metadataOnly) const;
98};
99
100PXR_NAMESPACE_CLOSE_SCOPE
101
102#endif // PXR_USD_USD_USDZ_FILE_FORMAT_H
Base class for file format implementations.
Definition: fileFormat.h:50
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to the various API below.
Definition: fileFormat.h:102
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:84
File format for package .usdz files.
virtual USD_API bool WriteToString(const SdfLayer &layer, std::string *str, const std::string &comment=std::string()) const override
Writes the content in layer to the string str.
virtual USD_API bool WriteToStream(const SdfSpecHandle &spec, std::ostream &out, size_t indent) const override
Write the provided spec to out indented indent levels.
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to the various API below.
Definition: fileFormat.h:102
virtual USD_API bool IsPackage() const override
Returns true if this file format is a package containing other assets.
bool _ReadDetached(SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const override
virtual USD_API SdfAbstractDataRefPtr InitData(const FileFormatArguments &args) const override
This method allows the file format to bind to whatever data container is appropriate.
virtual USD_API bool Read(SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const override
Reads scene description from the asset specified by resolvedPath into the layer layer.
virtual USD_API bool ReadFromString(SdfLayer *layer, const std::string &str) const override
Reads data in the string str into the layer layer.
virtual USD_API std::string GetPackageRootLayerPath(const std::string &resolvedPath) const override
Returns the path of the "root" layer contained in the package layer at resolvedPath produced by this ...
virtual USD_API bool CanRead(const std::string &file) const override
Returns true if file can be read by this format.
virtual USD_API bool WriteToFile(const SdfLayer &layer, const std::string &filePath, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const override
Writes the content in layer into the file at filePath.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:81