Loading...
Searching...
No Matches
SdfFileFormat Class Referenceabstract

Base class for file format implementations. More...

#include <fileFormat.h>

+ Inheritance diagram for SdfFileFormat:

Public Types

typedef std::map< std::string, std::string > FileFormatArguments
 Type for specifying additional file format-specific arguments to the various API below.
 
- Public Types inherited from TfRefBase
typedef void(* UniqueChangedFuncPtr) (TfRefBase const *, bool)
 

Public Member Functions

 SdfFileFormat (const SdfFileFormat &)=delete
 
SdfFileFormatoperator= (const SdfFileFormat &)=delete
 
SDF_API const SdfSchemaBaseGetSchema () const
 Returns the schema for this format.
 
SDF_API const TfTokenGetFormatId () const
 Returns the format identifier.
 
SDF_API const TfTokenGetTarget () const
 Returns the target for this file format.
 
SDF_API const std::string & GetFileCookie () const
 Returns the cookie to be used when writing files with this format.
 
SDF_API const TfTokenGetVersionString () const
 Returns the current version of this file format.
 
SDF_API bool IsPrimaryFormatForExtensions () const
 Returns true if this file format is the primary format for the extensions it handles.
 
SDF_API const std::vector< std::string > & GetFileExtensions () const
 Returns a list of extensions that this format supports.
 
SDF_API const std::string & GetPrimaryFileExtension () const
 Returns the primary file extension for this format.
 
SDF_API bool IsSupportedExtension (const std::string &extension) const
 Returns true if extension matches one of the extensions returned by GetFileExtensions.
 
virtual SDF_API bool IsPackage () const
 Returns true if this file format is a package containing other assets.
 
virtual SDF_API std::string GetPackageRootLayerPath (const std::string &resolvedPath) const
 Returns the path of the "root" layer contained in the package layer at resolvedPath produced by this file format.
 
virtual SDF_API FileFormatArguments GetDefaultFileFormatArguments () const
 Returns the FileFormatArguments that correspond to the default behavior of this file format when no FileFormatArguments are passed to NewLayer or InitData.
 
virtual SDF_API SdfAbstractDataRefPtr InitData (const FileFormatArguments &args) const
 This method allows the file format to bind to whatever data container is appropriate.
 
SDF_API SdfAbstractDataRefPtr InitDetachedData (const FileFormatArguments &args) const
 Returns a new SdfAbstractData providing access to the layer's data.
 
SDF_API SdfLayerRefPtr NewLayer (const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const std::string &realPath, const ArAssetInfo &assetInfo, const FileFormatArguments &args) const
 Instantiate a layer.
 
SDF_API bool ShouldSkipAnonymousReload () const
 Return true if this file format prefers to skip reloading anonymous layers.
 
SDF_API bool ShouldReadAnonymousLayers () const
 Returns true if anonymous layer identifiers should be passed to Read when a layer is opened or reloaded.
 
virtual SDF_API bool CanRead (const std::string &file) const =0
 Returns true if file can be read by this format.
 
