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. Public Struct

Diagnostics

Public Struct
std.json.Scanner.Diagnostics
pub const Diagnostics = struct

To enable diagnostics, declare var diagnostics = Diagnostics{}; then call source.enableDiagnostics(&diagnostics); where source is either a std.json.Reader or a std.json.Scanner that has just been initialized. At any time, notably just after an error, call getLine(), getColumn(), and/or getByteOffset() to get meaningful information from this.

Fields

line_number: u64 = 1
line_start_cursor: usize = @as(usize, @bitCast(@as(isize, -1)))
total_bytes_before_current_input: u64 = 0
cursor_pointer: *const usize = undefined

Functions

pub fn getLine(self: *const @This()) u64

Starts at 1.

pub fn getColumn(self: *const @This()) u64

Starts at 1.

pub fn getByteOffset(self: *const @This()) u64

Starts at 0. Measures the byte offset since the start of the input.

File

json/Scanner.zig:1546
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
pub const Diagnostics = struct {
    line_number: u64 = 1,
    line_start_cursor: usize = @as(usize, @bitCast(@as(isize, -1))), // Start just "before" the input buffer to get a 1-based column for line 1.
    total_bytes_before_current_input: u64 = 0,
    cursor_pointer: *const usize = undefined,

    /// Starts at 1.
    pub fn getLine(self: *const @This()) u64 {
        return self.line_number;
    }
    /// Starts at 1.
    pub fn getColumn(self: *const @This()) u64 {
        return self.cursor_pointer.* -% self.line_start_cursor;
    }
    /// Starts at 0. Measures the byte offset since the start of the input.
    pub fn getByteOffset(self: *const @This()) u64 {
        return self.total_bytes_before_current_input + self.cursor_pointer.*;
    }
}