commit 9b51842ca502d6928221a1af566c4fff2996a13a Author: Kitteh Date: Tue Jun 1 10:38:42 2021 +0100 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..20a040b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +material diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..603d26b --- /dev/null +++ b/src/main.zig @@ -0,0 +1,19 @@ +const std = @import("std"); + +const read = @import("./qtshit/read.zig"); +const write = @import("./qtshit/write.zig"); + + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + try stdout.print("Hello, {s}!\n", .{"world"}); + + var byteList = std.ArrayList(u8).init(std.heap.page_allocator); + defer byteList.deinit(); + + try write.add_int(byteList.writer(), 4242); + + var reader = std.io.fixedBufferStream(byteList.items).reader(); + try stdout.print("Number: {} \n", .{try read.get_int(reader)}); + +} \ No newline at end of file diff --git a/src/qtshit/read.zig b/src/qtshit/read.zig new file mode 100644 index 0000000..2e9b61a --- /dev/null +++ b/src/qtshit/read.zig @@ -0,0 +1,3 @@ +pub fn get_int(reader: anytype) !u16 { + return try reader.readIntBig(u16); +} \ No newline at end of file diff --git a/src/qtshit/write.zig b/src/qtshit/write.zig new file mode 100644 index 0000000..ffff856 --- /dev/null +++ b/src/qtshit/write.zig @@ -0,0 +1,6 @@ +const std = @import("std"); + + +pub fn add_int(writer: anytype, number: u16) !void { + try writer.writeIntBig(u32, 10); +} \ No newline at end of file