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 PXR_USD_SDF_TEXT_FILE_FORMAT_H
25 #define PXR_USD_SDF_TEXT_FILE_FORMAT_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
32 #include "pxr/usd/sdf/fileFormat.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:
59  // SdfFileFormat overrides.
60  SDF_API
61  virtual bool CanRead(const std::string &file) const override;
62 
63  SDF_API
64  virtual bool Read(
65  SdfLayer* layer,
66  const std::string& resolvedPath,
67  bool metadataOnly) const override;
68 
69  SDF_API
70  virtual bool WriteToFile(
71  const SdfLayer& layer,
72  const std::string& filePath,
73  const std::string& comment = std::string(),
74  const FileFormatArguments& args = FileFormatArguments()) const override;
75 
76  SDF_API
77  virtual bool ReadFromString(
78  SdfLayer* layer,
79  const std::string& str) const override;
80 
81  SDF_API
82  virtual bool WriteToString(
83  const SdfLayer& layer,
84  std::string* str,
85  const std::string& comment = std::string()) const override;
86 
87  SDF_API
88  virtual bool WriteToStream(
89  const SdfSpecHandle &spec,
90  std::ostream& out,
91  size_t indent) const override;
92 
93 protected:
94  SDF_FILE_FORMAT_FACTORY_ACCESS;
95 
97  SDF_API
98  virtual ~SdfTextFileFormat();
99 
101  SDF_API
103 
109  SDF_API
110  explicit SdfTextFileFormat(const TfToken& formatId,
111  const TfToken& versionString = TfToken(),
112  const TfToken& target = TfToken());
113 
114 private:
115  // Override to return false. Reloading anonymous text layers clears their
116  // content.
117  SDF_API virtual bool _ShouldSkipAnonymousReload() const override;
118 };
119 
120 PXR_NAMESPACE_CLOSE_SCOPE
121 
122 #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:96
virtual SDF_API bool WriteToStream(const SdfSpecHandle &spec, std::ostream &out, size_t indent) const override
Write the provided spec to out indented indent levels.
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
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
#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:119
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.
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.
This file defines some macros that are useful for declaring and using static TfTokens.
Base class for file format implementations.
Definition: fileFormat.h:64
virtual SDF_API bool ReadFromString(SdfLayer *layer, const std::string &str) const override
Reads data in the string str into the layer layer.