This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
usdcFileFormat.h
1//
2// Copyright 2016 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_USDC_FILE_FORMAT_H
8#define PXR_USD_USD_USDC_FILE_FORMAT_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/usd/api.h"
14#include <string>
15
16PXR_NAMESPACE_OPEN_SCOPE
17
18#define USD_USDC_FILE_FORMAT_TOKENS \
19 ((Id, "usdc"))
20
21TF_DECLARE_PUBLIC_TOKENS(UsdUsdcFileFormatTokens, USD_API, USD_USDC_FILE_FORMAT_TOKENS);
22
24
25class ArAsset;
26
32{
33public:
35 using string = std::string;
36
37 virtual SdfAbstractDataRefPtr InitData(
38 const FileFormatArguments& args) const override;
39
40 virtual bool CanRead(const string &file) const override;
41
42 virtual bool Read(
43 SdfLayer* layer,
44 const string& resolvedPath,
45 bool metadataOnly) const override;
46
47 virtual bool WriteToFile(
48 const SdfLayer& layer,
49 const string& filePath,
50 const string& comment = string(),
51 const FileFormatArguments& args = FileFormatArguments()) const override;
52
53 virtual bool SaveToFile(
54 const SdfLayer& layer,
55 const string& filePath,
56 const string& comment = string(),
57 const FileFormatArguments& args = FileFormatArguments()) const override;
58
59 virtual bool ReadFromString(SdfLayer* layer,
60 const string& str) const override;
61
62 virtual bool WriteToString(const SdfLayer& layer,
63 string* str,
64 const string& comment = string()) const override;
65
66 virtual bool WriteToStream(const SdfSpecHandle &spec,
67 std::ostream& out,
68 size_t indent) const override;
69
70protected:
71 SDF_FILE_FORMAT_FACTORY_ACCESS;
72
74 virtual ~UsdUsdcFileFormat();
75
76private:
77 friend class UsdUsdFileFormat;
78
79 SdfAbstractDataRefPtr _InitDetachedData(
80 const FileFormatArguments& args) const override;
81
82 bool _ReadDetached(
83 SdfLayer* layer,
84 const std::string& resolvedPath,
85 bool metadataOnly) const override;
86
87 bool _CanReadFromAsset(
88 const std::string& resolvedPath,
89 const std::shared_ptr<ArAsset>& asset) const;
90
91 bool _ReadFromAsset(
92 SdfLayer* layer,
93 const std::string& resolvedPath,
94 const std::shared_ptr<ArAsset>& asset,
95 bool metadataOnly,
96 bool detached) const;
97
98 template <class ...Args>
99 bool _ReadHelper(
100 SdfLayer* layer,
101 const std::string& resolvedPath,
102 bool metadataOnly,
103 Args&&... args) const;
104
105};
106
107PXR_NAMESPACE_CLOSE_SCOPE
108
109#endif // PXR_USD_USD_USDC_FILE_FORMAT_H
Interface for accessing the contents of an asset.
Definition: asset.h:27
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 USD files.
Definition: usdFileFormat.h:43
File format for binary Usd files.
virtual bool ReadFromString(SdfLayer *layer, const string &str) const override
Reads data in the string str into the layer layer.
virtual bool WriteToString(const SdfLayer &layer, string *str, const string &comment=string()) const override
Writes the content in layer to the string str.
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 bool CanRead(const string &file) const override
Returns true if file can be read by this format.
virtual bool Read(SdfLayer *layer, const string &resolvedPath, bool metadataOnly) const override
Reads scene description from the asset specified by resolvedPath into the layer layer.
virtual bool WriteToFile(const SdfLayer &layer, const string &filePath, const string &comment=string(), const FileFormatArguments &args=FileFormatArguments()) const override
Writes the content in layer into the file at filePath.
virtual bool SaveToFile(const SdfLayer &layer, const string &filePath, const string &comment=string(), const FileFormatArguments &args=FileFormatArguments()) const override
Write the content in layer to the file at filePath, which is the backing store for layer itself.
virtual SdfAbstractDataRefPtr InitData(const FileFormatArguments &args) const override
This method allows the file format to bind to whatever data container is appropriate.
virtual bool WriteToStream(const SdfSpecHandle &spec, std::ostream &out, size_t indent) const override
Write the provided spec to out indented indent levels.
#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