Code Monkey home page Code Monkey logo

Comments (3)

ARC-MX avatar ARC-MX commented on May 26, 2024

I wonder how to initialize an INI file while instantiating an object, Is it possible to add such a function?

from inifile-cpp.

Rookfighter avatar Rookfighter commented on May 26, 2024

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.

from inifile-cpp.

ARC-MX avatar ARC-MX commented on May 26, 2024

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

from inifile-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.