Skip to content

arsd.ini + my utility functions #11

@crazymonkyyy

Description

@crazymonkyyy

0x wrote code and pinged me for my opinion

my opinion for serialization remains conversational

I wrote this when testing the lib

	auto parseIniFile(string filePath) {
		import std.file : readText;
		return parseIniAA(readText(filePath));
	}
	auto parseSimpleIniFile(string filePath) {
		return parseIniFile(filePath)[""];
	}
	void writeIniFile(string filePath, IniDocument!string document) {
		import std.file : write;
		return write(filePath, stringifyIni(document));
	}
	void hotloadSave(Args...)(string filePath="data.ini"){
		import std.file;
		import std.conv;
		auto file=File(filePath,"w");
		static foreach(I;0..Args.length){
			file.writeln(Args[I].stringof,"=",Args[I].to!string);
		}
	}
	void hotloadLoad(Args...)(string filePath="data.ini"){
		import std.conv;
		foreach(key,value;parseSimpleIniFile(filePath)){
			lable:switch(key){
				static foreach(I;0..Args.length){
					case Args[I].stringof:
						writeln(Args[I].stringof,",",value);
						Args[I]=value.to!(typeof(Args[I])); break lable;
				}
				default: writeln(key,value,"missed");
			}
	}}

When 0x.ini moves to odc.ini or adrs.ini; I will want some kind of hotloading api

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions