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 library itself.

Parsed

lang.Parsed
pub const Parsed = struct

File

Code

pub const Parsed = struct {
    language_code: []const u8,
    script_tag: ?[]const u8 = null,
    country_code: ?[]const u8 = null,
    /// Can be a sort order (e.g. phoneb) or something like valencia, 001, etc
    suffix: ?[]const u8 = null,
    /// There can be any number of suffixes, but we don't need to care what their
    /// values are, we just need to know if any exist so that e.g. `ca-es-valencia-blah`
    /// can be seen as different from `ca-es-valencia`. Storing this as a bool
    /// allows us to avoid needing either (a) dynamic allocation or (b) a limit to
    /// the number of suffixes allowed when parsing.
    multiple_suffixes: bool = false,

    pub fn isSuffixValidSortOrder(self: Parsed) bool {
        if (self.country_code == null) return false;
        if (self.suffix == null) return false;
        if (self.script_tag != null) return false;
        if (self.multiple_suffixes) return false;
        for (valid_alternate_sorts) |valid_sort| {
            if (std.ascii.eqlIgnoreCase(valid_sort.language_code, self.language_code) and
                std.ascii.eqlIgnoreCase(valid_sort.country_code.?, self.country_code.?) and
                std.ascii.eqlIgnoreCase(valid_sort.suffix.?, self.suffix.?))
            {
                return true;
            }
        }
        return false;
    }
}