New C++ class AppConfig for maintaining the config.ini

New helper function for generating a unified "generated by slic3r" header.
This commit is contained in:
bubnikv 2017-10-30 18:15:41 +01:00
parent 835e5b71a8
commit 1fee3633a0
11 changed files with 107 additions and 51 deletions

View file

@ -1,6 +1,6 @@
#include "Config.hpp"
#include "Utils.hpp"
#include <assert.h>
#include <ctime>
#include <fstream>
#include <iostream>
#include <exception> // std::runtime_error
@ -422,13 +422,7 @@ void ConfigBase::save(const std::string &file) const
{
boost::nowide::ofstream c;
c.open(file, std::ios::out | std::ios::trunc);
{
std::time_t now;
time(&now);
char buf[sizeof "0000-00-00 00:00:00"];
strftime(buf, sizeof(buf), "%F %T", gmtime(&now));
c << "# generated by Slic3r " << SLIC3R_VERSION << " on " << buf << std::endl;
}
c << "# " << Slic3r::header_slic3r_generated() << std::endl;
for (const std::string &opt_key : this->keys())
c << opt_key << " = " << this->serialize(opt_key) << std::endl;
c.close();