HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
usdcFileFormat.h
Go to the documentation of this file.
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"
12 #include "pxr/usd/sdf/fileFormat.h"
14 #include <string>
15 
17 
18 #define USD_USDC_FILE_FORMAT_TOKENS \
19  ((Id, "usdc"))
20 
22 
24 
25 class ArAsset;
26 
27 /// \class UsdUsdcFileFormat
28 ///
29 /// File format for binary Usd files.
30 ///
32 {
33 public:
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 
70 protected:
72 
74  virtual ~UsdUsdcFileFormat();
75 
76 private:
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 
108 
109 #endif // PXR_USD_USD_USDC_FILE_FORMAT_H
Definition: layer.h:81
#define USD_API
Definition: api.h:23
#define USD_USDC_FILE_FORMAT_TOKENS
Definition: asset.h:27
virtual ~UsdUsdcFileFormat()
virtual bool WriteToStream(const SdfSpecHandle &spec, std::ostream &out, size_t indent) const override
Write the provided spec to out indented indent levels.
virtual bool ReadFromString(SdfLayer *layer, const string &str) const override
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
virtual SdfAbstractDataRefPtr InitData(const FileFormatArguments &args) const override
virtual bool CanRead(const string &file) const override
Returns true if file can be read by this format.
virtual bool SaveToFile(const SdfLayer &layer, const string &filePath, const string &comment=string(), const FileFormatArguments &args=FileFormatArguments()) const override
virtual bool Read(SdfLayer *layer, const string &resolvedPath, bool metadataOnly) const override
virtual bool WriteToString(const SdfLayer &layer, string *str, const string &comment=string()) const override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
SdfAbstractDataRefPtr _InitDetachedData(const FileFormatArguments &args) const override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool _ReadDetached(SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const override
TF_DECLARE_PUBLIC_TOKENS(UsdUsdcFileFormatTokens, USD_API, USD_USDC_FILE_FORMAT_TOKENS)
**If you just want to fire and args
Definition: thread.h:618
virtual bool WriteToFile(const SdfLayer &layer, const string &filePath, const string &comment=string(), const FileFormatArguments &args=FileFormatArguments()) const override
TF_DECLARE_WEAK_AND_REF_PTRS(UsdUsdcFileFormat)
std::map< std::string, std::string > FileFormatArguments
Definition: fileFormat.h:102