| author | |
| committer | |
| log | 4318aeb6e24e89245917e9b011892b944c26bea3 |
| tree | b2dafeb507525d3130042508b5b2bc23d2e5ca14 |
| parent | 01c643e7b070c69c402c64059af02ea881cde5f5 |
| signature |
4 files changed, 13 insertions(+), 0 deletions(-)
AnyReadable.zig+1| ... | @@ -17,6 +17,7 @@ pub const readArray = R.readArray; | ... | @@ -17,6 +17,7 @@ pub const readArray = R.readArray; |
| 17 | pub const readByte = R.readByte; | 17 | pub const readByte = R.readByte; |
| 18 | pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList; | 18 | pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList; |
| 19 | pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc; | 19 | pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc; |
| 20 | pub const readUntilDelimiterOrEofAlloc = R.readUntilDelimiterOrEofAlloc; | ||
| 20 | pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf; | 21 | pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf; |
| 21 | pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList; | 22 | pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList; |
| 22 | pub const readAlloc = R.readAlloc; | 23 | pub const readAlloc = R.readAlloc; |
buffered_reader.zig+1| ... | @@ -28,6 +28,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty | ... | @@ -28,6 +28,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty |
| 28 | pub const readByte = R.readByte; | 28 | pub const readByte = R.readByte; |
| 29 | pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList; | 29 | pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList; |
| 30 | pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc; | 30 | pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc; |
| 31 | pub const readUntilDelimiterOrEofAlloc = R.readUntilDelimiterOrEofAlloc; | ||
| 31 | pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf; | 32 | pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf; |
| 32 | pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList; | 33 | pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList; |
| 33 | pub const readAlloc = R.readAlloc; | 34 | pub const readAlloc = R.readAlloc; |
fixed_buffer_stream.zig+1| ... | @@ -36,6 +36,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type { | ... | @@ -36,6 +36,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type { |
| 36 | pub const readByte = R.readByte; | 36 | pub const readByte = R.readByte; |
| 37 | pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList; | 37 | pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList; |
| 38 | pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc; | 38 | pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc; |
| 39 | pub const readUntilDelimiterOrEofAlloc = R.readUntilDelimiterOrEofAlloc; | ||
| 39 | pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf; | 40 | pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf; |
| 40 | pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList; | 41 | pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList; |
| 41 | pub const readAlloc = R.readAlloc; | 42 | pub const readAlloc = R.readAlloc; |
nio.zig+10| ... | @@ -125,6 +125,16 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type { | ... | @@ -125,6 +125,16 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type { |
| 125 | return list.toOwnedSlice(); | 125 | return list.toOwnedSlice(); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | pub fn readUntilDelimiterOrEofAlloc(self: Self, allocator: std.mem.Allocator, needle: u8, max_size: usize) !?[]u8 { | ||
| 129 | var list: std.ArrayList(u8) = .init(allocator); | ||
| 130 | defer list.deinit(); | ||
| 131 | _ = readUntilDelimiterArrayList(self, &list, needle, max_size) catch |err| switch (err) { | ||
| 132 | error.EndOfStream => return null, | ||
| 133 | else => |e| return e, | ||
| 134 | }; | ||
| 135 | return try list.toOwnedSlice(); | ||
| 136 | } | ||
| 137 | |||
| 128 | /// Returned slice is not suffixed by needle but buffer will contain it. | 138 | /// Returned slice is not suffixed by needle but buffer will contain it. |
| 129 | pub fn readUntilDelimitersBuf(self: Self, buffer: []u8, needle: []const u8) ![]u8 { | 139 | pub fn readUntilDelimitersBuf(self: Self, buffer: []u8, needle: []const u8) ![]u8 { |
| 130 | var real_len: usize = 0; | 140 | var real_len: usize = 0; |