A library for parsing Tiled maps.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use comptime magic to generalize type parsing

Not sure if this is making things more unreadable in an attempt at keeping this kind of stuff DRY

+6 -6
+6 -6
src/Property.zig
··· 50 50 .type = property_type, 51 51 52 52 .value = switch (property_type) { 53 - .string => .{ .string = try innerParseFromValue([]const u8, allocator, value, options) }, 54 - .int => .{ .int = try innerParseFromValue(u32, allocator, value, options) }, 55 - .float => .{ .float = try innerParseFromValue(f32, allocator, value, options) }, 56 - .bool => .{ .bool = try innerParseFromValue(bool, allocator, value, options) }, 57 - .color => .{ .color = try innerParseFromValue(Color, allocator, value, options) }, 58 - .file => .{ .file = try innerParseFromValue([]const u8, allocator, value, options) }, 53 + inline else => |tag| @unionInit(Value, @tagName(tag), try innerParseFromValue( 54 + @typeInfo(Value).@"union".fields[@intFromEnum(tag)].type, 55 + allocator, 56 + value, 57 + options, 58 + )), 59 59 }, 60 60 }; 61 61 }