Still learning about these generative AI tools. My assessment is that it is a Hugh leap in Natural Language Processing. And for programming, might enable us to weave generated pieces into a coherent product faster. It will also allow program creation that might not otherwise happen.
Here is a prompt that I gave Bing copilot – no thrills
With the copilot – it appears to grab stuff from github, but this is a popular library. A real test of that would be to use a obscure or a really fresh github library.
Generate a C++ class that will read the following toml file usinghttps://github.com/ToruNiina/toml11 and store this in a structure for the 2 parts program and script. have method to retrieve the structures for use
So, I created a toml file and said create a class to read. and what you get is a easily to test proof of concept. And yes it works – with some easy mods – like real location of you file
#include <iostream> #include <toml.hpp> struct Program { std::string pgm; std::string parms; std::string user; int interval_seconds; std::string status; }; struct Script { std::string location; std::string pgm; std::string options; int throttle_minutes; }; class TomlReader { public: TomlReader(const std::string& filename) : filename_(filename) {} bool read() { try { data_ = toml::parse_file(filename_); program_ = toml::find<Program>(data_, "program"); script_ = toml::find<Script>(data_, "script"); return true; } catch (const toml::parse_error& e) { std::cerr << "Error parsing TOML file: " << e.what() << std::endl; return false; } } const Program& getProgram() const { return program_; } const Script& getScript() const { return script_; } private: std::string filename_; toml::value data_; Program program_; Script script_; }; int main() { TomlReader reader("your_toml_file.toml"); if (reader.read()) { const Program& program = reader.getProgram(); const Script& script = reader.getScript(); std::cout << "Program:" << std::endl; std::cout << " pgm: " << program.pgm << std::endl; std::cout << " parms: " << program.parms << std::endl; // Add other fields as needed std::cout << "Script:" << std::endl; std::cout << " location: " << script.location << std::endl; std::cout << " pgm: " << script.pgm << std::endl; // Add other fields as needed } return 0; }