Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › json › Scanner › Reader › nextAllocMax Public Function nextAllocMax Doc Source Public Function std.json.Scanner.Reader.nextAllocMax
pub fn nextAllocMax (self : *@This (), allocator : Allocator , when : AllocWhen , max_value_len : usize ) Reader .AllocError !Token Params File json/Scanner.zig: 1606
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638 pub fn nextAllocMax (self : *@This (), allocator : Allocator , when : AllocWhen , max_value_len : usize ) Reader .AllocError !Token {
const token_type = try self .peekNextTokenType ();
switch (token_type ) {
.number , .string => {
var value_list = std .array_list .Managed (u8 ).init (allocator );
errdefer {
value_list .deinit ();
}
if (try self .allocNextIntoArrayListMax (&value_list , when , max_value_len )) |slice | {
return if (token_type == .number )
Token { .number = slice }
else
Token { .string = slice };
} else {
return if (token_type == .number )
Token { .allocated_number = try value_list .toOwnedSlice () }
else
Token { .allocated_string = try value_list .toOwnedSlice () };
}
},
// Simple tokens never alloc.
.object_begin ,
.object_end ,
.array_begin ,
.array_end ,
.true ,
.false ,
.null ,
.end_of_document ,
=> return try self .next (),
}
}
See also
std.json.Tokenfor documentation ofnextAlloc*()function behavior.