Working CLEAR command, now checking REMOVE
This commit is contained in:
parent
005631ac76
commit
cd178ce53d
@ -68,17 +68,20 @@ fn pop(allocator: std.mem.Allocator, input: *zid.Data) !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear(allocator: std.mem.Allocator, input: *zid.Data) void {
|
fn clear(allocator: std.mem.Allocator, input: *zid.Data) !void {
|
||||||
var updated_array = std.ArrayList(u8).init(allocator);
|
var updated_array = std.ArrayList(u8).init(allocator);
|
||||||
errdefer updated_array.deinit();
|
errdefer updated_array.deinit();
|
||||||
|
|
||||||
|
const new_len: u64 = 0;
|
||||||
|
try updated_array.appendSlice(std.mem.asBytes(&new_len));
|
||||||
|
|
||||||
switch (input.*) {
|
switch (input.*) {
|
||||||
.IntArray => input.*.IntArray = zid.allocEncodArray.Empty(),
|
.IntArray => input.*.IntArray = try updated_array.toOwnedSlice(),
|
||||||
.FloatArray => input.*.FloatArray = zid.allocEncodArray.Empty(),
|
.FloatArray => input.*.FloatArray = try updated_array.toOwnedSlice(),
|
||||||
.UnixArray => input.*.UnixArray = zid.allocEncodArray.Empty(),
|
.UnixArray => input.*.UnixArray = try updated_array.toOwnedSlice(),
|
||||||
.UUIDArray => input.*.UUIDArray = zid.allocEncodArray.Empty(),
|
.UUIDArray => input.*.UUIDArray = try updated_array.toOwnedSlice(),
|
||||||
.BoolArray => input.*.BoolArray = zid.allocEncodArray.Empty(),
|
.BoolArray => input.*.BoolArray = try updated_array.toOwnedSlice(),
|
||||||
.StrArray => input.*.StrArray = zid.allocEncodArray.Empty(),
|
.StrArray => input.*.StrArray = try updated_array.toOwnedSlice(),
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ pub fn parseNewData(
|
|||||||
.keyword_clear => if (for_update) {
|
.keyword_clear => if (for_update) {
|
||||||
map.put(
|
map.put(
|
||||||
member_name,
|
member_name,
|
||||||
ValueOrArray{ .array = .{ .condition = .pop, .data = null } },
|
ValueOrArray{ .array = .{ .condition = .clear, .data = null } },
|
||||||
) catch return ZipponError.MemoryError;
|
) catch return ZipponError.MemoryError;
|
||||||
state = .expect_comma_OR_end;
|
state = .expect_comma_OR_end;
|
||||||
} else return printError(
|
} else return printError(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user