Exemple #1
0
void procTables(QDomNode start, QTextStream &outstrm)
{
    QString tableName;
    tableName = start.toElement().attribute("name");
    //qDebug() << "Creating table:" + tableName;
    QDomNode node = start.firstChild();
    QList<QDomNode> fields;
    bool proc;
    proc = false;
    while (!node.isNull())
    {
        if (node.toElement().tagName() == "field")
            fields.append(node);
        if (node.toElement().tagName() == "table")
        {
            if (proc == false)
            {
                createTable(tableName,fields,outstrm); //Create the current table
                fields.clear(); //Clear the fields
                proc = true;
            }
            procTables(node,outstrm); //Recursive process the subtable
        }
        node = node.nextSibling();
    }
    if (fields.count() > 0)
    {
        createTable(tableName,fields,outstrm);
    }
}
Exemple #2
0
Organizer::Organizer()
{
    if (!createDB())
    {
        perror("Open DB");
        exit(errno);
    }

    createTable("CREATE TABLE fic(size integer,path varchar(1000) UNIQUE, md5 varchar(16));");

    createTable("CREATE TABLE dir(empty bool,path varchar(1000) UNIQUE, modif datetime);");
}
Exemple #3
0
int main(int argc, char **argv)
{
    srand(time(NULL));
    pi = 4.0 * atan(1);
    min_x = 0.0;
    max_x = 3.0 * pi;
    if (argc > 1) {
        if (strcmp(argv[1], "-n") == 0) {
            no_random = 1;
        } else {
            print_usage(argv[0]);
            return 1;
        }
    }

    Table my_table = createMyTable();
    Table doubled_table = doubleTable(&my_table, min_x);
    Table left_table = createTable(min_x, max_x, 0);
    Table middle_table = createTable(min_x, max_x, numof_parts / 2);
    Table right_table = createTable(min_x, max_x, numof_parts - 1);

    printReport(&my_table, "Initial table");
    printReport(&doubled_table, "Doubled table");
    printReport(&left_table, "Left table");
    printReport(&middle_table, "Middle table");
    printReport(&right_table, "Right table");

    resetFunction(&right_table, my_g);
    resetFunction(&middle_table, my_g);
    resetFunction(&left_table, my_g);
    resetFunction(&doubled_table, my_g);
    resetFunction(&my_table, my_g);

    printReport(&my_table, "Initial table");
    printReport(&doubled_table, "Doubled table");
    printReport(&left_table, "Left table");
    printReport(&middle_table, "Middle table");
    printReport(&right_table, "Right table");

    disposeTable(&right_table);
    disposeTable(&middle_table);
    disposeTable(&left_table);
    disposeTable(&doubled_table);
    disposeTable(&my_table);

    reportMaxError();

    return 0;
}
Exemple #4
0
void testStore(void) {

  // setup
  struct Command* createDatabaseCommand = createCreateDatabaseCommand("test_store");
  createDatabase(createDatabaseCommand);

  char names[FIELD_SIZE][NAME_LIMIT] = { "name1", "name2", "name3", "name4", };

  char values[FIELD_SIZE][VALUE_LIMIT] = { "1", "value2", "1/1/2015", "3", };

  FieldType types[FIELD_SIZE][1] = { INTEGER, TEXT, DATE, INTEGER, };

  struct Field* fields = createFieldList(names, values, types, 4);
  struct Command* createTableCmd = createCreateTableCommand("table",
      fields);
  createTable(createTableCmd);


  // test
  struct Command* insertCmd = createInsertCommand("table", fields);
  insertTuple(insertCmd);
  values[0][0] = '2';
  insertTuple(insertCmd);

  // teardown
  destroyCommand(createDatabaseCommand);
  destroyCommand(createTableCmd);
}
Exemple #5
0
void testCreateTable(void) {

  struct Command* createDBCommand = createCreateDatabaseCommand("foo");
  createDatabase(createDBCommand);
  assert(strcmp(currentDatabase, "foo") == 0, "currentDatabase should be set!");
  char tableFolderPath[PATH_SIZE];

  char names[FIELD_SIZE][NAME_LIMIT] = { "name1", "name2", "name3", "name4", };

  char values[FIELD_SIZE][VALUE_LIMIT] = { "1", "value2", "1/1/2015", "3", };

  FieldType types[FIELD_SIZE][1] = { INTEGER, TEXT, DATE, INTEGER, };
  struct Field* fields = createFieldList(names, values, types, 4);

  struct Command* createTableCmd = createCreateTableCommand("bar", fields);
  createTable(createTableCmd);
  sprintf(tableFolderPath, "%s/foo/bar", DATABASE_DIR);
  assert(access(tableFolderPath, F_OK) != -1, "Table file was not constructed!");

  char fileContents[RECORD_SIZE];
  FILE* file = fopen(tableFolderPath, "r");
  fgets(fileContents, RECORD_SIZE, file);

  char* header = "name1[I]|name2[T]|name3[D]|name4[I]\n";
  assert(strcmp(fileContents, header) == 0, "Table was not written correctly!");

  // cleanup garbage
  fclose(file);
  destroyCommand(createDBCommand);
  destroyCommand(createTableCmd);
}
int main(int argc, char *argv[])
/* Read ContigInfo into hash. */
/* Filter ContigLocusId and write to ContigLocusIdFilter. */
{

if (argc != 3)
    usage();

snpDb = argv[1];
contigGroup = argv[2];
hSetDb(snpDb);

/* check for needed tables */
if(!hTableExistsDb(snpDb, "ContigLocusId"))
    errAbort("no ContigLocusId table in %s\n", snpDb);
if(!hTableExistsDb(snpDb, "ContigInfo"))
    errAbort("no ContigInfo table in %s\n", snpDb);


contigHash = loadContigs(contigGroup);
if (contigHash == NULL) 
    {
    verbose(1, "couldn't get ContigInfo hash\n");
    return 1;
    }

filterSNPs();
createTable();
loadDatabase();

return 0;
}
Exemple #7
0
/**
 * Adds a set of constants to the Lua library
 * @param L             A pointer to the Lua VM
 * @param LibName       The name of the library.
 * If this is an empty string, the functions will be added to the global namespace.
 * @param Constants     An array of the constant values along with their names.
 * The array must be terminated with the enry (0, 0)
 * @return              Returns true if successful, otherwise false.
 */
bool LuaBindhelper::addConstantsToLib(lua_State *L, const Common::String &libName, const lua_constant_reg *constants) {
#ifdef DEBUG
	int __startStackDepth = lua_gettop(L);
#endif

	// If the table is empty, the constants are added to the global namespace
	if (libName.size() == 0) {
		for (; constants->Name; ++constants) {
			lua_pushstring(L, constants->Name);
			lua_pushnumber(L, constants->Value);
			lua_settable(L, LUA_GLOBALSINDEX);
		}
	}
	// If the table name is nto empty, the constants are added to that table
	else {
		// Ensure that the library table exists
		if (!createTable(L, libName)) return false;

		// Register each constant in the table
		for (; constants->Name; ++constants) {
			lua_pushstring(L, constants->Name);
			lua_pushnumber(L, constants->Value);
			lua_settable(L, -3);
		}

		// Remove the library table from the Lua stack
		lua_pop(L, 1);
	}

#ifdef DEBUG
	assert(__startStackDepth == lua_gettop(L));
#endif

	return true;
}
/*!
    Constructs the UiDigitalGenerator with the given \a parent.
*/
UiDigitalGenerator::UiDigitalGenerator(DigitalSignals* digitalSignals,
                                       QWidget *parent) :
    QWidget(parent)
{
    int defaultStates = 32;
    mSignals = digitalSignals;

    GeneratorDevice* device = DeviceManager::instance().activeDevice()
            ->generatorDevice();
    if (device != NULL) {
        defaultStates = device->maxNumDigitalStates();
    }

    // Deallocation: ownership changed when calling setLayout
    QVBoxLayout* verticalLayout = new QVBoxLayout();

    mTable = createTable();

    verticalLayout->addWidget(createToolBar());
    verticalLayout->addWidget(mTable);

    setLayout(verticalLayout);


    setNumStates(defaultStates);
}
Exemple #9
0
GameMatrix* newGameMatrix(SDL_Surface *screen, int matrixHeight, int matrixWidth)
{
	int i = 0,j = 0;
	
	/** Crée la surface de jeu **/
	GameMatrix *surface = malloc(sizeof(GameMatrix));
	/// Dimensions de la grille de jeu
	surface->height = matrixHeight;
	surface->width = matrixWidth;
	surface->surf = createTable(surface->height, surface->width);
	
	// Calcul de la largeur d'un bloc en fonction des dimensions de la fenêtre
	surface->coteBloc = (HEIGHT-CADRE*2)/surface->height;
	
	// Initialisation de la surface à 0
	for(i = 0; i < surface->height; i++)
		for(j = 0; j < surface->width; j++)
			surface->surf[i][j] = 0;
				
	// Initialisation des couleurs		
	surface->colors[0] = SDL_MapRGB(screen->format, 255,0,0); // Rouge
	surface->colors[1] = SDL_MapRGB(screen->format, 0,0,255); // Bleu
	surface->colors[2] = SDL_MapRGB(screen->format, 189,141,70); // Brun
	surface->colors[3] = SDL_MapRGB(screen->format, 255,0,255); // Magenta
	surface->colors[4] = SDL_MapRGB(screen->format, 255,255,255); // Blanc
	surface->colors[5] = SDL_MapRGB(screen->format, 0,255,255); // Cyan
	surface->colors[6] = SDL_MapRGB(screen->format, 0,255,0); // Vert
	
	return surface;
}
Recordinfo API::dealCmd(sqlcommand& sql){
	// 使用get方法更好,这里先直接调用public
	switch(sql.sqlType){
		case 0:
		return select(sql);
		break;
		case 1:
		return del(sql);
		break;
		case 2:
		return insert(sql);
		break;
		case 3:
		return createTable(sql);
		break;
		case 4:
		return createIndex(sql);
		break;
		case 5:
		return dropTable(sql);
		break;
		case 6:
		return dropIndex(sql);
		break;
	}
	return Recordinfo();
}
Exemple #11
0
void HashTable::rebuildTable(unsigned int newSize, HashFunction *hashFunct)
{
    List **oldTable = table;
    unsigned int oldSize = hTsize;
    hTsize = newSize;
    createTable();
    collisions = 0;
    maxCollLength = 0;
    LoadFactor = 0;
    elemQuantity = 0;
    delete hash;
    hash = hashFunct;
    for (unsigned int i = 0; i < oldSize; i++)
    {
        if (oldTable[i] != NULL && !oldTable[i]->isEmpty())
        {
            ListElement *temp = oldTable[i]->getHead();
            while (temp->getNext() != NULL)
            {
                add(temp->getStr(), temp->getElemCounter());
                temp = temp->getNext();
            }
            add(temp->getStr(), temp->getElemCounter());
        }
    }
    for (int i = 0; i < hTsize; i++)
		delete oldTable[i];
    delete[] oldTable;
}
Exemple #12
0
void Calendar::initDatabase()
{
    QFile dbFile("data.db");
    if(dbFile.exists())
    {
        m_db = QSqlDatabase::addDatabase("QSQLITE");
        m_db.setDatabaseName("data.db");
        m_db.open();
        qDebug() << "Database oppened.";
    }
    else
    {
        m_db = QSqlDatabase::addDatabase("QSQLITE");
        m_db.setDatabaseName("data.db");
        m_db.open();
        QSqlQuery createTable(m_db);
        createTable.exec("CREATE TABLE events(empty_place TEXT NULL, name TEXT NULL, description TEXT NULL, date_time DATETIME)");
        qDebug() << "Database created.";
    }

    m_sqlTableModel = new QSqlTableModel(this, m_db);
    m_sqlTableModel->setTable("events");
    m_sqlTableModel->setSort(3, Qt::AscendingOrder);
    m_sqlTableModel->select();
}
void THTMLLandaus::addLandauDiamondTable(vector<Float_t> vecHistoMeans, vector<Float_t> vecHistoMaxs, vector<Float_t> vecHistoGaus, vector<Float_t> vecHistoLandau)
{
	stringstream sectionContent;
	vector<vector<string> > tableContent;
	tableContent.resize(vecHistoMeans.size()+1);
	tableContent.at(0).push_back("ClusterSize");
	tableContent.at(0).push_back("Mean");
	tableContent.at(0).push_back("MaxPos");
	tableContent.at(0).push_back("GausPos");
	tableContent.at(0).push_back("LandauMP");
	tableContent.at(0).push_back("Landau/Gaus");
	tableContent.at(0).push_back("Landau/Max");
	for(UInt_t i=0;i<vecHistoMeans.size()&&i<vecHistoMaxs.size()&&i<vecHistoGaus.size()&&i<vecHistoLandau.size();i++){
		Float_t fraction = vecHistoLandau.at(i)/vecHistoGaus.at(i);
		tableContent.at(i+1).push_back((i==0?"AllClusters":this->floatToString(i+1)));
		tableContent.at(i+1).push_back(this->floatToString(vecHistoMeans.at(i)));
		tableContent.at(i+1).push_back(this->floatToString(vecHistoMaxs.at(i)));
		tableContent.at(i+1).push_back(this->floatToString(vecHistoGaus.at(i)));
		tableContent.at(i+1).push_back(this->floatToString(vecHistoLandau.at(i)));
		tableContent.at(i+1).push_back(this->floatToString(fraction));
		fraction = vecHistoLandau.at(i)/vecHistoMaxs.at(i);
		tableContent.at(i+1).push_back(this->floatToString(fraction));
	}
	sectionContent<<"<p>\n";
	sectionContent<<createTable(tableContent)<<endl;
	sectionContent<<"<p>";
	this->addSection("Landau Fit CrossCheck Table",sectionContent.str());
}
/***********************************************************************************
   Main function for table creation/altering called from tobrowsertable.cpp
   It will call either createTable either alterTable
************************************************************************************/
QString toOracleExtract::migrateTable(toExtract &ext, std::list<QString> &source,
                                      std::list<QString> &destin) const
{
#ifdef DEBUG
    qDebug() << "toOracleExtract::migrateTable source=";
    for (std::list<QString>::iterator i = source.begin(); i != source.end(); i++)
    {
        qDebug() << *i;
    }
    qDebug() << "toOracleExtract::migrateTable destin=";
    for (std::list<QString>::iterator i = destin.begin(); i != destin.end(); i++)
    {
        qDebug() << *i;
    }
#endif


    if (source.empty())
    {
#ifdef DEBUG
        qDebug() << "New table has to be created.";
#endif
        return createTable(destin);
    }
    else
    {
#ifdef DEBUG
        qDebug() << "Existing table is to be modified.";
#endif
        return alterTable(source, destin);
    }
} // migrateTable
Exemple #15
0
int main ()
{
    HashTable *hashTable = createTable(hashConst, SIZE);
    textAnalyzer(hashTable);
    stat(hashTable);
    freeTable(hashTable);
    hashTable = createTable(hashCountCodes, SIZE);
    textAnalyzer(hashTable);
    stat(hashTable);
    freeTable(hashTable);
    hashTable = createTable(hashGood, SIZE);
    textAnalyzer(hashTable);
    stat(hashTable);
    freeTable(hashTable);

}
Exemple #16
0
int main()
{
    Connection conn;
    DbRetVal rv = conn.open("root", "manager");
    if (rv != OK) return 1;
    DatabaseManagerImpl *dbMgr = (DatabaseManagerImpl*) conn.getDatabaseManager();
    if (dbMgr == NULL) { printf("Auth failed\n"); return 2;}
    int ret =0, rc =0;
    if (createTable(dbMgr, "t1") != 0 ) { ret = 3; }
#ifdef WITHINDEX
    if (createIndex(dbMgr, "t1","f1", "idx1") != 0 ) { ret = 4; }
#endif
    rv = conn.startTransaction();
    if (rv != OK) ret = 5; 
    rc = insertTuple(dbMgr, conn, "t1", 10);
    if (rc != 10) ret = 6;
    conn.commit(); 

    rv = conn.startTransaction();
    if (rv != OK) ret = 5; 
    rc = selectTuple(dbMgr, conn, "t1", 10);
    if (rc != 10) ret = 6;
    printf("Before commit\n");
    dbMgr->printDebugLockInfo();
    conn.commit(); 
    printf("After commit\n");
    dbMgr->printDebugLockInfo();
    dropTable(dbMgr, "t1");
    conn.close();
    return ret;
}
Exemple #17
0
void main() {

	Table *table = createTable(11);
	TableEntry entry[11];
	initialize(&entry[0], "coke", 20);
	insertEntry(table, &entry[0]);
	initialize(&entry[1], "bsererreeaffsfsd", 20);
	insertEntry(table, &entry[1]);
	initialize(&entry[2], "bfdsfadsfb", 20);
	insertEntry(table, &entry[2]);
	initialize(&entry[3], "bfdafdsbb", 20);
	insertEntry(table, &entry[3]);
	initialize(&entry[4], "milk tefssfa", 15);
	insertEntry(table, &entry[4]);
	initialize(&entry[5], "apple judffice", 30);
	insertEntry(table, &entry[5]);
	initialize(&entry[6], "orange juidsce", 25);
	insertEntry(table, &entry[6]);
	initialize(&entry[7], "black tefdfdsa", 10);
	insertEntry(table, &entry[7]);


	findTable(table, "bsererreeaffsfsd");
	findTable(table, "c*k");
	findTable(table, "milk tea");
	findTable(table, "apple juice");
	findTable(table, "black tea");
	findTable(table, "b");

	system("pause");
}
Exemple #18
0
int main()
{

    Connection conn;
    DbRetVal rv = conn.open("root", "manager");
    if (rv != OK) { printf("Error during connection %d\n", rv); return 1; }
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    int ret = createTable(dbMgr);
    if (ret != 0) { return 1; }

    pthread_t thr[2];
    int *status1, *status2;
    pthread_create (&thr[0], NULL, &runTest1,  NULL);
    pthread_create (&thr[1], NULL, &runTest2,  NULL);
    printf("All threads started\n");

    pthread_join(thr[0], (void**)&status1);
    pthread_join(thr[1], (void**)&status2);
    ret = 0;
    if (*status1 != 0 || *status2 != 0) ret = 1;
    if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; }
    if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; }
    dbMgr->dropTable("t1");
    conn.close();
    return ret;
}
Exemple #19
0
void database::redoTable()
{
    deleteTable();
    deleteReactionsTable();
    createTable();
    createReactionsTable();
}
TEST_F(PointerCalcTests, pc_from_vertical_table_slice_count_4_groups) {
  auto t = createTable(table_5);
  ASSERT_EQ(5u, t->partitionCount());
  auto tmp_fd = new std::vector<field_t>{1, 2, 3, 4};
  auto res = PointerCalculator::create(t, nullptr, tmp_fd);
  ASSERT_EQ(2u, res->partitionCount());
}
int kmp(char s[], int ss, char t[], int ts){
    int h[ts]; //Partial Table
    createTable(t,h,ts);

    int i=0,j=0;
    while(i<ss){    
        while(s[i]!=t[0]) i++;
        j=1;
        while(s[i+j]==t[j]) j++;
        if(j==ts-1) {
            if(DEBUG) { 
                int k = 0;
                for(k=0;k<j;k++)
                    printf("%c",s[i+k]);
                printf("\n");
            }
            return i;
        } else {
            i += j - 1 - h[j-1];
            if(DEBUG) printf("Advance :%d\n",j-1-h[j-1]);
        }
    }

    return -1;
}
TEST_F(PointerCalcTests, rename_field) {
  auto t = createTable(table_7);
  auto res = PointerCalculator::create(t);
  ASSERT_EQ(t->nameOfColumn(0), res->nameOfColumn(0));
  res->rename(0, "NoMobile");
  ASSERT_EQ("NoMobile", res->nameOfColumn(0));
}
Exemple #23
0
int runSQLite(int clientSelect)
{
    clientNumber=clientSelect;
	sqlite3 *db = NULL;
	int rc;
	//打开指定的数据库文件
	rc = sqlite3_open("./data/DataBase.db",&db);
	if(rc)
	{
		fprintf(stderr,"can't open database: %s\n",sqlite3_errmsg(db));
		sqlite3_close(db);
		exit(1);
	}
	else
		printf("You have opened a sqlite3 database successfully!\n");
	//创建表
	createTable(db);
	//插入记录
	insertRecord(db);
	//查询
	//使用sqlite3_get_table实现查询
	//inquire_nocb(db);
	printf("--------------------------------\n");
	//使用回调函数实现查询
	inquire_Usecb(db);
	//删除记录
	//deleteRecord(db);
	//关闭数据库
	sqlite3_close(db);
	return 0;
}
Exemple #24
0
void eGTable::sectionRead(const __u8 *d)
{
	unsigned int last_section_number = d[7];
	m_table.flags &= ~eDVBTableSpec::tfAnyVersion;
	m_table.flags |= eDVBTableSpec::tfThisVersion;
	m_table.version = (d[5]>>1)&0x1F;

		/* if a section is missing, we retry reading the
		   whole data up to 5 times. if after that the
		   section is still missing, we timeout. */
	if (m_tries > 5 * (last_section_number+1))
	{
		timeout();
		return;
	}
	
	m_tries++;

	if (createTable(d[6], d, last_section_number + 1))
	{
		if (m_timeout)
			m_timeout->stop();
		if (m_reader)
		{
			m_reader->stop();
			m_reader=0;
		}
		m_sectionRead_conn=0;
		ready = 1;
		tableReady(error);
	} else if ((m_table.flags & eDVBTableSpec::tfHaveTimeout) && m_timeout)
		m_timeout->start(m_table.timeout, 1); // reset timeout
}
// ************************************************************ 
void
testCreateTableAndInsert (void)
{
  RM_TableData *table = (RM_TableData *) malloc(sizeof(RM_TableData));
  TestRecord inserts[] = { 
    {1, "aaaa", 3}, 
    {2, "bbbb", 2},
    {3, "cccc", 1},
    {4, "dddd", 3},
    {5, "eeee", 5},
    {6, "ffff", 1},
    {7, "gggg", 3},
    {8, "hhhh", 3},
    {9, "iiii", 2}
  };
  int numInserts = 9, i;
  Record *r;
  RID *rids;
  Schema *schema;
  testName = "test creating a new table and inserting tuples";
  schema = testSchema();
  rids = (RID *) malloc(sizeof(RID) * numInserts);
  
  TEST_CHECK(initRecordManager(NULL));
  //printf("\n Testing create table");
  TEST_CHECK(createTable("test_table_r.txt",schema));
  //printf("\n Testing open Table");
  TEST_CHECK(openTable(table, "test_table_r.txt"));
 printf("\n Opened "); 
  // insert rows into table
   for(i = 0; i < numInserts; i++)
    {
    	printf("\n Inserting");
      r = fromTestRecord(schema, inserts[i]);
      	
      TEST_CHECK(insertRecord(table,r)); 
      rids[i] = r->id;
    }

 TEST_CHECK(closeTable(table));
  TEST_CHECK(openTable(table, "test_table_r.txt"));
	printf("\n Opened successsfully");
  // randomly retrieve records from the table and compare to inserted ones
  for(i = 0; i < 1000; i++)
    {
      int pos = rand() % numInserts;
      RID rid = rids[pos];
      printf("\n getting records");
      TEST_CHECK(getRecord(table, rid, r));
      ASSERT_EQUALS_RECORDS(fromTestRecord(schema, inserts[pos]), r, schema, "compare records");
    }
  
  TEST_CHECK(closeTable(table));
  TEST_CHECK(deleteTable("test_table_r.txt"));
  TEST_CHECK(shutdownRecordManager());

  free(rids);
  free(table);
  TEST_DONE();
}
void CCassandraLogAgent::ensureTransSeedTable()
{
    //Create transaction seed table as needed
    StringBuffer transSeedTableKeys;
    StringArray transSeedTableColumnNames, transSeedTableColumnTypes;
    transSeedTableColumnNames.append("id");
    transSeedTableColumnTypes.append("int");
    transSeedTableColumnNames.append("application");
    transSeedTableColumnTypes.append("varchar");
    transSeedTableKeys.set("application"); //primary keys

    //The defaultDB has transactions table.
    setSessionOptions(defaultDB.str());
    cassSession->connect();
    createTable(defaultDB.str(), transactionTable.str(), transSeedTableColumnNames, transSeedTableColumnTypes, transSeedTableKeys.str());

    unsigned id = 0;
    VStringBuffer st("SELECT id FROM %s LIMIT 1;", transactionTable.str());
    if (!executeSimpleSelectStatement(st.str(), id))
    {
        st.setf("INSERT INTO %s (id, application) values ( 10000, '%s');",
                transactionTable.str(), loggingTransactionApp.get());
        executeSimpleStatement(st.str());

        if (!strieq(defaultTransactionApp.get(), loggingTransactionApp.get()))
        {
            st.setf("INSERT INTO %s (id, application) values ( 10000, '%s');",
                    transactionTable.str(), defaultTransactionApp.get());
            executeSimpleStatement(st.str());
        }
    }
    cassSession->disconnect();
}
// ------------------------------------------------------------------------
void DicomParser::setUpDisplay()
{

	parseDicom();
	loadImages();


	QWidget * w1 = new QWidget(this);
	QHBoxLayout * l1 = new QHBoxLayout;
	l1->addWidget(createTable());
	l1->addWidget(createViewer());
	w1->setLayout(l1);
	

	
	okButton = new QPushButton("OK", this);
	connect(okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
	
	cancelButton = new QPushButton("Cancel", this);
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelPressed()));

	QHBoxLayout * l2 = new QHBoxLayout;
	l2->addWidget(cancelButton);
	l2->addWidget(okButton);

	QWidget * w2 = new QWidget(this);
	w2->setLayout(l2);

	QVBoxLayout * l3 = new QVBoxLayout;
	l3->addWidget(w1);
	l3->addWidget(w2);

	this->setLayout(l3);

}
Exemple #28
0
/* *
* init function creates database with specified name and makes a connection
* which is stored in private variable mysqlpp::Connection connection_
*
* Second phase is to parse given file and store found data: nodes, lines, surfaces and recorded data
* into that database.
*
*/
bool DatabaseStorage::init(const string& file)
{
    if (file.empty())
    {
        std::cerr << "DatabaseStorage::init --\n";
        std::cerr << "File: is empty\n";
        return false;
    }

    // TODO: repository? argument "file" is not needed.
    string repository = Oi::stripToFileName(file);
    if (repository.empty())
    {
        std::cerr << "DatabaseStorage::init --\n";
        std::cerr << "Bad file name: " << file << "\n";
        return false;
    }

    mysqlpp::Connection con;

    // noexception is needed not to throw exception when such database exist.
    mysqlpp::NoExceptions ne(con);

    // try to create database and table
    if (!connectToDatabase(con))
    {
        std::cout << "Database: " << DATABASE << " do not exist. Creating new one!\n";
        if (!con.create_db(DATABASE))
        {
            std::cerr << "Error creating database: " << con.error() << std::endl;
            return false;
        }
        if(!createTable())
        {
            std::cerr << "Error creating table: Store.\n";
            return false;
        }
    }



    if (!existTable())
        createTable();

    return true;
}
DetailTitleMgrView::DetailTitleMgrView(QWidget *parent)
	: TableView(parent)
{
	setViewId(DetailTitleView);
	setTabName(QString::fromLocal8Bit("详细科目管理"));

	createTable();
}
Exemple #30
0
void SitesView::setupModel(QString& whereQryPart)
{
	QSqlDatabase db = Database::database();
	model = new QSqlQueryModel(this);
	model->setQuery(QString("SELECT site_name, url FROM sites %1").arg(whereQryPart), db);
	createTable();

}