SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SDL::Storage Struct Reference

Handle to an owned storage. More...

Inheritance diagram for SDL::Storage:
Inheritance graph
[legend]

Public Member Functions

void Close ()
 Closes and frees a storage container.
 
StorageShared share ()
 Move this storage into a StorageShared.
 
constexpr ResourceUnique (std::nullptr_t=nullptr)
 Default constructor.
 
constexpr ResourceUnique (base::value_type value, DELETER deleter={})
 Constructs from raw type.
 
constexpr ResourceUnique (ResourceUnique &&other)
 Move constructor.
 
 ResourceUnique (const ResourceUnique &other)=delete
 
- Public Member Functions inherited from SDL::ResourceUnique< StorageRef >
constexpr ResourceUnique (std::nullptr_t=nullptr)
 Default constructor.
 
constexpr ResourceUnique (base::value_type value, DefaultDeleter< StorageRef > deleter={})
 Constructs from raw type.
 
constexpr ResourceUnique (ResourceUnique &&other)
 Move constructor.
 
 ResourceUnique (const ResourceUnique &other)=delete
 
 ~ResourceUnique ()
 Destructor.
 
constexpr ResourceUniqueoperator= (ResourceUnique other)
 Assignment operator.
 
void reset ()
 Resets the value, destroying the resource if not nullptr.
 
- Public Member Functions inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
RESOURCE release ()
 Returns reference and reset this.
 
- Public Member Functions inherited from SDL::ResourcePtrBase< RESOURCE >
constexpr operator bool () const
 Check if not null.
 
constexpr bool operator== (const ResourcePtrBase &other) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr reference operator* () const
 Gets reference.
 
constexpr const referenceoperator-> () const
 Gets addressable reference.
 
constexpr referenceoperator-> ()
 Gets addressable reference.
 
reference get () const
 Get reference.
 

Static Public Member Functions

static Storage OpenTitle (StringParam override, PropertiesRef props)
 Opens up a read-only container for the application's filesystem.
 
static Storage OpenUser (StringParam org, StringParam app, PropertiesRef props)
 Opens up a container for a user's unique read/write filesystem.
 
static Storage OpenFile (StringParam path)
 Opens up a container for local filesystem storage.
 
static Storage Open (const StorageInterface &iface, void *userdata)
 Opens up a container using a client-provided storage interface.
 

Additional Inherited Members

- Public Types inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
using deleter = DELETER
 The deleter type.
 
- Public Types inherited from SDL::ResourcePtrBase< RESOURCE >
using reference = RESOURCE
 The reference resource type.
 
using value_type = typename reference::value_type
 The raw resource type.
 
- Protected Member Functions inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
constexpr ResourceOwnerBase (base::value_type value={}, DELETER deleter={})
 Constructs from raw type.
 
void free ()
 Frees resource.
 
- Protected Member Functions inherited from SDL::ResourcePtrBase< RESOURCE >
constexpr ResourcePtrBase (value_type value={})
 Constructs from raw type.
 
referenceget ()
 Get reference.
 

Detailed Description

Category:
Resource
See also
StorageRef

Member Function Documentation

◆ Close()

void SDL::Storage::Close ( )
inline
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
Storage.OpenFile
Storage.Open
Storage.OpenTitle
Storage.OpenUser

◆ Open()

static Storage SDL::Storage::Open ( const StorageInterface iface,
void *  userdata 
)
inlinestatic

Applications do not need to use this function unless they are providing their own StorageRef implementation. If you just need an StorageRef, you should use the built-in implementations in SDL, like Storage.OpenTitle() or Storage.OpenUser().

This function makes a copy of iface and the caller does not need to keep it around after this call.

Parameters
ifacethe interface that implements this storage, initialized using SDL_INIT_INTERFACE().
userdatathe pointer that will be passed to the interface functions.
Returns
a storage container on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
Storage.Close
StorageRef.GetFileSize
StorageRef.GetSpaceRemaining
SDL_INIT_INTERFACE
StorageRef.ReadFile
StorageRef.Ready
StorageRef.WriteFile

◆ OpenFile()

static Storage SDL::Storage::OpenFile ( StringParam  path)
inlinestatic

This is provided for development and tools. Portable applications should use Storage.OpenTitle() for access to game data and Storage.OpenUser() for access to user data.

Parameters
paththe base path prepended to all storage paths, or nullptr for no base path.
Returns
a filesystem storage container on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
Storage.Close
StorageRef.GetFileSize
StorageRef.GetSpaceRemaining
Storage.OpenTitle
Storage.OpenUser
StorageRef.ReadFile
StorageRef.WriteFile

◆ OpenTitle()

static Storage SDL::Storage::OpenTitle ( StringParam  override,
PropertiesRef  props 
)
inlinestatic
Parameters
overridea path to override the backend's default title root.
propsa property list that may contain backend-specific information.
Returns
a title storage container on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
Storage.Close
StorageRef.GetFileSize
Storage.OpenUser
StorageRef.ReadFile

◆ OpenUser()

static Storage SDL::Storage::OpenUser ( StringParam  org,
StringParam  app,
PropertiesRef  props 
)
inlinestatic

While title storage can generally be kept open throughout runtime, user storage should only be opened when the client is ready to read/write files. This allows the backend to properly batch file operations and flush them when the container has been closed; ensuring safe and optimal save I/O.

Parameters
orgthe name of your organization.
appthe name of your application.
propsa property list that may contain backend-specific information.
Returns
a user storage container on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
Storage.Close
StorageRef.GetFileSize
StorageRef.GetSpaceRemaining
Storage.OpenTitle
StorageRef.ReadFile
StorageRef.Ready
StorageRef.WriteFile

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