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

Semi-safe reference for AsyncIO.

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

Public Member Functions

 AsyncIORef (AsyncIOParam resource) noexcept
 Constructs from AsyncIOParam. More...
 
 AsyncIORef (AsyncIORaw resource) noexcept
 Constructs from AsyncIOParam. More...
 
constexpr AsyncIORef (const AsyncIORef &other) noexcept=default
 Copy constructor.
 
 ~AsyncIORef ()
 Destructor.
 
constexpr AsyncIO (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr AsyncIO (const AsyncIORaw resource) noexcept
 Constructs from AsyncIOParam. More...
 
constexpr AsyncIO (const AsyncIO &other) noexcept=default
 Copy constructor.
 
constexpr AsyncIO (AsyncIO &&other) noexcept
 Move constructor.
 
constexpr AsyncIO (const AsyncIORef &other)=delete
 
constexpr AsyncIO (AsyncIORef &&other)=delete
 
 AsyncIO (StringParam file, StringParam mode)
 Use this function to create a new AsyncIO object for reading from and/or writing to a named file. More...
 
- Public Member Functions inherited from SDL::AsyncIO
constexpr AsyncIO (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr AsyncIO (const AsyncIORaw resource) noexcept
 Constructs from AsyncIOParam. More...
 
constexpr AsyncIO (AsyncIO &&other) noexcept
 Move constructor.
 
constexpr AsyncIO (const AsyncIORef &other)=delete
 
constexpr AsyncIO (AsyncIORef &&other)=delete
 
 AsyncIO (StringParam file, StringParam mode)
 Use this function to create a new AsyncIO object for reading from and/or writing to a named file. More...
 
 ~AsyncIO ()
 Destructor.
 
constexpr AsyncIOoperator= (AsyncIO &&other) noexcept
 Assignment operator.
 
constexpr AsyncIORaw get () const noexcept
 Retrieves underlying AsyncIORaw.
 
constexpr AsyncIORaw release () noexcept
 Retrieves underlying AsyncIORaw and clear this.
 
constexpr auto operator<=> (const AsyncIO &other) const noexcept=default
 Comparison.
 
constexpr operator bool () const noexcept
 Converts to bool.
 
constexpr operator AsyncIOParam () const noexcept
 Converts to AsyncIOParam.
 
bool Close (bool flush, AsyncIOQueueParam queue, void *userdata)
 Close and free any allocated resources for an async I/O object. More...
 
Sint64 GetSize ()
 Use this function to get the size of the data stream in an AsyncIO. More...
 
void Read (void *ptr, Uint64 offset, Uint64 size, AsyncIOQueueParam queue, void *userdata)
 Start an async read. More...
 
void Write (void *ptr, Uint64 offset, Uint64 size, AsyncIOQueueParam queue, void *userdata)
 Start an async write. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SDL::AsyncIO
constexpr AsyncIO (const AsyncIO &other) noexcept=default
 Copy constructor.
 
constexpr AsyncIOoperator= (const AsyncIO &other) noexcept=default
 Assignment operator.
 

Constructor & Destructor Documentation

◆ AsyncIORef() [1/2]

SDL::AsyncIORef::AsyncIORef ( AsyncIOParam  resource)
inlinenoexcept
Parameters
resourcea AsyncIORaw or AsyncIO.

This does not takes ownership!

◆ AsyncIORef() [2/2]

SDL::AsyncIORef::AsyncIORef ( AsyncIORaw  resource)
inlinenoexcept
Parameters
resourcea AsyncIORaw or AsyncIO.

This does not takes ownership!

Member Function Documentation

◆ AsyncIO() [1/2]

constexpr SDL::AsyncIO::AsyncIO ( const AsyncIORaw  resource)
inlineexplicitconstexprnoexcept
Parameters
resourcea AsyncIORaw to be wrapped.

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

◆ AsyncIO() [2/2]

SDL::AsyncIO::AsyncIO ( StringParam  file,
StringParam  mode 
)
inline

The mode string understands the following values:

  • "r": Open a file for reading only. It must exist.
  • "w": Open a file for writing only. It will create missing files or truncate existing ones.
  • "r+": Open a file for update both reading and writing. The file must exist.
  • "w+": Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.

There is no "b" mode, as there is only "binary" style I/O, and no "a" mode for appending, since you specify the position when starting a task.

This function supports Unicode filenames, but they must be encoded in UTF-8 format, regardless of the underlying operating system.

This call is not asynchronous; it will open the file before returning, under the assumption that doing so is generally a fast operation. Future reads and writes to the opened file will be async, however.

Parameters
filea UTF-8 string representing the filename to open.
modean ASCII string representing the mode to be used for opening the file.
Postcondition
a pointer to the AsyncIO structure that is created or nullptr on failure; call GetError() for more information.
Since
This function is available since SDL 3.2.0.
See also
AsyncIO.Close
AsyncIO.Read
AsyncIO.Write

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