Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using toml++. How can I modify a particular value of a TOML file in CPP using toml++


json ConfigService::getAllData(std::string filePath)
{
    try
    {
        auto _data_table = toml::parse_file(filePath);
        _data_table["config_paths"]["DIAAI_core"] = "diaaiSetting.toml";  # this is not working
        cout << _data_table << endl;
    }
    catch (const exception err)
    {
        std::cerr << "Parsing failed:\n"
                  << err.what() << "\n";
        std::runtime_error(err.what());
    }
}


traceback

error: no match for ‘operator=’ (operand types are ‘toml::v3::node_view<toml::v3::node>’ and ‘int’)
   51 |         _data_table["config_paths"] = 1;


What I have tried:

toml++ TOML for C++[^]
Posted
Updated 18-Jun-22 22:46pm

1 solution

The error message is stating the the element at _data_table["config_paths"] cannot be an integer. You need to consult the documentation for the _data_table class to find out why.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900