Int_t foam_demopers() { gSystem->Load("libFoam"); // need to load the foam_demo tutorial for the definition of the function TString macroName = gSystem->UnixPathName(__FILE__); macroName.ReplaceAll("foam_demopers.C","foam_demo.C"); gROOT->ProcessLine(TString::Format(".L %s+",macroName.Data())); //****************************************** cout<<"====================== TestVector ================================"<<endl; TFile fileA("foam_demo.root"); fileA.cd(); cout<<"------------------------------------------------------------------"<<endl; fileA.ls(); cout<<"------------------------------------------------------------------"<<endl; fileA.Map(); cout<<"------------------------------------------------------------------"<<endl; fileA.ShowStreamerInfo(); cout<<"------------------------------------------------------------------"<<endl; fileA.GetListOfKeys()->Print(); cout<<"------------------------------------------------------------------"<<endl; //******************************************* TFoam *FoamX = (TFoam*)fileA.Get("FoamX"); //******************************************* // FoamX->PrintCells(); FoamX->CheckAll(1); //N.B. the integrand functions need to be reset // because cannot be made persistent #ifdef __CINT__ // this can be done only in CINT TFoamIntegrand *rho= new TFDISTR(); #else // this should be done with AClic or Cling TFoamIntegrand * rho = (TFoamIntegrand*) gROOT->ProcessLine("return new TFDISTR();"); #endif FoamX->SetRho(rho); Double_t *MCvect =new Double_t[2]; // 2-dim vector generated in the MC run for(long loop=0; loop<50000; loop++){ FoamX->MakeEvent(); // generate MC event FoamX->GetMCvect( MCvect); // get generated vector (x,y) Double_t x=MCvect[0]; Double_t y=MCvect[1]; if(loop<10) cout<<"(x,y) = ( "<< x <<", "<< y <<" )"<<endl; }// loop // Double_t IntNorm, Errel; FoamX->Finalize( IntNorm, Errel); // final printout Double_t MCresult, MCerror; FoamX->GetIntegMC( MCresult, MCerror); // get MC integral, should be one cout << " MCresult= " << MCresult << " +- " << MCerror <<endl; cout<<"===================== TestPers FINISHED ======================="<<endl; return 0; }
TEST_F(TableMergerTest, MergeFileOverlay) { ResourceTable finalTable; TableMergerOptions tableMergerOptions; tableMergerOptions.autoAddOverlay = false; TableMerger merger(mContext.get(), &finalTable, tableMergerOptions); ResourceFile fileDesc; fileDesc.name = test::parseNameOrDie(u"@xml/foo"); test::TestFile fileA("path/to/fileA.xml.flat"); test::TestFile fileB("path/to/fileB.xml.flat"); ASSERT_TRUE(merger.mergeFile(fileDesc, &fileA)); ASSERT_TRUE(merger.mergeFileOverlay(fileDesc, &fileB)); }
Model::Model(ImageProvider* ip): m_showkeyboard(true), m_contactsModel(NULL), m_applistModel(NULL), m_error(""), m_searchString(""), m_modelsready(false), m_searchresults(new QList<AppEntry>()), m_ip(ip), m_clearresults(false), iCallDialer(NULL) { LS("Model::Model =>>"); QHash<int, QByteArray> roles; roles[0] = "title"; roles[1] = "uid"; roles[2] = "iscontact"; setRoleNames(roles); roles.clear(); QFile fileA( NOTHING ); if(!fileA.exists()) m_applistModel = new applistModel(this); fileA.close(); QFile file( ONLYAPPS ); if(!file.exists()) m_contactsModel = new contactsModel(this); file.close(); if(m_applistModel) { QObject::connect(m_applistModel, SIGNAL(modelReady()), this, SLOT(modelReadyHandle())); QObject::connect(m_applistModel, SIGNAL(HandleSearchResults(QString,QList<AppEntry>&,int,bool)), this, SLOT(HandleSearchComplete(QString,QList<AppEntry>&,int,bool))); } if(m_contactsModel) { QObject::connect(m_contactsModel, SIGNAL(modelReady()), this, SLOT(modelReadyHandle())); QObject::connect(m_contactsModel, SIGNAL(HandleSearchResults(QString,QList<AppEntry>&,int,bool)), this, SLOT(HandleSearchComplete(QString,QList<AppEntry>&,int,bool))); } if(m_contactsModel == NULL && m_applistModel == NULL) modelReadyHandle(); LS("Model::Model <<"); }
int main(int argc, char *argv[]) { QString title; title = title + "********************************************************************* \n"; title = title + " * Compare Insert XML 1.0 * \n"; title = title + " * This tool compares two insert XML files (A and B) for incremental * \n"; title = title + " * changes. * \n"; title = title + " * * \n"; title = title + " * The tool informs of lookup values in A that are not in B. * \n"; title = title + " * The tool can also create a combined file C that appends * \n"; title = title + " * not found values. * \n"; title = title + " * * \n"; title = title + " * Nomenclature: * \n"; title = title + " * TNF: Lookup table not found. * \n"; title = title + " * VNF: Value not found. * \n"; title = title + " * VNS: The values is not the same. * \n"; title = title + " * * \n"; title = title + " * This tool is usefull when dealing with multiple versions of an * \n"; title = title + " * ODK survey that must be combined in one common database. * \n"; title = title + " * * \n"; title = title + " * This tool is part of ODK Tools (c) ILRI-RMG, 2015 * \n"; title = title + " * Author: Carlos Quiros ([email protected] / [email protected]) * \n"; title = title + " ********************************************************************* \n"; TCLAP::CmdLine cmd(title.toUtf8().constData(), ' ', "1.0"); TCLAP::ValueArg<std::string> aArg("a","inputa","Input insert XML file A",true,"","string"); TCLAP::ValueArg<std::string> bArg("b","inputb","Input insert XML file B",true,"","string"); TCLAP::ValueArg<std::string> cArg("c","outputc","Output insert XML file C",false,"./combined-insert.xml","string"); cmd.add(aArg); cmd.add(bArg); cmd.add(cArg); //Parsing the command lines cmd.parse( argc, argv ); //Getting the variables from the command QString inputA = QString::fromUtf8(aArg.getValue().c_str()); QString inputB = QString::fromUtf8(bArg.getValue().c_str()); QString outputC = QString::fromUtf8(cArg.getValue().c_str()); if (inputA != inputB) { if ((QFile::exists(inputA)) && (QFile::exists(inputB))) { //Openning and parsing input file A QDomDocument docA("inputA"); QFile fileA(inputA); if (!fileA.open(QIODevice::ReadOnly)) { log("Cannot open input file A"); return 1; } if (!docA.setContent(&fileA)) { log("Cannot parse document for input file A"); fileA.close(); return 1; } fileA.close(); //Openning and parsing input file B QDomDocument docB("inputB"); QFile fileB(inputB); if (!fileB.open(QIODevice::ReadOnly)) { log("Cannot open input file B"); return 1; } if (!docB.setContent(&fileB)) { log("Cannot parse document for input file B"); fileB.close(); return 1; } fileB.close(); QDomElement rootA = docA.documentElement(); QDomElement rootB = docB.documentElement(); if ((rootA.tagName() == "insertValuesXML") && (rootB.tagName() == "insertValuesXML")) { //Comparing lookup tables if ((!rootA.firstChild().isNull()) && (!rootB.firstChild().isNull())) qDebug() << "Comparing lookup tables"; compareLKPTables(rootA.firstChild(),docB); //Create the manifext file. If exist it get overwriten if (QFile::exists(outputC)) QFile::remove(outputC); QFile file(outputC); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream out(&file); out.setCodec("UTF-8"); docB.save(out,1,QDomNode::EncodingFromTextStream); file.close(); } else log("Error: Cannot create XML combined file"); } else { if (!(rootA.tagName() == "ODKImportXML")) { log("Input document A is not a insert XML file"); return 1; } if (!(rootB.tagName() == "ODKImportXML")) { log("Input document B is not a insert XML file"); return 1; } } } else { if (!QFile::exists(inputA)) { log("Input file A does not exists"); return 1; } if (!QFile::exists(inputB)) { log("Input file B does not exists"); return 1; } } } else { log("Input files A and B are the same. No point in comparing them."); return 1; } return 0; }
int main(int argc, char *argv[]) { QString title; title = title + "********************************************************************* \n"; title = title + " * Create from XML * \n"; title = title + " * This tool create a SQL DDL script file from a XML schema file * \n"; title = title + " * created by ODKToMySQL. * \n"; title = title + " * * \n"; title = title + " * This tool is usefull when dealing with multiple versions of an * \n"; title = title + " * ODK survey that were combined into a common XML schema using * \n"; title = title + " * compareCreateXML. * \n"; title = title + " * * \n"; title = title + " * This tool is part of ODK Tools (c) ILRI-RMG, 2015 * \n"; title = title + " * Author: Carlos Quiros ([email protected] / [email protected]) * \n"; title = title + " ********************************************************************* \n"; TCLAP::CmdLine cmd(title.toUtf8().constData(), ' ', "1.0"); TCLAP::ValueArg<std::string> inputArg("i","input","Input create XML file",true,"","string"); TCLAP::ValueArg<std::string> outputArg("o","output","Output SQL file",false,"./create.sql","string"); cmd.add(inputArg); cmd.add(outputArg); //Parsing the command lines cmd.parse( argc, argv ); //Getting the variables from the command QString input = QString::fromUtf8(inputArg.getValue().c_str()); QString output = QString::fromUtf8(outputArg.getValue().c_str()); idx = 0; if (input != output) { if (QFile::exists(input)) { //Openning and parsing input file A QDomDocument docA("input"); QFile fileA(input); if (!fileA.open(QIODevice::ReadOnly)) { log("Cannot open input file"); return 1; } if (!docA.setContent(&fileA)) { log("Cannot parse input file"); fileA.close(); return 1; } fileA.close(); QDomElement rootA = docA.documentElement(); if (rootA.tagName() == "XMLSchemaStructure") { QFile file(output); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { log("Cannot create output file"); return 1; } QDateTime date; date = QDateTime::currentDateTime(); QTextStream out(&file); out << "-- Code generated by createFromXML" << "\n"; out << "-- Created: " + date.toString("ddd MMMM d yyyy h:m:s ap") << "\n"; out << "-- by: createFromXML Version 1.0" << "\n"; out << "-- WARNING! All changes made in this file might be lost when running createFromXML again" << "\n\n"; QDomNode lkpTables = docA.documentElement().firstChild(); QDomNode tables = docA.documentElement().firstChild().nextSibling(); if (!lkpTables.isNull()) { procLKPTables(lkpTables.firstChild(),out); } if (!tables.isNull()) { procTables(tables.firstChild(),out); } } else { log("Input document is not a XML create file"); return 1; } } else { log("Input file does not exists"); return 1; } } else { log("Fatal: Input files and output file are the same."); return 1; } return 0; }