Loading...
Searching...
No Matches
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"
34
35#include <iosfwd>
36#include <string>
37
38PXR_NAMESPACE_OPEN_SCOPE
39
40#define SDF_TEXT_FILE_FORMAT_TOKENS \
41 ((Id, "sdf")) \
42 ((Version, "1.4.32")) \
43 ((Target, "sdf"))
44
45TF_DECLARE_PUBLIC_TOKENS(SdfTextFileFormatTokens,
46 SDF_API, SDF_TEXT_FILE_FORMAT_TOKENS);
47
49
50SDF_DECLARE_HANDLES(SdfSpec);
51
52class ArAsset;
53
59{
60public:
61 // SdfFileFormat overrides.
62 SDF_API
63 virtual bool CanRead(const std::string &file) const override;
64
65 SDF_API
66 virtual bool Read(
67 SdfLayer* layer,
68 const std::string& resolvedPath,
69 bool metadataOnly) const override;
70
71 SDF_API
72 virtual bool WriteToFile(
73 const SdfLayer& layer,
74 const std::string& filePath,
75 const std::string& comment = std::string(),
76 const FileFormatArguments& args = FileFormatArguments()) const override;
77
78 SDF_API
79 virtual bool ReadFromString(
80 SdfLayer* layer,
81 const std::string& str) const override;
82
83 SDF_API
84 virtual bool WriteToString(
85 const SdfLayer& layer,
86 std::string* str,
87 const std::string& comment = std::string()) const override;
88
89 SDF_API
90 virtual bool WriteToStream(
91 const SdfSpecHandle &spec,
92 std::ostream& out,
93 size_t indent) const override;
94
95protected:
96 SDF_FILE_FORMAT_FACTORY_ACCESS;
97
99 SDF_API
101
103 SDF_API
105
111 SDF_API
112 explicit SdfTextFileFormat(const TfToken& formatId,
113 const TfToken& versionString = TfToken(),
114 const TfToken& target = TfToken());
115
117 SDF_API
119 const std::string& resolvedPath,
120 const std::shared_ptr<ArAsset>& asset) const;
121
123 SDF_API
125 SdfLayer* layer,
126 const std::string& resolvedPath,
127 const std::shared_ptr<ArAsset>& asset,
128 bool metadataOnly) const;
129
130private:
131 // Override to return false. Reloading anonymous text layers clears their
132 // content.
133 SDF_API virtual bool _ShouldSkipAnonymousReload() const override;
134};
135
136PXR_NAMESPACE_CLOSE_SCOPE
137
138#endif // SDF_TEXT_FILE_FORMAT_H
Interface for accessing the contents of an asset.
Definition: asset.h:44
Base class for file format implementations.
Definition: fileFormat.h:67
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to the various API below.
Definition: fileFormat.h:119
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:100
Base class for all Sdf spec classes.
Definition: spec.h:50
Sdf text file format.
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 bool _CanReadFromAsset(const std::string &resolvedPath, const std::shared_ptr< ArAsset > &asset) const
Return true if layer can be read from asset at resolvedPath.
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 _ReadFromAsset(SdfLayer *layer, const std::string &resolvedPath, const std::shared_ptr< ArAsset > &asset, bool metadataOnly) const
Read layer from asset at resolvedPath into layer.
SDF_API SdfTextFileFormat()
Constructor.
SDF_API SdfTextFileFormat(const TfToken &formatId, const TfToken &versionString=TfToken(), const TfToken &target=TfToken())
Constructor.
virtual SDF_API bool ReadFromString(SdfLayer *layer, const std::string &str) const override
Reads data in the string str into the layer layer.
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 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 SDF_API ~SdfTextFileFormat()
Destructor.
virtual SDF_API bool CanRead(const std::string &file) const override
Returns true if file can be read by this format.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
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:108