Exemplo n.º 1
0
static void
init_table_generator(int t){
	
	num_table =  t;
	chains = 0 ;

	char name[80];
	name_table(name,t);

	create_hash_table3(&hash_table, name);
}
Exemplo n.º 2
0
// Create a new library database
bool CLibraryDb::Create(const TCHAR *filename)
{
	m_name = filename;

	// Now create the database
	try
	{
		if (m_database.IsOpen())
		{
			m_database.Close();
		}

		m_database.Create(m_name + ".mdb");
	} catch (CException *e)
	{
		CString s;
		CString msg;
		e->GetErrorMessage(msg.GetBuffer(256), 256, NULL);
		msg.ReleaseBuffer();
		s.Format(_T("Cannot create library %s.\r\n%s"), m_name, msg);
		AfxMessageBox(s);
		e->Delete();
		return false;
	}

	// .. and create the default tables
	try
	{
		/////////////////////// NAME TABLE /////////////////////// 

		CDaoTableDef name_table(&m_database);
		name_table.Create(_T("Name"));
		name_table.CreateField(_T("NameID"), dbLong, 0, dbAutoIncrField);
		name_table.CreateField(_T("Name"), dbText, 128);
		name_table.CreateField(_T("SymbolID"), dbLong, 0);
		name_table.CreateField(_T("Type"), dbLong, 0);
		name_table.CreateField(_T("Reference"), dbText, 255);
		name_table.CreateField(_T("ppp"), dbLong, 0);
		name_table.CreateField(_T("Description"), dbText, 255);
		name_table.CreateField(_T("ShowName"), dbLong, 0);
		name_table.CreateField(_T("ShowRef"), dbLong, 0);

		// Now create the primary key (what an effort!)
		CDaoIndexInfo name_index;
		CDaoIndexFieldInfo name_index_field;

		name_index_field.m_bDescending = FALSE;
		name_index_field.m_strName = _T("NameID");

		name_index.m_strName = _T("Name_PK");
		name_index.m_bPrimary = TRUE;
		name_index.m_pFieldInfos = &name_index_field;
		name_index.m_nFields = 1;
		name_index.m_bUnique = FALSE;
		name_index.m_bClustered = FALSE;
		name_index.m_bIgnoreNulls = FALSE;
		name_index.m_bRequired = FALSE;
		name_index.m_bForeign = FALSE;
		name_index.m_lDistinctCount = 0;

		name_table.CreateIndex(name_index);

		// Now add the table to the database..
		name_table.Append();

		/////////////////////// ATTRIBUTE TABLE ///////////////////////

		CDaoTableDef attr_table(&m_database);
		attr_table.Create(_T("Attribute"));
		attr_table.CreateField(_T("AttributeID"), dbLong, 0, dbAutoIncrField);
		attr_table.CreateField(_T("NameID"), dbLong, 0);
		attr_table.CreateField(_T("AttName"), dbText, 64);
		attr_table.CreateField(_T("AttValue"), dbMemo, 0); // Note: change to v2 of library!
		attr_table.CreateField(_T("ShowAtt"), dbLong, 0);

		// Now create the primary key (what an effort!)
		CDaoIndexInfo attr_index;
		CDaoIndexFieldInfo attr_index_field;

		attr_index_field.m_bDescending = FALSE;
		attr_index_field.m_strName = _T("AttributeID");

		attr_index.m_strName = "Attribute_PK";
		attr_index.m_bPrimary = TRUE;
		attr_index.m_pFieldInfos = &attr_index_field;
		attr_index.m_nFields = 1;
		attr_index.m_bUnique = FALSE;
		attr_index.m_bClustered = FALSE;
		attr_index.m_bIgnoreNulls = FALSE;
		attr_index.m_bRequired = FALSE;
		attr_index.m_bForeign = FALSE;
		attr_index.m_lDistinctCount = 0;

		attr_table.CreateIndex(attr_index);

		// Now add the table to the database..
		attr_table.Append();

		/////////////////////// SYMBOL TABLE ///////////////////////

		CDaoTableDef symbol_table(&m_database);
		symbol_table.Create(_T("Symbol"));
		symbol_table.CreateField(_T("SymbolID"), dbLong, 0, dbAutoIncrField);
		symbol_table.CreateField(_T("Data"), dbLongBinary, 0);
		symbol_table.CreateField(_T("DrawRotate"), dbLong, 0);
		symbol_table.CreateField(_T("DefRotate"), dbLong, 0);
		symbol_table.CreateField(_T("Type"), dbLong, 0);

		// Now create the primary key (what an effort!)
		CDaoIndexInfo symbol_index;
		CDaoIndexFieldInfo symbol_index_field;

		symbol_index_field.m_bDescending = FALSE;
		symbol_index_field.m_strName = "SymbolID";

		symbol_index.m_strName = "Symbol_PK";
		symbol_index.m_bPrimary = TRUE;
		symbol_index.m_pFieldInfos = &symbol_index_field;
		symbol_index.m_nFields = 1;
		symbol_index.m_bUnique = FALSE;
		symbol_index.m_bClustered = FALSE;
		symbol_index.m_bIgnoreNulls = FALSE;
		symbol_index.m_bRequired = FALSE;
		symbol_index.m_bForeign = FALSE;
		symbol_index.m_lDistinctCount = 0;

		symbol_table.CreateIndex(symbol_index);

		// Now add the table to the database..
		symbol_table.Append();

		/////////////////////// PROPERTY TABLE ///////////////////////

		CDaoTableDef prop_table(&m_database);
		prop_table.Create(_T("Property"));
		prop_table.CreateField(_T("PropertyID"), dbLong, 0, dbAutoIncrField);
		prop_table.CreateField(_T("Name"), dbText, 64);
		prop_table.CreateField(_T("Value"), dbText, 255);

		// Now create the primary key (what an effort!)
		CDaoIndexInfo prop_index;
		CDaoIndexFieldInfo prop_index_field;

		prop_index_field.m_bDescending = FALSE;
		prop_index_field.m_strName = _T("PropertyID");

		prop_index.m_strName = "Property_PK";
		prop_index.m_bPrimary = TRUE;
		prop_index.m_pFieldInfos = &prop_index_field;
		prop_index.m_nFields = 1;
		prop_index.m_bUnique = FALSE;
		prop_index.m_bClustered = FALSE;
		prop_index.m_bIgnoreNulls = FALSE;
		prop_index.m_bRequired = FALSE;
		prop_index.m_bForeign = FALSE;
		prop_index.m_lDistinctCount = 0;

		prop_table.CreateIndex(prop_index);

		// Now add the table to the database..
		prop_table.Append();

	} catch (CException *e)
	{
		CString s;
		CString msg;
		e->GetErrorMessage(msg.GetBuffer(256), 256, NULL);
		msg.ReleaseBuffer();
		s.Format(_T("Cannot create library %s.\r\n%s"), m_name, msg);
		AfxMessageBox(s);
		e->Delete();
		return false;
	}

	return true;
}