virtual SDF_API bool Read (SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const =0
 Reads scene description from the asset specified by resolvedPath into the layer layer.
 
SDF_API bool ReadDetached (SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const
 Reads scene description from the asset specified by resolvedPath into the detached 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
 Writes the content in layer into the file at filePath.
 
virtual SDF_API bool SaveToFile (const SdfLayer &layer, const std::string &filePath, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const
 Write the content in layer to the file at filePath, which is the backing store for layer itself.
 
virtual SDF_API bool ReadFromString (SdfLayer *layer, const std::string &str) const
 Reads data in the string str into the layer layer.
 
virtual SDF_API bool WriteToStream (const SdfSpecHandle &spec, std::ostream &out, size_t indent) const
 Write the provided spec to out indented indent levels.
 
virtual SDF_API bool WriteToString (const SdfLayer &layer, std::string *str, const std::string &comment=std::string()) const
 Writes the content in layer to the string str.
 
virtual SDF_API std::set< std::string > GetExternalAssetDependencies (const SdfLayer &layer) const
 Returns the set of resolved paths to external asset file dependencies for the given layer.
 
SDF_API bool SupportsReading () const
 Returns true if this file format supports reading.
 
SDF_API bool SupportsWriting () const
 This is a convenience method for invoking FormatSupportsWriting with this format's extension and target.
 
SDF_API bool SupportsEditing () const
 This is a convenience method for invoking FormatSupportsEditing with this format's extension and target.
 
- Public Member Functions inherited from TfRefBase
 TfRefBase (TfRefBase const &)
 
TfRefBaseoperator= (TfRefBase const &)
 
size_t GetCurrentCount () const
 Return the current reference count of this object.
 
bool IsUnique () const
 Return true if only one TfRefPtr points to this object.
 
void SetShouldInvokeUniqueChangedListener (bool shouldCall)
 
- Public Member Functions inherited from TfWeakBase
 TfWeakBase (const TfWeakBase &)
 
const TfWeakBase__GetTfWeakBase__ () const
 
const TfWeakBaseoperator= (const TfWeakBase &)
 
void EnableNotification2 () const
 
TF_API void const * GetUniqueIdentifier () const
 

Static Public Member Functions

static SDF_API std::string GetFileExtension (const std::string &s)
 Returns the file extension for path or file name s, without the leading dot character.
 
static SDF_API std::set< std::string > FindAllFileFormatExtensions ()
 Returns a set containing the extension(s) corresponding to all registered file formats.
 
static SDF_API std::set< std::string > FindAllDerivedFileFormatExtensions (const TfType &baseType)
 Returns a set containing the extension(s) corresponding to all registered file formats that derive from baseType.
 
static SDF_API bool FormatSupportsReading (const std::string &extension, const std::string &target=std::string())
 Returns true if the file format for the supplied extension and target pair supports reading.
 
static SDF_API bool FormatSupportsWriting (const std::string &extension, const std::string &target=std::string())
 Returns true if the file format for the supplied extension and target pair supports writing.
 
static SDF_API bool FormatSupportsEditing (const std::string &extension, const std::string &target=std::string())
 Returns true if the file format for the supplied extension and target pair supports editing.
 
static SDF_API SdfFileFormatConstPtr FindById (const TfToken &formatId)
 Returns the file format instance with the specified formatId identifier.
 
static SDF_API SdfFileFormatConstPtr FindByExtension (const std::string &path, const std::string &target=std::string())
 Returns the file format instance that supports the extension for path.
 
static SDF_API SdfFileFormatConstPtr FindByExtension (const std::string &path, const FileFormatArguments &args)
 Returns a file format instance that supports the extension for path and whose target matches one of those specified by the given args.
 
- Static Public Member Functions inherited from TfRefBase
static TF_API void SetUniqueChangedListener (UniqueChangedListener listener)
 

Protected Member Functions

SDF_API SdfFileFormat (const TfToken &formatId, const TfToken &versionString, const TfToken &target, const std::string &extension)
 Constructor.
 
SDF_API SdfFileFormat (const TfToken &formatId, const TfToken &versionString, const TfToken &target, const std::string &extension, const SdfSchemaBase &schema)
 Constructor.
 
 SdfFileFormat (const TfToken &formatId, const TfToken &versionString, const TfToken &target, const std::string &extension, const SdfSchemaBase &&schema)=delete
 Disallow temporary SdfSchemaBase objects being passed to the c'tor.
 
SDF_API SdfFileFormat (const TfToken &formatId, const TfToken &versionString, const TfToken &target, const std::vector< std::string > &extensions)
 Constructor.
 
SDF_API SdfFileFormat (const TfToken &formatId, const TfToken &versionString, const TfToken &target, const std::vector< std::string > &extensions, const SdfSchemaBase &schema)
 Constructor.
 
 SdfFileFormat (const TfToken &formatId, const TfToken &versionString, const TfToken &target, const std::vector< std::string > &extensions, const SdfSchemaBase &&schema)=delete
 Disallow temporary SdfSchemaBase objects being passed to the c'tor.
 
virtual SDF_API ~SdfFileFormat ()
 Destructor.
 
SDF_API bool _ReadAndCopyLayerDataToMemory (SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly, bool *didCopyData=nullptr) const
 Helper function for _ReadDetached.
 
virtual SDF_API SdfLayer_InstantiateNewLayer (const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const std::string &realPath, const ArAssetInfo &assetInfo, const FileFormatArguments &args) const
 
virtual SDF_API bool _ShouldSkipAnonymousReload () const
 
virtual SDF_API bool _ShouldReadAnonymousLayers () const
 File format subclasses may override this to specify whether Read should be called when creating, opening, or reloading an anonymous layer of this format.
 
virtual SDF_API SdfAbstractDataRefPtr _InitDetachedData (const FileFormatArguments &args) const
 
virtual SDF_API bool _ReadDetached (SdfLayer *layer, const std::string &resolvedPath, bool metadataOnly) const
 
- Protected Member Functions inherited from TfWeakBase
TfRefPtr< Tf_Remnant > _Register () const
 
template<class T >
TfRefPtr< Tf_Remnant > _Register (T *tempRmnt) const
 
bool _HasRemnant () const
 

Static Protected Member Functions

static SDF_API void _SetLayerData (SdfLayer *layer, SdfAbstractDataRefPtr &data)
 Set the internal data for layer to data, possibly transferring ownership of data.
 
static SDF_API void _SetLayerData (SdfLayer *layer, SdfAbstractDataRefPtr &data, SdfLayerHints hints)
 Set the internal data for layer to data, possibly transferring ownership of data.
 
static SDF_API SdfAbstractDataConstPtr _GetLayerData (const SdfLayer &layer)
 Get the internal data for layer.
 

Detailed Description

Base class for file format implementations.

Definition at line 64 of file fileFormat.h.

Member Typedef Documentation

◆ FileFormatArguments

typedef std::map<std::string, std::string> FileFormatArguments

Type for specifying additional file format-specific arguments to the various API below.

Definition at line 119 of file fileFormat.h.

Constructor & Destructor Documentation

◆ SdfFileFormat() [1/6]

SDF_API SdfFileFormat ( const TfToken formatId,
const TfToken versionString,
const TfToken target,
const std::string &  extension 
)
protected

Constructor.

◆ SdfFileFormat() [2/6]

SDF_API SdfFileFormat ( const TfToken formatId,
const TfToken versionString,
const TfToken target,
const std::string &  extension,
const SdfSchemaBase schema 
)
protected

Constructor.

schema must remain valid for the lifetime of this file format.

◆ SdfFileFormat() [3/6]

SdfFileFormat ( const TfToken formatId,
const TfToken versionString,
const TfToken target,
const std::string &  extension,
const SdfSchemaBase &&  schema 
)
protecteddelete

Disallow temporary SdfSchemaBase objects being passed to the c'tor.

◆ SdfFileFormat() [4/6]

SDF_API SdfFileFormat ( const TfToken formatId,
const TfToken versionString,
const TfToken target,
const std::vector< std::string > &  extensions 
)
protected

Constructor.

◆ SdfFileFormat() [5/6]

SDF_API SdfFileFormat ( const TfToken formatId,
const TfToken versionString,
const TfToken target,
const std::vector< std::string > &  extensions,
const SdfSchemaBase schema 
)
protected

Constructor.

schema must remain valid for the lifetime of this file format.

◆ SdfFileFormat() [6/6]

SdfFileFormat ( const TfToken formatId,
const TfToken versionString,
const TfToken target,
const std::vector< std::string > &  extensions,
const SdfSchemaBase &&  schema 
)
protecteddelete

Disallow temporary SdfSchemaBase objects being passed to the c'tor.

◆ ~SdfFileFormat()

virtual SDF_API ~SdfFileFormat ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ _GetLayerData()

static SDF_API SdfAbstractDataConstPtr _GetLayerData ( const SdfLayer layer)
staticprotected

Get the internal data for layer.

◆ _InitDetachedData()

virtual SDF_API SdfAbstractDataRefPtr _InitDetachedData ( const FileFormatArguments args) const
protectedvirtual
See also
InitDetachedData

This function must return a new SdfAbstractData object that is detached, i.e. SdfAbstractData::IsDetached returns false.

The default implementation returns an SdfData object.

Reimplemented in UsdUsdFileFormat.

◆ _ReadAndCopyLayerDataToMemory()

SDF_API bool _ReadAndCopyLayerDataToMemory ( SdfLayer layer,
const std::string &  resolvedPath,
bool  metadataOnly,
bool *  didCopyData = nullptr 
) const
protected

Helper function for _ReadDetached.

Calls Read with the given parameters. If successful and layer is not detached (i.e., SdfLayer::IsDetached returns false) copies the layer data into an SdfData object and set that into layer. If this copy occurs and didCopyData is given, it will be set to true.

Note that the copying process is a simple spec-by-spec, field-by-field value copy. This process may not produce detached layers if the data object used by layer after the initial call to Read returns VtValues that are not detached. One example is a VtValue holding a VtArray backed by a foreign data source attached to a memory mapping.

Returns true if Read was successful, false otherwise.

◆ _ReadDetached()

virtual SDF_API bool _ReadDetached ( SdfLayer layer,
const std::string &  resolvedPath,
bool  metadataOnly 
) const
protectedvirtual
See also
ReadDetached

Upon completion, layer must have an SdfAbstractData object set that is detached, i.e. SdfAbstractData::IsDetached returns false.

The default implementation calls _ReadAndCopyLayerDataToMemory to read the specified layer and copy its data into an SdfData object if it is not detached. If data is copied, a warning will be issued since this may be an expensive operation. If the above behavior is desired, subclasses can just call _ReadAndCopyLayerDataToMemory to do the same thing but without the warning.

Reimplemented in UsdUsdFileFormat, and UsdUsdzFileFormat.

◆ _SetLayerData() [1/2]

static SDF_API void _SetLayerData ( SdfLayer layer,
SdfAbstractDataRefPtr &  data 
)
staticprotected

Set the internal data for layer to data, possibly transferring ownership of data.

Existing layer hints are reset to the default hints.

◆ _SetLayerData() [2/2]

static SDF_API void _SetLayerData ( SdfLayer layer,
SdfAbstractDataRefPtr &  data,
SdfLayerHints  hints 
)
staticprotected

Set the internal data for layer to data, possibly transferring ownership of data.

Existing layer hints are replaced with hints.

◆ _ShouldReadAnonymousLayers()

virtual SDF_API bool _ShouldReadAnonymousLayers ( ) const
protectedvirtual

File format subclasses may override this to specify whether Read should be called when creating, opening, or reloading an anonymous layer of this format.

Default implementation returns false.

◆ CanRead()

virtual SDF_API bool CanRead ( const std::string &  file) const
pure virtual

Returns true if file can be read by this format.

Implemented in SdfTextFileFormat, UsdUsdFileFormat, UsdUsdzFileFormat, and UsdUsdcFileFormat.

◆ FindAllDerivedFileFormatExtensions()

static SDF_API std::set< std::string > FindAllDerivedFileFormatExtensions ( const TfType baseType)
static

Returns a set containing the extension(s) corresponding to all registered file formats that derive from baseType.

baseType must derive from SdfFileFormat.

◆ FindAllFileFormatExtensions()

static SDF_API std::set< std::string > FindAllFileFormatExtensions ( )
static

Returns a set containing the extension(s) corresponding to all registered file formats.

◆ FindByExtension() [1/2]

static SDF_API SdfFileFormatConstPtr FindByExtension ( const std::string &  path,
const FileFormatArguments args 
)
static

Returns a file format instance that supports the extension for path and whose target matches one of those specified by the given args.

If the args specify no target, then the file format that is registered as the primary plugin will be returned. If a format with a matching extension is not found, this returns a null file format pointer.

◆ FindByExtension() [2/2]

static SDF_API SdfFileFormatConstPtr FindByExtension ( const std::string &  path,
const std::string &  target = std::string() 
)
static

Returns the file format instance that supports the extension for path.

If a format with a matching extension is not found, this returns a null file format pointer.

An extension may be handled by multiple file formats, but each with a different target. In such cases, if no target is specified, the file format that is registered as the primary plugin will be returned. Otherwise, the file format whose target matches target will be returned.

◆ FindById()

static SDF_API SdfFileFormatConstPtr FindById ( const TfToken formatId)
static

Returns the file format instance with the specified formatId identifier.

If a format with a matching identifier is not found, this returns a null file format pointer.

◆ FormatSupportsEditing()

static SDF_API bool FormatSupportsEditing ( const std::string &  extension,
const std::string &  target = std::string() 
)
static

Returns true if the file format for the supplied extension and target pair supports editing.

This method will not load the plugin that provides the specified file format. If the extension and target pair is invalid, this method will return false.

See also
FormatSupportsReading
FormatSupportsWriting

◆ FormatSupportsReading()

static SDF_API bool FormatSupportsReading ( const std::string &  extension,
const std::string &  target = std::string() 
)
static

Returns true if the file format for the supplied extension and target pair supports reading.

This method will not load the plugin that provides the specified file format. If the extension and target pair is invalid, this method will return false.

See also
FormatSupportsWriting
FormatSupportsEditing

◆ FormatSupportsWriting()

static SDF_API bool FormatSupportsWriting ( const std::string &  extension,
const std::string &  target = std::string() 
)
static

Returns true if the file format for the supplied extension and target pair supports writing.

This method will not load the plugin that provides the specified file format. If the extension and target pair is invalid, this method will return false.

See also
FormatSupportsReading
FormatSupportsEditing

◆ GetDefaultFileFormatArguments()

virtual SDF_API FileFormatArguments GetDefaultFileFormatArguments ( ) const
virtual

Returns the FileFormatArguments that correspond to the default behavior of this file format when no FileFormatArguments are passed to NewLayer or InitData.

◆ GetExternalAssetDependencies()

virtual SDF_API std::set< std::string > GetExternalAssetDependencies ( const SdfLayer layer) const
virtual

Returns the set of resolved paths to external asset file dependencies for the given layer.

These are additional dependencies, specific to the file format, that are needed when generating the layer's contents and would not otherwise be discoverable through composition dependencies (i.e. sublayers, references, and payloads).

The default implementation returns an empty set. Derived file formats that depend on external assets to read and generate layer content should implement this function to return the external asset paths.

See also
SdfLayer::GetExternalAssetDependencies
SdfLayer::Reload

◆ GetFileCookie()

SDF_API const std::string & GetFileCookie ( ) const

Returns the cookie to be used when writing files with this format.

◆ GetFileExtension()

static SDF_API std::string GetFileExtension ( const std::string &  s)
static

Returns the file extension for path or file name s, without the leading dot character.

◆ GetFileExtensions()

SDF_API const std::vector< std::string > & GetFileExtensions ( ) const

Returns a list of extensions that this format supports.

◆ GetFormatId()

SDF_API const TfToken & GetFormatId ( ) const

Returns the format identifier.

◆ GetPackageRootLayerPath()

virtual SDF_API std::string GetPackageRootLayerPath ( const std::string &  resolvedPath) const
virtual

Returns the path of the "root" layer contained in the package layer at resolvedPath produced by this file format.

If this file format is not a package, returns the empty string.

The package root layer is the layer in the package layer that is used when that package is opened via SdfLayer.

Reimplemented in UsdUsdzFileFormat.

◆ GetPrimaryFileExtension()

SDF_API const std::string & GetPrimaryFileExtension ( ) const

Returns the primary file extension for this format.

This is the extension that is reported for layers using this file format.

◆ GetSchema()

SDF_API const SdfSchemaBase & GetSchema ( ) const

Returns the schema for this format.

◆ GetTarget()

SDF_API const TfToken & GetTarget ( ) const

Returns the target for this file format.

◆ GetVersionString()

SDF_API const TfToken & GetVersionString ( ) const

Returns the current version of this file format.

◆ InitData()

virtual SDF_API SdfAbstractDataRefPtr InitData ( const FileFormatArguments args) const
virtual

This method allows the file format to bind to whatever data container is appropriate.

Returns a shared pointer to an SdfAbstractData implementation.

Reimplemented in UsdUsdcFileFormat, UsdUsdFileFormat, and UsdUsdzFileFormat.

◆ InitDetachedData()

SDF_API SdfAbstractDataRefPtr InitDetachedData ( const FileFormatArguments args) const

Returns a new SdfAbstractData providing access to the layer's data.

This data object is detached from any underlying storage.

◆ IsPackage()

virtual SDF_API bool IsPackage ( ) const
virtual

Returns true if this file format is a package containing other assets.

Reimplemented in UsdUsdzFileFormat.

◆ IsPrimaryFormatForExtensions()

SDF_API bool IsPrimaryFormatForExtensions ( ) const

Returns true if this file format is the primary format for the extensions it handles.

◆ IsSupportedExtension()

SDF_API bool IsSupportedExtension ( const std::string &  extension) const

Returns true if extension matches one of the extensions returned by GetFileExtensions.

◆ NewLayer()

SDF_API SdfLayerRefPtr NewLayer ( const SdfFileFormatConstPtr &  fileFormat,
const std::string &  identifier,
const std::string &  realPath,
const ArAssetInfo assetInfo,
const FileFormatArguments args 
) const

Instantiate a layer.

◆ Read()

virtual SDF_API bool Read ( SdfLayer layer,
const std::string &  resolvedPath,
bool  metadataOnly 
) const
pure virtual

Reads scene description from the asset specified by resolvedPath into the layer layer.

metadataOnly is a flag that asks for only the layer metadata to be read in, which can be much faster if that is all that is required. Note that this is just a hint: some FileFormat readers may disregard this flag and still fully populate the layer contents.

Returns true if the asset is successfully read into layer, false otherwise.

Implemented in SdfTextFileFormat, UsdUsdFileFormat, UsdUsdzFileFormat, and UsdUsdcFileFormat.

◆ ReadDetached()

SDF_API bool ReadDetached ( SdfLayer layer,
const std::string &  resolvedPath,
bool  metadataOnly 
) const

Reads scene description from the asset specified by resolvedPath into the detached layer layer.

After reading is completed, layer must be detached from any underlying storage.

metadataOnly is a flag that asks for only the layer metadata to be read in, which can be much faster if that is all that is required. Note that this is just a hint: some FileFormat readers may disregard this flag and still fully populate the layer contents.

Returns true if the asset is successfully read into layer, false if the the asset could not be read or if the resulting layer is not detached.

◆ ReadFromString()

virtual SDF_API bool ReadFromString ( SdfLayer layer,
const std::string &  str 
) const
virtual

Reads data in the string str into the layer layer.

If the file is successfully read, this method returns true. Otherwise, false is returned and errors are posted.

Reimplemented in SdfTextFileFormat, UsdUsdFileFormat, UsdUsdzFileFormat, and UsdUsdcFileFormat.

◆ SaveToFile()

virtual SDF_API bool SaveToFile ( const SdfLayer layer,
const std::string &  filePath,
const std::string &  comment = std::string(),
const FileFormatArguments args = FileFormatArguments() 
) const
virtual

Write the content in layer to the file at filePath, which is the backing store for layer itself.

If the content is successfully written, this method returns true. Otherwise, false is returned and errors are posted. The default implementation just calls WriteToFile() passing all the same arguments.

The purpose of this member function is to provide a distinction between a "Save" operation that updates the backing store for the layer itself and an "Export" operation that writes the layer data to a distinct asset. File formats that retain all data in memory can typically override only WriteToFile(), but formats that do not may need to take different action on "Save" vs "Export".

Reimplemented in UsdUsdFileFormat, and UsdUsdcFileFormat.

◆ ShouldReadAnonymousLayers()

SDF_API bool ShouldReadAnonymousLayers ( ) const

Returns true if anonymous layer identifiers should be passed to Read when a layer is opened or reloaded.

Anonymous layers will not have an asset backing and thus for most file formats there is nothing that can be read for an anonymous layer. However, there are file formats that use Read to generate dynamic layer content without reading any data from the resolved asset associated with the layer's identifier.

For these types of file formats it is useful to be able to open anonymous layers and allow Read to populate them to avoid requiring a placeholder asset to exist just so Read can populate the layer.

◆ ShouldSkipAnonymousReload()

SDF_API bool ShouldSkipAnonymousReload ( ) const

Return true if this file format prefers to skip reloading anonymous layers.

◆ SupportsEditing()

SDF_API bool SupportsEditing ( ) const

This is a convenience method for invoking FormatSupportsEditing with this format's extension and target.

◆ SupportsReading()

SDF_API bool SupportsReading ( ) const

Returns true if this file format supports reading.

This is a convenience method for invoking FormatSupportsReading with this format's extension and target

◆ SupportsWriting()

SDF_API bool SupportsWriting ( ) const

This is a convenience method for invoking FormatSupportsWriting with this format's extension and target.

◆ WriteToFile()

virtual SDF_API bool WriteToFile ( const SdfLayer layer,
const std::string &  filePath,
const std::string &  comment = std::string(),
const FileFormatArguments args = FileFormatArguments() 
) const
virtual

Writes the content in layer into the file at filePath.

If the content is successfully written, this method returns true. Otherwise, false is returned and errors are posted. The default implementation returns false.

This member function makes no distinction between a "Save" operation that updates the backing store for the layer itself and an "Export" operation that writes the layer data to a distinct asset. For file formats that retain all data in memory this is typically fine. But for file formats that handle data requests by reading from the backing store, this distinction can be important. In that case, additionally override the member function SaveToFile() to take different action.

Reimplemented in SdfTextFileFormat, UsdUsdFileFormat, UsdUsdzFileFormat, and UsdUsdcFileFormat.

◆ WriteToStream()

virtual SDF_API bool WriteToStream ( const SdfSpecHandle &  spec,
std::ostream &  out,
size_t  indent 
) const
virtual

Write the provided spec to out indented indent levels.

Reimplemented in SdfTextFileFormat, UsdUsdcFileFormat, UsdUsdFileFormat, and UsdUsdzFileFormat.

◆ WriteToString()

virtual SDF_API bool WriteToString ( const SdfLayer layer,
std::string *  str,
const std::string &  comment = std::string() 
) const
virtual

Writes the content in layer to the string str.

This function should write a textual representation of layer to the stream that can be read back in via ReadFromString.

Reimplemented in SdfTextFileFormat, UsdUsdFileFormat, UsdUsdzFileFormat, and UsdUsdcFileFormat.


The documentation for this class was generated from the following file: