int main(int argc, char *argv[]) { QString title; title = title + "****************************************************************** \n"; title = title + " * MySQLtoFile 1.0 * \n"; title = title + " * This tool exports a table in a MySQL schema to various file * \n"; title = title + " * formats like STATA, SPSS, CSV (tab delimited), JSON and XML * \n"; title = title + " * This tool is part of CSPro Tools (c) ILRI, 2013 * \n"; title = title + " ****************************************************************** \n"; TCLAP::CmdLine cmd(title.toAscii().data(), ' ', "1.0 (Beta 1)"); //Required arguments TCLAP::ValueArg<std::string> hostArg("H","host","MySQL host. Default localhost",false,"localhost","string"); TCLAP::ValueArg<std::string> portArg("P","port","MySQL port. Default 3306.",false,"3306","string"); TCLAP::ValueArg<std::string> userArg("u","user","User to connect to MySQL",true,"","string"); TCLAP::ValueArg<std::string> passArg("p","password","Password to connect to MySQL",true,"","string"); TCLAP::ValueArg<std::string> schemaArg("s","schema","Schema in MySQL",true,"","string"); TCLAP::ValueArg<std::string> auditArg("a","audit","Target directory for the audit files. Default ./audit (created if not exists)",false,"./audit","string"); TCLAP::SwitchArg createSwitch("c","create","Create META dictionary tables", cmd, false); TCLAP::SwitchArg loadSwitch("l","load","Load META dictionary tables", cmd, false); TCLAP::SwitchArg deleteSwitch("d","delete","Delete previous data before load", cmd, false); TCLAP::SwitchArg viewSwitch("v","views","Include views in dictionary tables", cmd, false); cmd.add(hostArg); cmd.add(portArg); cmd.add(userArg); cmd.add(passArg); cmd.add(schemaArg); cmd.add(auditArg); cmd.parse( argc, argv ); //Getting the variables from the command bool createMETA; bool loadMETA; bool deldata; bool includeViews; createMETA = createSwitch.getValue(); loadMETA = loadSwitch.getValue(); deldata = deleteSwitch.getValue(); includeViews = viewSwitch.getValue(); QString host = QString::fromUtf8(hostArg.getValue().c_str()); QString port = QString::fromUtf8(portArg.getValue().c_str()); QString user = QString::fromUtf8(userArg.getValue().c_str()); QString pass = QString::fromUtf8(passArg.getValue().c_str()); QString schema = QString::fromUtf8(schemaArg.getValue().c_str()); QString auditPath = QString::fromUtf8(auditArg.getValue().c_str()); //Dictionary tables ignoreTables << "dict_grpinfo"; ignoreTables << "dict_tblinfo"; ignoreTables << "dict_clminfo"; ignoreTables << "dict_relinfo"; ignoreTables << "dict_childinfo"; ignoreTables << "audit_log"; //Authorisation tables Not used since 2015-03-19. Backward compatibility ignoreTables << "auth_group"; ignoreTables << "auth_group_permissions"; ignoreTables << "auth_permission"; ignoreTables << "auth_user"; ignoreTables << "auth_user_groups"; ignoreTables << "auth_user_user_permissions"; ignoreTables << "user_log"; //Django tables Not used since 2014. Backward compatibility ignoreTables << "auth_message"; ignoreTables << "django_admin_log"; ignoreTables << "django_content_type"; ignoreTables << "django_session"; ignoreTables << "django_site"; //I18N tables ignoreTables << "dict_iso639"; ignoreTables << "dict_lkpiso639"; ignoreTables << "dict_dctiso639"; { QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName(host); db.setPort(port.toInt()); db.setDatabaseName(schema); db.setUserName(user); db.setPassword(pass); bool METACreated; METACreated = false; bool METALoaded; METALoaded = false; bool deletePrevious; deletePrevious = false; QString data; if (db.open()) { getTableOrder(db); if (createMETA) { log("Are you sure that you want to create META's tables? This will delete any previous META information INCLUDING the audit. (Y/N): ",false); QTextStream createIn(stdin); data = createIn.readLine(); if (data.toUpper().simplified() == "Y") { if (createMETATables(db) == 0) METACreated = true; else return 1; } } if (loadMETA) { if (deldata && !createMETA) { log("Are you sure that you want to delete any previous META's data? This WILL NOT delete the audit. (Y/N): ",false); QTextStream deleteIn(stdin); data = deleteIn.readLine(); if (data.toUpper().simplified() == "Y") { deletePrevious = true; } } if (loadMETATables(db,deletePrevious,includeViews) == 0) METALoaded = true; else return 1; } createMETAAudit(db,auditPath); if (METACreated && !METALoaded) { log("META was created but not information was loaded. Use initmeta -l to load METAS's information"); } } else { log("Cannot connect to database"); log(db.lastError().databaseText()); return 1; } } return 0; }
void ECKeyPad::initPins( unsigned numCols ) { if ( numCols < 3 ) numCols = 3; else if ( numCols > 9 ) numCols = 9; if ( numCols == m_numCols ) return; int w = sideLength(numCols); int h = sideLength(4); setSize( -int(w/16)*8, -int(h/16)*8, w, h, true ); if ( numCols > m_numCols ) { // Adding columns for ( unsigned i = 0; i < 4; i++ ) { for ( unsigned j = m_numCols; j < numCols; j++ ) addButton( buttonID(i,j), QRect( 0, 0, 20, 20 ), text[i][j] ); } ECNode * cols[9]; for ( unsigned j = m_numCols; j < numCols; j++ ) cols[j] = createPin( 0, 64, 270, "col_" + QString::number(j) ); for ( unsigned i = 0; i < 4; i++ ) { ECNode * row = ecNodeWithID("row_"+QString::number(i)); for ( unsigned j = m_numCols; j < numCols; j++ ) m_switch[i][j] = createSwitch( cols[j], row, true ); } } else { // Remove columns for ( unsigned i = 0; i < 4; i++ ) { for ( unsigned j = numCols; j < m_numCols; j++ ) removeWidget( buttonID(i,j) ); } for ( unsigned j = numCols; j < m_numCols; j++ ) removeNode( "col_" + QString::number(j) ); for ( unsigned i = 0; i < 4; i++ ) { for ( unsigned j = m_numCols; j < numCols; j++ ) removeSwitch( m_switch[i][j] ); } } //BEGIN Update Positions m_numCols = numCols; for ( int i = 0; i < 4; i++ ) { for ( int j = 0; j < int(m_numCols); j++ ) { widgetWithID( buttonID(i,j) )->setOriginalRect( QRect( offsetX() + 6 + 24*j, offsetY() + 6 + 24*i, 20, 20 ) ); } } for ( int i = 0; i < 4; i++ ) m_nodeMap["row_" + QString::number(i)].x = width()+offsetX(); for ( int j = 0; j < int(m_numCols); j++ ) m_nodeMap["col_" + QString::number(j)].x = 24*j+offsetX()+16; updateAttachedPositioning(); //END Update Positions }
void *NclPresentationControlParser::parseSwitch( DOMElement *parentElement, void *objGrandParent) { void *parentObject; DOMNodeList *elementNodeList; int i, size; DOMNode *node; DOMElement *element; string elementTagName; void *elementObject; parentObject = createSwitch(parentElement, objGrandParent); if (parentObject == NULL) { return NULL; } elementNodeList = parentElement->getChildNodes(); size = elementNodeList->getLength(); for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE) { element = (DOMElement*)node; elementTagName = XMLString::transcode(element->getTagName()); if (XMLString::compareIString(elementTagName.c_str(), "media") == 0) { elementObject = ((NclComponentsParser*) getComponentsParser())->parseMedia( element, parentObject); if (elementObject != NULL) { addMediaToSwitch(parentObject, elementObject); } } else if (XMLString::compareIString(elementTagName.c_str(), "context") == 0) { elementObject = ((NclComponentsParser*) getComponentsParser())->parseContext( element, parentObject); if (elementObject != NULL) { addContextToSwitch(parentObject, elementObject); } } else if (XMLString::compareIString(elementTagName.c_str(), "switch") == 0) { elementObject = parseSwitch(element, parentObject); if (elementObject != NULL) { addSwitchToSwitch(parentObject, elementObject); } } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType() == DOMNode::ELEMENT_NODE) { element = (DOMElement*)node; elementTagName = XMLString::transcode(element->getTagName()); if (XMLString::compareIString(elementTagName.c_str(), "bindRule") == 0) { elementObject = parseBindRule((DOMElement*)node, parentObject); if (elementObject != NULL) { addBindRuleToSwitch(parentObject, elementObject); } } else if (XMLString::compareIString(elementTagName.c_str(), "defaultComponent") == 0) { elementObject = parseDefaultComponent((DOMElement*)node, parentObject); if (elementObject != NULL) { addDefaultComponentToSwitch( parentObject, elementObject); } } } } return parentObject; }