Closed ARC-MX closed 2 years ago
Hi ARC-MX,
could you provide a bit more information on how you want to initialize an INI file or what your goal is? You can directly load an INI file into a IniFile object using its constructor:
IniFile myIni("path/to/some_file.ini");
Directly deserializing a INI file into an object is currently not possible. Also the other way around is not possible. Moving the data of a inifile to a custom struct or class must be handled by the implementer.
I want to initial the “file.ini” while it doesn't create when my code is frist-run like this: `
std::ifstream is("hardwareConfig.ini");
if (is.good() == false) {
std::cout << "open "
<< "hardwareConfig.ini"
<< "field, this is found";
ini::IniFile inif;
inif["Weight"]["startAddr"] = 0x400000000;
inif["Weight"]["maxSize"] = 0x100000000;
inif["Weight"]["gpioPinOfMemReady"] = 1;
inif["Instruction"]["startAddr"] = 0xA1000000;
inif["Instruction"]["maxSize"] = 0x10000;
inif["Instruction"]["gpioPinOfMemReady"] = 3;
inif["FeatureMap"]["startAddr"] = 0xA0000000;
inif["FeatureMap"]["maxSize"] = 0x200000;
inif["FeatureMap"]["gpioPinOfMemReady"] = 2;
inif["Control"]["gpioInBase"] = 501;
inif["Control"]["wpuInterruptEvent"] = 0;
inif["Control"]["weightControlerReady"] = 1;
inif["Control"]["userPlkey"] = 3;
inif["Control"]["gpioOutBase"] = 504;
inif["Control"]["start"] = 0;
inif.save("hardwareConfig.ini");
debugCout << "Saved ini file." << std::endl;
}
ini::IniFile inif;
inif.load("hardwareConfig.ini");
debugCout << "Has " << inif.size() << " sections" << std::endl;
`
I just don't know how to add an init function to inicpp.h file to do that
I wonder how to initialize an INI file while instantiating an object, Is it possible to add such a function?