Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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. Private Type Function

CpuinfoParser

Private Type Function
std.zig.system.linux.CpuinfoParser
fn CpuinfoParser(comptime impl: anytype) type

The generic implementation of a /proc/cpuinfo parser. For every line it invokes the line_hook method with the key and value strings as first and second parameters. Returning false from the hook function stops the iteration without raising an error. When all the lines have been analyzed the finalize method is called.

Functions

fn parse(arch: Target.Cpu.Arch, reader: *Io.Reader) !?Target.Cpu

File

zig/system/linux.zig:429
429
430
431
432
433
434
435
436
437
438
439
440
441
442
fn CpuinfoParser(comptime impl: anytype) type {
    return struct {
        fn parse(arch: Target.Cpu.Arch, reader: *Io.Reader) !?Target.Cpu {
            var obj: impl = .{};
            while (try reader.takeDelimiter('\n')) |line| {
                const colon_pos = mem.findScalar(u8, line, ':') orelse continue;
                const key = mem.trimEnd(u8, line[0..colon_pos], " \t");
                const value = mem.trimStart(u8, line[colon_pos + 1 ..], " \t");
                if (!try obj.line_hook(key, value)) break;
            }
            return obj.finalize(arch);
        }
    };
}