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

Semi-safe reference for Storage.

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

Public Member Functions

 StorageRef (StorageParam resource) noexcept
 Constructs from StorageParam. More...
 
 StorageRef (StorageRaw resource) noexcept
 Constructs from StorageParam. More...
 
 StorageRef (const StorageRef &other) noexcept
 Copy constructor.
 
 ~StorageRef ()
 Destructor.
 
constexpr Storage (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr Storage (const StorageRaw resource) noexcept
 Constructs from StorageParam. More...
 
constexpr Storage (const Storage &other)=delete
 Copy constructor.
 
constexpr Storage (Storage &&other) noexcept
 Move constructor.
 
constexpr Storage (const StorageRef &other)=delete
 
constexpr Storage (StorageRef &&other)=delete
 
 Storage (StringParam override, PropertiesParam props)
 Opens up a read-only container for the application's filesystem. More...
 
 Storage (StringParam org, StringParam app, PropertiesParam props)
 Opens up a container for a user's unique read/write filesystem. More...
 
 Storage (StringParam path)
 Opens up a container for local filesystem storage. More...
 
 Storage (const StorageInterface &iface, void *userdata)
 Opens up a container using a client-provided storage interface. More...
 
- Public Member Functions inherited from SDL::Storage
constexpr Storage (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr Storage (const StorageRaw resource) noexcept
 Constructs from StorageParam. More...
 
constexpr Storage (const Storage &other)=delete
 Copy constructor.
 
constexpr Storage (Storage &&other) noexcept
 Move constructor.
 
constexpr Storage (const StorageRef &other)=delete
 
constexpr Storage (StorageRef &&other)=delete
 
 Storage (StringParam override, PropertiesParam props)
 Opens up a read-only container for the application's filesystem. More...
 
 Storage (StringParam org, StringParam app, PropertiesParam props)
 Opens up a container for a user's unique read/write filesystem. More...
 
 Storage (StringParam path)
 Opens up a container for local filesystem storage. More...
 
 Storage (const StorageInterface &iface, void *userdata)
 Opens up a container using a client-provided storage interface. More...
 
 ~Storage ()
 Destructor.
 
constexpr Storageoperator= (Storage &&other) noexcept
 Assignment operator.
 
constexpr StorageRaw get () const noexcept
 Retrieves underlying StorageRaw.
 
constexpr StorageRaw release () noexcept
 Retrieves underlying StorageRaw and clear this.
 
constexpr auto operator<=> (const Storage &other) const noexcept=default
 Comparison.
 
constexpr operator bool () const noexcept
 Converts to bool.
 
constexpr operator StorageParam () const noexcept
 Converts to StorageParam.
 
bool Close ()
 Closes and frees a storage container. More...
 
bool Ready ()
 Checks if the storage container is ready to use. More...
 
std::optional< Uint64GetFileSize (StringParam path)
 Query the size of a file within a storage container. More...
 
bool ReadFile (StringParam path, TargetBytes destination)
 Synchronously read a file from a storage container into a client-provided buffer. More...
 
std::string ReadFile (StringParam path)
 Synchronously read a file from a storage container into a client-provided buffer. More...
 
template<class T >
std::vector< T > ReadFileAs (StringParam path)
 Synchronously read a file from a storage container into a client-provided buffer. More...
 
void WriteFile (StringParam path, SourceBytes source)
 Synchronously write a file from client memory into a storage container. More...
 
void CreateDirectory (StringParam path)
 Create a directory in a writable storage container. More...
 
void EnumerateDirectory (StringParam path, EnumerateDirectoryCallback callback, void *userdata)
 Enumerate a directory in a storage container through a callback function. More...
 
std::vector< PathEnumerateDirectory (StringParam path)
 Enumerate a directory in a storage container through a callback function. More...
 
void EnumerateDirectory (StringParam path, EnumerateDirectoryCB callback)
 Enumerate a directory in a storage container through a callback function. More...
 
void RemovePath (StringParam path)
 Remove a file or an empty directory in a writable storage container. More...
 
void RenamePath (StringParam oldpath, StringParam newpath)
 Rename a file or directory in a writable storage container. More...
 
void CopyFile (StringParam oldpath, StringParam newpath)
 Copy a file in a writable storage container. More...
 
PathInfo GetPathInfo (StringParam path)
 Get information about a filesystem path in a storage container. More...
 
Uint64 GetSpaceRemaining ()
 Queries the remaining space in a storage container. More...
 
OwnArray< char * > GlobDirectory (StringParam path, StringParam pattern, GlobFlags flags)
 Enumerate a directory tree, filtered by pattern, and return a list. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SDL::Storage
constexpr Storageoperator= (const Storage &other) noexcept=default
 Assignment operator.
 

Constructor & Destructor Documentation

◆ StorageRef() [1/2]

SDL::StorageRef::StorageRef ( StorageParam  resource)
inlinenoexcept
Parameters
resourcea StorageRaw or Storage.

This does not takes ownership!

◆ StorageRef() [2/2]

SDL::StorageRef::StorageRef ( StorageRaw  resource)
inlinenoexcept
Parameters
resourcea StorageRaw or Storage.

This does not takes ownership!

Member Function Documentation

◆ Storage() [1/5]

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

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

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 InitInterface().
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
Storage.Close
Storage.GetFileSize
Storage.GetSpaceRemaining
InitInterface
Storage.ReadFile
Storage.Ready
Storage.WriteFile

◆ Storage() [2/5]

constexpr SDL::Storage::Storage ( const StorageRaw  resource)
inlineexplicitconstexprnoexcept
Parameters
resourcea StorageRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

◆ Storage() [3/5]

SDL::Storage::Storage ( StringParam  org,
StringParam  app,
PropertiesParam  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
Storage.Close
Storage.GetFileSize
Storage.GetSpaceRemaining
Storage.Storage
Storage.ReadFile
Storage.Ready
Storage.WriteFile

◆ Storage() [4/5]

SDL::Storage::Storage ( StringParam  override,
PropertiesParam  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
Storage.Close
Storage.GetFileSize
Storage.Storage
Storage.ReadFile

◆ Storage() [5/5]

SDL::Storage::Storage ( StringParam  path)
inline

This is provided for development and tools. Portable applications should use Storage.Storage() for access to game data and Storage.Storage() 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
Storage.Close
Storage.GetFileSize
Storage.GetSpaceRemaining
Storage.Storage
Storage.Storage
Storage.ReadFile
Storage.WriteFile

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