All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
textFileFormat.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef SD_MENVA_FILE_FORMAT_H
25 #define SD_MENVA_FILE_FORMAT_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/usd/sdf/declareHandles.h"
32 #include "pxr/usd/sdf/fileFormat.h"
33 #include "pxr/base/tf/staticTokens.h"
34 
35 #include <iosfwd>
36 #include <string>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 #define SDF_TEXT_FILE_FORMAT_TOKENS \
41  ((Id, "sdf")) \
42  ((Version, "1.4.32")) \
43  ((Target, "sdf"))
44 
45 TF_DECLARE_PUBLIC_TOKENS(SdfTextFileFormatTokens,
46  SDF_API, SDF_TEXT_FILE_FORMAT_TOKENS);
47 
49 
50 SDF_DECLARE_HANDLES(SdfSpec);
51 
57 {
58 public:
64  SDF_API
65  bool Write(
66  const SdfLayer& layer,
67  std::ostream& ostr,
68  const std::string& comment = std::string()) const;
69 
73  SDF_API
74  bool WriteToStream(
75  const SdfLayer& layer,
76  std::ostream& ostr) const;
77 
78  // SdfFileFormat overrides.
79  SDF_API
80  virtual bool CanRead(const std::string &file) const override;
81 
82  SDF_API
83  virtual bool Read(
84  SdfLayer* layer,
85  const std::string& resolvedPath,
86  bool metadataOnly) const override;
87 
88  SDF_API
89  virtual bool WriteToFile(
90  const SdfLayer& layer,
91  const std::string& filePath,
92  const std::string& comment = std::string(),
93  const FileFormatArguments& args = FileFormatArguments()) const override;
94 
95  SDF_API
96  virtual bool ReadFromString(
97  SdfLayer* layer,
98  const std::string& str) const override;
99 
100  SDF_API
101  virtual bool WriteToString(
102  const SdfLayer& layer,
103  std::string* str,
104  const std::string& comment = std::string()) const override;
105 
106  SDF_API
107  virtual bool WriteToStream(
108  const SdfSpecHandle &spec,
109  std::ostream& out,
110  size_t indent) const override;
111 
112 protected:
113  SDF_FILE_FORMAT_FACTORY_ACCESS;
114 
116  SDF_API
117  virtual ~SdfTextFileFormat();
118 
120  SDF_API
122 
127  SDF_API
128  explicit SdfTextFileFormat(const TfToken& formatId,
129  const TfToken& versionString = TfToken(),
130  const TfToken& target = TfToken());
131 
132 private:
133 
134  // Override to return false. Reloading anonymous menva files clears their
135  // content.
136  SDF_API virtual bool _ShouldSkipAnonymousReload() const override;
137 };
138 
139 PXR_NAMESPACE_CLOSE_SCOPE
140 
141 #endif // SDF_TEXT_FILE_FORMAT_H
A unit of scene description that you combine with other units of scene description to form a shot...
Definition: layer.h:93
SDF_API SdfTextFileFormat()
Constructor.
Sdf text file format.
virtual SDF_API bool CanRead(const std::string &file) const override
Returns true if file can be read by this format.
Base class for all Sdf spec classes.
Definition: spec.h:51
virtual SDF_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.
virtual SDF_API ~SdfTextFileFormat()
Destructor.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
SDF_API bool WriteToStream(const SdfLayer &layer, std::ostream &ostr) const
Writes the content in layer into the stream ostr.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to the various API below.
Definition: fileFormat.h:113
virtual SDF_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.
SDF_API bool Write(const SdfLayer &layer, std::ostream &ostr, const std::string &comment=std::string()) const
Writes the content of the layer layer to the stream ostr.
virtual SDF_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.
Base class for file format implementations.
Definition: fileFormat.h:63
virtual SDF_API bool ReadFromString(SdfLayer *layer, const std::string &str) const override
Reads data in the string str into the layer layer.