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

Handle to a non owned storage. More...

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

Public Member Functions

constexpr StorageRef (const StorageRef &other)
 Copy constructor.
 
constexpr StorageRef (StorageRef &&other)
 Move constructor.
 
constexpr ~StorageRef ()=default
 Default constructor.
 
StorageRefoperator= (StorageRef other)
 Assignment operator.
 
bool reset (SDL_Storage *newResource={})
 Closes and frees a storage container.
 
bool Close ()
 Closes and frees a storage container.
 
 StorageBase (StringParam override, PropertiesBase &props)
 Opens up a read-only container for the application's filesystem.
 
 StorageBase (StringParam org, StringParam app, PropertiesBase &props)
 Opens up a container for a user's unique read/write filesystem.
 
 StorageBase (StringParam path)
 Opens up a container for local filesystem storage.
 
 StorageBase (const StorageInterface &iface, void *userdata)
 Opens up a container using a client-provided storage interface.
 
- Public Member Functions inherited from SDL::StorageBase
 StorageBase (StringParam override, PropertiesBase &props)
 Opens up a read-only container for the application's filesystem.
 
 StorageBase (StringParam org, StringParam app, PropertiesBase &props)
 Opens up a container for a user's unique read/write filesystem.
 
 StorageBase (StringParam path)
 Opens up a container for local filesystem storage.
 
 StorageBase (const StorageInterface &iface, void *userdata)
 Opens up a container using a client-provided storage interface.
 
bool Ready () const
 Checks if the storage container is ready to use.
 
std::optional< Uint64 > GetFileSize (StringParam path) const
 Query the size of a file within a storage container.
 
std::string ReadFile (StringParam path) const
 Synchronously read a file from a storage container into a client-provided buffer.
 
bool ReadFile (StringParam path, TargetBytes destination) const
 Synchronously read a file from a storage container into a client-provided buffer.
 
template<class T >
std::vector< T > ReadFileAs (StringParam path) const
 Synchronously read a file from a storage container into a client-provided buffer.
 
void WriteFile (StringParam path, SourceBytes source)
 Synchronously write a file from client memory into a storage container.
 
void CreateDirectory (StringParam path)
 Create a directory in a writable storage container.
 
std::vector< PathEnumerateDirectory (StringParam path)
 Enumerate a directory.
 
void EnumerateDirectory (StringParam path, EnumerateDirectoryCB callback)
 Enumerate a directory in a storage container through a callback function.
 
void EnumerateDirectory (StringParam path, EnumerateDirectoryCallback callback, void *userdata)
 Enumerate a directory in a storage container through a callback function.
 
void RemovePath (StringParam path)
 Remove a file or an empty directory in a writable storage container.
 
void RenamePath (StringParam oldpath, StringParam newpath)
 Rename a file or directory in a writable storage container.
 
void CopyFile (StringParam oldpath, StringParam newpath)
 Copy a file in a writable storage container.
 
PathInfo GetPathInfo (StringParam path) const
 Get information about a filesystem path in a storage container.
 
Uint64 GetSpaceRemaining () const
 Queries the remaining space in a storage container.
 
OwnArray< char * > GlobDirectory (StringParam path, StringParam pattern, GlobFlags flags)
 Enumerate a directory tree, filtered by pattern, and return a list.
 
constexpr Resource (T resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
- Public Member Functions inherited from SDL::Resource< SDL_Storage * >
constexpr Resource (SDL_Storage * resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
Resourceoperator= (const Resource &other)=delete
 
Resourceoperator= (Resource &&other)=delete
 
constexpr operator bool () const
 True if contains a valid resource.
 
constexpr bool operator== (const Resource &other) const=default
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr SDL_Storage * get () const
 Return contained resource;.
 
constexpr SDL_Storage * release (SDL_Storage * newResource={})
 Return contained resource and empties or replace value.
 
constexpr const SDL_Storage * operator-> () const
 Access to fields.
 
constexpr SDL_Storage * operator-> ()
 Access to fields.
 

Detailed Description

Category:
Resource
See also
StorageBase
Storage

Member Function Documentation

◆ Close()

bool SDL::StorageRef::Close ( )
inline
Returns
true if the container was freed with no errors, false otherwise; call GetError() for more information. Even if the function returns an error, the container data will be freed; the error is only for informational purposes.
Since
This function is available since SDL 3.2.0.
See also
StorageBase.StorageBase

◆ reset()

bool SDL::StorageRef::reset ( SDL_Storage *  newResource = {})
inline
Returns
true if the container was freed with no errors, false otherwise; call GetError() for more information. Even if the function returns an error, the container data will be freed; the error is only for informational purposes.
Since
This function is available since SDL 3.2.0.
See also
StorageBase.StorageBase
StorageBase.StorageBase
StorageBase.StorageBase
StorageBase.StorageBase

◆ StorageBase() [1/4]

SDL::StorageBase::StorageBase ( const StorageInterface iface,
void *  userdata 
)
inline

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

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.
Postcondition
a storage container on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
StorageBase.GetFileSize
StorageBase.GetSpaceRemaining
SDL_INIT_INTERFACE
StorageBase.ReadFile
StorageBase.Ready
StorageBase.WriteFile

◆ StorageBase() [2/4]

SDL::StorageBase::StorageBase ( StringParam  org,
StringParam  app,
PropertiesBase props 
)
inline

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.
Postcondition
a user storage container on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
StorageBase.GetFileSize
StorageBase.GetSpaceRemaining
StorageBase.StorageBase
StorageBase.ReadFile
StorageBase.Ready
StorageBase.WriteFile

◆ StorageBase() [3/4]

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

◆ StorageBase() [4/4]

SDL::StorageBase::StorageBase ( StringParam  path)
inline

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

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

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