classnetColarUtils::SettingUtils
sys::Obj netColarUtils::SettingUtils
Settings Allows for Easy, documented settings files
Note: Usually prefer JsonUtils has it is a bit more flexible/sturdy than serialization.
All fields with the Facet "Setting" will be saved (using serialization: writeObj/ReadObj) Fields with the Setting Facet can NOT be nullable. Fields are stored using fantom serialization If there is a default value it will be displayed as well (as a comment in saved file) Note: It even works with "Complex" serialized obects, although it is less user friendly (better to stick to "simples")
- commentChar
Str commentChar := "#"
Line comment char (default: #)
- headComments
Str[] headComments := Str[,]
Comments to show at the top of the file commentChar will be prepanded to each line
- load
static Obj? load(File file, Type type, Bool createIfMissing := true)
Load settings from a file into given type
- make
new make(|This f)
- read
Obj? read(Type type, InStream in)
Load the settings from a stream/file and inject the into a new object of given type the type must have an it constructor ! new make(|This| f) {f(this)}
- save
Void save(Obj o, OutStream out)
Save the settings (complete overwrite) Closes the stream when done
- tailComments
Str[] tailComments := Str[,]
Comments to show at the bottom of the file commentChar will be prepanded to each line
- update
Try to save the file "in place" Not touching existing comment lines If the file does not exist then it just calls save()