4 #include "extlib/sqlite3.h"
5 #include "Settings.hpp"
7 #include <boost/lexical_cast.hpp>
8 #include <boost/format.hpp>
9 #include <mof/GraphicsDevice.hpp>
16 //{{{ callback_load_settings
17 static int callback_load_settings(void* data, int argc, char** argv, char** colnames)
19 Settings* settings = static_cast<Settings*>(data);
20 for (int i = 0 ; i < argc; i++) {
21 char* colname = colnames[i];
22 char* value = argv[i];
23 if (!strcmp(colname, "screen_width")) settings->screen.width = boost::lexical_cast<int>(value);
24 else if (!strcmp(colname, "screen_height")) settings->screen.height = boost::lexical_cast<int>(value);
25 else if (!strcmp(colname, "screen_mode")) settings->screen_mode = boost::lexical_cast<int>(value);
26 else if (!strcmp(colname, "input_mode")) settings->input_mode = boost::lexical_cast<int>(value);
27 else if (!strcmp(colname, "enable_output_frame")) settings->enable_output_frame = boost::lexical_cast<int>(value);
28 else if (!strcmp(colname, "enable_output_audio")) settings->enable_output_audio = boost::lexical_cast<int>(value);
29 else if (!strcmp(colname, "fps")) settings->fps = boost::lexical_cast<int>(value);
35 int LoadSettings(Settings* p)
39 result = sqlite3_open("settings.db", &db);
40 if (SQLITE_OK != result) return 0;
41 static const char* sql = "SELECT * FROM settings WHERE id = 1";
43 result = sqlite3_exec(db, sql, callback_load_settings, (void*)p, &err);
45 std::cout << err << std::endl;
49 if (SQLITE_OK != result) return 0;