Module: encoding.ini
Source: ./encoding/ini.reef
Overview
encoding/ini - INI file parsing
Simple INI file format parser supporting:
- [section] headers
- key=value pairs
-
and ; comment lines
- Whitespace trimming
Usage: import encoding.ini if ini_is_section(line) let section = ini_get_section(line) elif ini_is_key_value(line) let key = ini_get_key(line) let value = ini_get_value(line)
Types
IniBuilder
Fields:
| Name | Type |
|---|---|
sb |
sb.StringBuilder |
in_section |
bool |
Functions
fn ini_get_section_or(line: string, default: string): string
Trim leading and trailing whitespace *_or line parsers: the parsed value, or the caller default when the line is not of that shape. Same pairing as encoding.toml / .json / .yaml.
Some("") is a PRESENT value here and is returned as-is -- key= is a real
empty INI value and [] a real empty section name. Substituting the default
for those would reinstate the collision the C16 conversion removed.
fn ini_get_key_or(line: string, default: string): string
fn ini_get_value_or(line: string, default: string): string
fn ini_trim(s: string): string
fn ini_is_empty(line: string): bool
Check if line is empty or only whitespace
fn ini_is_comment(line: string): bool
Check if line is a comment (starts with # or ; after whitespace)
fn ini_is_section(line: string): bool
Check if line is a section header [name]
fn ini_is_key_value(line: string): bool
Check if line is a key=value pair
fn ini_get_section(line: string): option.Option[string]
Extract section name from [section] line
0.9.2 C16: None when the line has no '[' -- i.e. is not a section header.
This returned "" for both "not a section line" and the section header [],
which ini_is_section() happily accepts, so the two were indistinguishable.
fn ini_get_key(line: string): option.Option[string]
Extract key from key=value line
0.9.2 C16: None when the line has no '=' -- i.e. is not a key/value line.
This returned "" for both that case and a line like =value, which
ini_is_key_value() accepts and which yields a real (if odd) empty key.
Mirrors ini_get_value, which took the same treatment.
fn ini_get_value(line: string): option.Option[string]
Extract value from key=value line
0.9.2 C16: Some(value) for a key=value line, None when there is no '='.
This returned "" for BOTH a line with no '=' and the entirely legitimate
key= with an empty value -- different facts a caller could not tell apart.
fn ini_builder(): IniBuilder
fn ini_serialize(b: IniBuilder): string
Procedures
proc ini_begin_section(b: IniBuilder, name: string)
proc ini_set(b: IniBuilder, key: string, value: string)
proc ini_set_int(b: IniBuilder, key: string, value: int)
proc ini_set_bool(b: IniBuilder, key: string, value: bool)
proc ini_comment(b: IniBuilder, text: string)
Generated by reefc doc