Backlog/lib/sdl3/v2/iostream.zig

211 lines
6.4 KiB
Zig

const std = @import("std");
pub const c = @import("c.zig").c;
pub const PropertiesID = u32;
pub const IOStreamInterface = extern struct {
version: u32,
size: ?*const anyopaque,
seek: ?*const anyopaque,
read: ?*const anyopaque,
write: ?*const anyopaque,
flush: ?*const anyopaque,
close: ?*const anyopaque,
};
pub const IOStream = opaque {
pub inline fn closeIO(iostream: *IOStream) bool {
return c.SDL_CloseIO(iostream);
}
pub inline fn getIOProperties(iostream: *IOStream) PropertiesID {
return c.SDL_GetIOProperties(iostream);
}
pub inline fn getIOStatus(iostream: *IOStream) IOStatus {
return c.SDL_GetIOStatus(iostream);
}
pub inline fn getIOSize(iostream: *IOStream) i64 {
return c.SDL_GetIOSize(iostream);
}
pub inline fn seekIO(iostream: *IOStream, offset: i64, whence: IOWhence) i64 {
return c.SDL_SeekIO(iostream, offset, whence);
}
pub inline fn tellIO(iostream: *IOStream) i64 {
return c.SDL_TellIO(iostream);
}
pub inline fn readIO(iostream: *IOStream, ptr: ?*anyopaque, size: usize) usize {
return c.SDL_ReadIO(iostream, ptr, size);
}
pub inline fn writeIO(iostream: *IOStream, ptr: ?*const anyopaque, size: usize) usize {
return c.SDL_WriteIO(iostream, ptr, size);
}
pub inline fn iOprintf(iostream: *IOStream, fmt: [*c]const u8, ...) usize {
return c.SDL_IOprintf(iostream, fmt, );
}
pub inline fn iOvprintf(iostream: *IOStream, fmt: [*c]const u8, ap: std.builtin.VaList) usize {
return c.SDL_IOvprintf(iostream, fmt, ap);
}
pub inline fn flushIO(iostream: *IOStream) bool {
return c.SDL_FlushIO(iostream);
}
pub inline fn loadFile_IO(iostream: *IOStream, datasize: *usize, closeio: bool) ?*anyopaque {
return c.SDL_LoadFile_IO(iostream, @ptrCast(datasize), closeio);
}
pub inline fn saveFile_IO(iostream: *IOStream, data: ?*const anyopaque, datasize: usize, closeio: bool,) bool {
return c.SDL_SaveFile_IO(iostream, data, datasize, closeio);
}
pub inline fn readU8(iostream: *IOStream, value: [*c]u8) bool {
return c.SDL_ReadU8(iostream, value);
}
pub inline fn readS8(iostream: *IOStream, value: Sint8 *) bool {
return c.SDL_ReadS8(iostream, value);
}
pub inline fn readU16LE(iostream: *IOStream, value: Uint16 *) bool {
return c.SDL_ReadU16LE(iostream, value);
}
pub inline fn readS16LE(iostream: *IOStream, value: Sint16 *) bool {
return c.SDL_ReadS16LE(iostream, value);
}
pub inline fn readU16BE(iostream: *IOStream, value: Uint16 *) bool {
return c.SDL_ReadU16BE(iostream, value);
}
pub inline fn readS16BE(iostream: *IOStream, value: Sint16 *) bool {
return c.SDL_ReadS16BE(iostream, value);
}
pub inline fn readU32LE(iostream: *IOStream, value: *u32) bool {
return c.SDL_ReadU32LE(iostream, @ptrCast(value));
}
pub inline fn readS32LE(iostream: *IOStream, value: *i32) bool {
return c.SDL_ReadS32LE(iostream, @ptrCast(value));
}
pub inline fn readU32BE(iostream: *IOStream, value: *u32) bool {
return c.SDL_ReadU32BE(iostream, @ptrCast(value));
}
pub inline fn readS32BE(iostream: *IOStream, value: *i32) bool {
return c.SDL_ReadS32BE(iostream, @ptrCast(value));
}
pub inline fn readU64LE(iostream: *IOStream, value: *u64) bool {
return c.SDL_ReadU64LE(iostream, @ptrCast(value));
}
pub inline fn readS64LE(iostream: *IOStream, value: Sint64 *) bool {
return c.SDL_ReadS64LE(iostream, value);
}
pub inline fn readU64BE(iostream: *IOStream, value: *u64) bool {
return c.SDL_ReadU64BE(iostream, @ptrCast(value));
}
pub inline fn readS64BE(iostream: *IOStream, value: Sint64 *) bool {
return c.SDL_ReadS64BE(iostream, value);
}
pub inline fn writeU8(iostream: *IOStream, value: u8) bool {
return c.SDL_WriteU8(iostream, value);
}
pub inline fn writeS8(iostream: *IOStream, value: i8) bool {
return c.SDL_WriteS8(iostream, value);
}
pub inline fn writeU16LE(iostream: *IOStream, value: u16) bool {
return c.SDL_WriteU16LE(iostream, value);
}
pub inline fn writeS16LE(iostream: *IOStream, value: i16) bool {
return c.SDL_WriteS16LE(iostream, value);
}
pub inline fn writeU16BE(iostream: *IOStream, value: u16) bool {
return c.SDL_WriteU16BE(iostream, value);
}
pub inline fn writeS16BE(iostream: *IOStream, value: i16) bool {
return c.SDL_WriteS16BE(iostream, value);
}
pub inline fn writeU32LE(iostream: *IOStream, value: u32) bool {
return c.SDL_WriteU32LE(iostream, value);
}
pub inline fn writeS32LE(iostream: *IOStream, value: i32) bool {
return c.SDL_WriteS32LE(iostream, value);
}
pub inline fn writeU32BE(iostream: *IOStream, value: u32) bool {
return c.SDL_WriteU32BE(iostream, value);
}
pub inline fn writeS32BE(iostream: *IOStream, value: i32) bool {
return c.SDL_WriteS32BE(iostream, value);
}
pub inline fn writeU64LE(iostream: *IOStream, value: u64) bool {
return c.SDL_WriteU64LE(iostream, value);
}
pub inline fn writeS64LE(iostream: *IOStream, value: i64) bool {
return c.SDL_WriteS64LE(iostream, value);
}
pub inline fn writeU64BE(iostream: *IOStream, value: u64) bool {
return c.SDL_WriteU64BE(iostream, value);
}
pub inline fn writeS64BE(iostream: *IOStream, value: i64) bool {
return c.SDL_WriteS64BE(iostream, value);
}
};
pub inline fn ioFromFile(file: [*c]const u8, mode: [*c]const u8) ?*IOStream {
return c.SDL_IOFromFile(file, mode);
}
pub inline fn ioFromMem(mem: ?*anyopaque, size: usize) ?*IOStream {
return c.SDL_IOFromMem(mem, size);
}
pub inline fn ioFromConstMem(mem: ?*const anyopaque, size: usize) ?*IOStream {
return c.SDL_IOFromConstMem(mem, size);
}
pub inline fn ioFromDynamicMem() ?*IOStream {
return c.SDL_IOFromDynamicMem();
}
pub inline fn openIO(iface: *const IOStreamInterface, userdata: ?*anyopaque) ?*IOStream {
return c.SDL_OpenIO(@ptrCast(iface), userdata);
}
pub inline fn loadFile(file: [*c]const u8, datasize: *usize) ?*anyopaque {
return c.SDL_LoadFile(file, @ptrCast(datasize));
}
pub inline fn saveFile(file: [*c]const u8, data: ?*const anyopaque, datasize: usize) bool {
return c.SDL_SaveFile(file, data, datasize);
}