logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SDL_IOStreamInterface - The function pointers that drive an SDL_IOStream .

Availability

       This struct is available since SDL 3.2.0.

Description

       Applications  can provide this struct to SDL_OpenIO () to create their own implementation of SDL_IOStream
       . This is not necessarily required, as SDL already offers  several  common  types  of  I/O  streams,  via
       functions like SDL_IOFromFile () and

       SDL_IOFromMem ().

       This structure should be initialized using

       SDL_INIT_INTERFACE ()

Header File

       Defined in SDL3/SDL_iostream.h

Name

       SDL_IOStreamInterface - The function pointers that drive an SDL_IOStream .

See Also

(3), SDL_INIT_INTERFACE(3)

Simple Directmedia Layer                           SDL 3.2.10                       SDL_IOStreamInterface(3type)

Synopsis

#include"SDL3/SDL.h"typedefstructSDL_IOStreamInterface{/*Theversionofthisinterface*/Uint32version;/***ReturnthenumberofbytesinthisSDL_IOStream*eturnthetotalsizeofthedatastream,or-1onerror.**/Sint64(SDLCALL*size)(void*userdata);/***Seekto`offset`relativeto`whence`,oneofstdio'swhencevalues:*SDL_IO_SEEK_SET,SDL_IO_SEEK_CUR,SDL_IO_SEEK_END*eturnthefinaloffsetinthedatastream,or-1onerror.**/Sint64(SDLCALL*seek)(void*userdata,Sint64offset,SDL_IOWhencewhence);/***Readupto`size`bytesfromthedatastreamtotheareapointed*atby`ptr`.**Onanincompleteread,youshouldset`*status`toavaluefromthe*SDL_IOStatusenum.Youdonothavetoexplicitlysetthison*acomplete,successfulread.*eturnthenumberofbytesread**/size_t(SDLCALL*read)(void*userdata,void*ptr,size_tsize,SDL_IOStatus*status);/***Writeexactly`size`bytesfromtheareapointedatby`ptr`*todatastream.**Onanincompletewrite,youshouldset`*status`toavaluefromthe*SDL_IOStatusenum.Youdonothavetoexplicitlysetthison*acomplete,successfulwrite.*eturnthenumberofbyteswritten**/size_t(SDLCALL*write)(void*userdata,constvoid*ptr,size_tsize,SDL_IOStatus*status);/***Ifthestreamisbuffering,makesurethedataiswrittenout.**Onfailure,youshouldset`*status`toavaluefromthe*SDL_IOStatusenum.Youdonothavetoexplicitlysetthison*asuccessfulflush.*eturntrueifsuccessfulorfalseonwriteerrorwhenflushingdata.**/bool(SDLCALL*flush)(void*userdata,SDL_IOStatus*status);/***Closeandfreeanyallocatedresources.**Thisdoesnotguaranteefilewriteswillsynctophysicalmedia;they*canbeinthesystem'sfilecache,waitingtogotodisk.**TheSDL_IOStreamisstilldestroyedevenifthisfails,socleanupanything*evenifflushingbuffers,etc,returnsanerror.*eturntrueifsuccessfulorfalseonwriteerrorwhenflushingdata.**/bool(SDLCALL*close)(void*userdata);}SDL_IOStreamInterface;

See Also