Repository

v-ini

INI library for V.

Setup

v install Sorrow446.vini

import sorrow446.vini as ini

Examples

Accessing values

mut cfg := ini.read('1.ini')!
section := cfg.sections['config']
println(section['out_path'])
println(section['format'].int())

Read INI, modify it, then write it to a new file

mut cfg := ini.read('1.ini')!
cfg.sections['config']['out_path'] = 'G:\\out2'
cfg.sections['new.section'] = {
  'ab': 'cd',
  'ef': 'gh',
}
ini.write('2.ini', cfg)!
[config]
out_path=G:\out
format=10

->

[config]
out_path=G:\out2
format=10

[new.section]
ab=cd
ef=gh

Restrictions

Type Allowed chars
Section key a-zA-Z0-9.-_/
Key a-zA-Z0-9.-_ , first char can be + , - or !
Value any
  • Loose key/value pairs without sections are allowed.
  • Duplicate value keys are allowed, but duplicate section keys aren't.
  • Comments can start with ; or # .

Structs

pub struct Duplicates {
pub mut:
    sections map[string]map[string][]string
    loose	map[string][]string
}

pub struct INIFile {
pub mut:
    sections map[string]map[string]string
    loose map[string]string
    duplicates Duplicates
}

About

0
5
last May 7

Author

Sorrow446