32 rc = sqlite3_open(dbName.c_str(), &db);
33 sqlite3_exec(db,
"PRAGMA temp_store=MEMORY",NULL, NULL, &errmsg);
34 sqlite3_exec(db,
"PRAGMA synchronous=OFF",NULL, NULL, &errmsg);
35 sqlite3_exec(db,
"PRAGMA count_changes=OFF",NULL, NULL, &errmsg);
36 sqlite3_exec(db,
"PRAGMA page_size=4092",NULL, NULL, &errmsg);
51 if (sqlite3_exec(db, stmt.c_str(), NULL, NULL, &errmsg) != SQLITE_OK)
53 std::cerr << error <<
": " << errmsg << std::endl;
61 return execStmt(
"BEGIN TRANSACTION",
"Couldn't begin transaction: ");
66 return execStmt(
"COMMIT TRANSACTION",
"Couldn't commit transaction: ");
73 "DROP TABLE IF EXISTS Category;" 74 "CREATE TABLE Category (" 75 " id INTEGER PRIMARY KEY ASC AUTOINCREMENT, " 79 "INSERT INTO Category VALUES(NULL, 'Classification', NULL, 'classify_ ml_ mlf_');" 80 "INSERT INTO Category VALUES(NULL, 'CTF', NULL, 'ctf_');" 81 "INSERT INTO Category VALUES(NULL, 'Images', NULL, 'image_');" 82 "INSERT INTO Category VALUES(NULL, 'Metadatas', NULL, 'metadata_');" 83 "INSERT INTO Category VALUES(NULL, 'Phantoms', NULL, 'phantom_ pdb_');" 84 "INSERT INTO Category VALUES(NULL, 'Angular assignment', NULL, 'angular_');" 85 "INSERT INTO Category VALUES(NULL, 'Tomography', NULL, 'tomo_ xray_');" 86 "INSERT INTO Category VALUES(NULL, 'Transformations', NULL, 'transform_');" 87 "INSERT INTO Category VALUES(NULL, 'Volumes', NULL, 'volume_ reconstruct_ resolution_');" 88 "DROP TABLE IF EXISTS Program;" 89 "CREATE TABLE Program (" 90 "id INTEGER PRIMARY KEY ASC AUTOINCREMENT," 91 "category_id INTEGER, name TEXT UNIQUE, usage TEXT, examples TEXT," 94 return execStmt(cmdStr,
"Couldn't create Program table: ");
100 while ((pos = str.find_first_of(
"'", pos)) != String::npos)
102 str.replace(pos, 1,
"''");
105 str =
"'" + str +
"'";
114 std::stringstream ss;
117 <<
"DELETE FROM Program WHERE name=" << progName
118 <<
";INSERT INTO Program VALUES(NULL, NULL," 123 bool result =
execStmt(ss.str(),
"Couldn't insert program");
168 rc = sqlite3_prepare_v2(db, cmd.c_str(), -1, &stmt, NULL);
170 if ((rc = sqlite3_step(stmt)) == SQLITE_ROW)
172 aux.assign((
char*)sqlite3_column_text(stmt, 4));
174 rc = sqlite3_finalize(stmt);
186 dict[
"name"] = program.
name;
188 dict[
"examples"] =
"";
189 dict[
"keywords"] = program.
keywords;
208 for (
size_t i = 0;
i < program.
sections.size(); ++
i)
virtual void printCommentList(const CommentList &comments, int v=0)
bool createProgramTables()
void init(const FileName &dbName)
bool execStmt(const String &stmt, const String &error="")
std::vector< SectionDef * > sections
virtual void printParam(const ParamDef ¶m, int v=0)
virtual void printArgument(const ArgumentDef &argument, int v=0)
virtual void printProgram(const ProgramDef &program, int v=0)
virtual void printSection(const SectionDef §ion, int v=0)
struct _parameter * param
CommentList examples
examples of use
std::map< const char *, String > DictDB
CommentList usageComments
comments of usage
String getLabelComment(const MDLabel &label)
String formatString(const char *format,...)
bool insertProgram(DictDB &program)
String & escapeSqliteStr(String &str)
static String label2Str(const MDLabel &label)