本文整理汇总了C++中Constraint::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Constraint::GetType方法的具体用法?C++ Constraint::GetType怎么用?C++ Constraint::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constraint
的用法示例。
在下文中一共展示了Constraint::GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCreateTableSql
wxString MySqlDbAdapter::GetCreateTableSql(Table* tab, bool dropTable)
{
//TODO:SQL:
wxString str = wxT("");
if (dropTable) str = wxString::Format(wxT("SET FOREIGN_KEY_CHECKS = 0;\nDROP TABLE IF EXISTS `%s` ;\nSET FOREIGN_KEY_CHECKS = 1; \n"),tab->GetName().c_str());
str.append(wxString::Format(wxT("CREATE TABLE `%s` (\n"),tab->GetName().c_str()));
SerializableList::compatibility_iterator node = tab->GetFirstChildNode();
while( node ) {
Column* col = NULL;
if( node->GetData()->IsKindOf( CLASSINFO(Column)) ) col = (Column*) node->GetData();
if(col) str.append(wxString::Format(wxT("\t`%s` %s"),col->GetName().c_str(), col->GetType()->ReturnSql().c_str()));
Constraint* constr = wxDynamicCast(node->GetData(),Constraint);
if (constr) {
if (constr->GetType() == Constraint::primaryKey) str.append(wxString::Format(wxT("\tPRIMARY KEY (`%s`) \n"), constr->GetLocalColumn().c_str()));
}
node = node->GetNext();
if (node) {
if (wxDynamicCast(node->GetData(),Column)) str.append(wxT(",\n ")) ;
else if ((constr = wxDynamicCast(node->GetData(),Constraint))) {
if (constr->GetType() == Constraint::primaryKey) str.append(wxT(",\n ")) ;
}
}
//else str.append(wxT("\n ")) ;
}
/* Column* col = tab->GetFristColumn();
while (col) {
str.append(wxString::Format(wxT("\t`%s` %s"),col->getName().c_str(), col->getPType()->ReturnSql().c_str()));
col = wxDynamicCast(col->GetSibbling(),Column);
if (col) str.append(wxT(",\n ")) ;
else str.append(wxT("\n ")) ;
}*/
str.append(wxT("\n) ENGINE=INNODB;\n"));
str.append(wxT("-- -------------------------------------------------------------\n"));
return str;
}
示例2: GetConstraint
Constraint* TableSettings::GetConstraint(Constraint::constraintType type,const wxString& localcol)
{
for( SerializableList::iterator it = m_lstKeys.begin();
it != m_lstKeys.end(); ++it ) {
Constraint *c = wxDynamicCast( *it, Constraint );
if( c && c->GetType() == type && c->GetLocalColumn() == localcol ) return c;
}
return NULL;
}
示例3: GetAlterTableConstraintSql
wxString MySqlDbAdapter::GetAlterTableConstraintSql(Table* tab)
{
//TODO:SQL:
wxString str = wxString::Format(wxT("-- ---------- CONSTRAINTS FOR TABLE `%s` \n"),tab->GetName().c_str());
str.append(wxT("-- -------------------------------------------------------------\n"));
wxString prefix = wxString::Format(wxT("ALTER TABLE `%s` "),tab->GetName().c_str());
SerializableList::compatibility_iterator node = tab->GetFirstChildNode();
while( node ) {
Constraint* constr = NULL;
constr = wxDynamicCast(node->GetData(), Constraint);
if (constr) {
if (constr->GetType() == Constraint::foreignKey) {
str.append(prefix + wxString::Format(wxT("ADD CONSTRAINT `%s` FOREIGN KEY (`%s`) REFERENCES `%s`(`%s`) " ), constr->GetName().c_str(), constr->GetLocalColumn().c_str(), constr->GetRefTable().c_str(), constr->GetRefCol().c_str()));
str.append(wxT("ON UPDATE "));
switch(constr->GetOnUpdate()) {
case Constraint::restrict:
str.append(wxT("RESTRICT "));
break;
case Constraint::cascade:
str.append(wxT("CASCADE "));
break;
case Constraint::setNull:
str.append(wxT("SET NULL "));
break;
case Constraint::noAction:
str.append(wxT("NO ACTION "));
break;
}
str.append(wxT("ON DELETE "));
switch(constr->GetOnDelete()) {
case Constraint::restrict:
str.append(wxT("RESTRICT "));
break;
case Constraint::cascade:
str.append(wxT("CASCADE "));
break;
case Constraint::setNull:
str.append(wxT("SET NULL "));
break;
case Constraint::noAction:
str.append(wxT("NO ACTION "));
break;
}
str.append(wxT("; \n"));
}
}//if (constr->GetType() == Constraint::primaryKey) str.append(prefix + wxString::Format(wxT("ADD CONSTRAINT `%s` PRIMARY KEY (`%s`); \n"), constr->GetName().c_str(), constr->GetLocalColumn().c_str()));
node = node->GetNext();
}
str.append(wxT("-- -------------------------------------------------------------\n"));
return str;
}
示例4: IsPrimaryKey
bool TableSettings::IsPrimaryKey(const wxString& colname)
{
for( SerializableList::iterator it = m_lstKeys.begin();
it != m_lstKeys.end(); ++it ) {
Constraint *c = wxDynamicCast( *it, Constraint );
if( c && ( c->GetType() == Constraint::primaryKey )
&& ( c->GetLocalColumn() == colname ) ) return true;
}
return false;
}
示例5: FillKeys
void TableSettings::FillKeys()
{
wxVector<wxVariant> line;
m_dvKeys->DeleteAllItems();
for( SerializableList::iterator it = m_lstKeys.begin();
it != m_lstKeys.end(); ++it ) {
Constraint *c = wxDynamicCast( *it, Constraint );
if( c && c->GetType() == Constraint::foreignKey ) {
line.clear();
line.push_back( wxVariant( c->GetName() ) );
m_dvKeys->AppendItem( line, reinterpret_cast<wxUIntPtr>(c) );
}
}
}
示例6: OnColumnChanged
void TableSettings::OnColumnChanged(wxDataViewEvent& event)
{
Column *col = reinterpret_cast<Column*>(m_dvColumns->GetItemData( event.GetItem() ) );
if( col ) {
wxVariant val;
event.GetModel()->GetValue( val, event.GetItem(), event.GetColumn() );
if( ! val.IsNull() ) {
switch( event.GetColumn() ) {
case 0: {
// rename local columns in keys
SerializableList keys;
GetConstraints( keys, col->GetName() );
for(SerializableList::iterator it = keys.begin(); it != keys.end(); ++it ) {
Constraint *key = (Constraint*) *it;
if( key->GetType() == Constraint::primaryKey ) key->SetName( wxT("PK_") + val.GetString() );
key->SetLocalColumn( val.GetString() );
}
// rename table column
col->SetName( val.GetString() );
break;
}
case 1: {
col->SetType( m_pDbAdapter->GetDbTypeByName( val.GetString() ) );
break;
}
case 2: {
long s1, s2;
s1 = s2 = 0;
wxSscanf( val.GetString(), wxT("%ld,%ld"), &s1, &s2 );
IDbType *type = col->GetType();
if( type->HaveSize() ) type->SetSize( s1 );
else {
m_infobar->ShowMessage( wxT("This data type doesn't support size definition."), wxICON_WARNING );
Refresh();
}
if( type->HaveSize2() ) type->SetSize2( s1 );
else {
m_infobar->ShowMessage( wxT("This data type doesn't support size definition."), wxICON_WARNING );
Refresh();
}
break;
}
case 3: {
IDbType *type = col->GetType();
if( type->HaveNotNull() ) type->SetNotNull( val.GetBool() );
else {
m_infobar->ShowMessage( wxT("This data type doesn't support NOT NULL feature."), wxICON_WARNING );
Refresh();
}
break;
}
case 4: {
IDbType *type = col->GetType();
if( type->HaveAutoIncrement() ) type->SetAutoIncrement( val.GetBool() );
else {
m_infobar->ShowMessage( wxT("This data type doesn't support AUTOINCREMENT feature."), wxICON_WARNING );
Refresh();
}
break;
}
case 5: {
Constraint *key = GetConstraint( Constraint::primaryKey, col->GetName() );
if( key ) {
// remove primary key if exists
m_lstKeys.DeleteObject( key );
delete key;
} else {
// create new primary key
key = new Constraint( wxT("PK_") + col->GetName(),
col->GetName(),
Constraint::primaryKey,
Constraint::noAction,
Constraint::noAction );
m_lstKeys.Append( key );
}
break;
}
}
}
}
event.Skip();
UpdateView();
}
示例7: GenerateFile
bool ClassGenerateDialog::GenerateFile(Table* pTab, wxTextFile& htmpFile, wxString& hFile, const wxString& classItemName, const wxString& classItemDef, const wxString& classColName, const wxString& classTableName, const wxString& classUtilName)
{
Constraint* pPK = NULL;
int colCount = 0;
int lastEditParam = 0;
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Constraint* pConstr = wxDynamicCast(node->GetData(),Constraint);
if (pConstr) {
if (pConstr->GetType() == Constraint::primaryKey) pPK = pConstr;
} else colCount++;
node = node->GetNext();
}
Column* pPKCol = NULL;
if (pPK) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
if (pCol->GetName() == pPK->GetLocalColumn()) pPKCol = pCol;
}
node = node->GetNext();
}
}
if( (pPKCol == NULL) && (pTab->IsView() == false) ) {
m_textLog->AppendText( wxString::Format( _("Table %s has no primary key defined!\n"), pTab->GetName().c_str() ) );
return false;
}
for ( wxString str = htmpFile.GetFirstLine(); !htmpFile.Eof(); str = htmpFile.GetNextLine() ) {
if (str.Contains(wxT("%%classItemGetters%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << wxString::Format(wxT("\tconst %s Get%s() const {"), GetResTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
hFile << wxString::Format(wxT("\t\treturn m_%s;"), pCol->GetName().c_str()) << "\n";
hFile << wxString::Format(wxT("\t\t}")) << "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemVariables%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << wxString::Format(wxT("\t%s m_%s;"), GetTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str())<< "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemLoading%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << wxString::Format(wxT("\t\tm_%s = pResult->%s(wxT(\"%s\"));"),pCol->GetName().c_str(), GetResultFunction(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemBindings%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << GetDebeaBinding(pCol) << "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemAddParameters%%"))) {
bool first = true;
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
if( first ) {
hFile << wxString::Format(wxT("\t\t\t%s %s"), GetParamTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
first = false;
} else {
hFile << wxString::Format(wxT("\t\t\t,%s %s"), GetParamTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
}
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemSetParams%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol ) {
hFile << wxT("\tm_") + pCol->GetName() + wxT(" = ") + pCol->GetName() + wxT(";") << "\n";
}
node = node->GetNext();
}
//.........这里部分代码省略.........