void insert(Node * p, char * c) { if (*c == NULL) p->terminal = true; else { if (p->childern[hf(*c)] == NULL) p->childern[hf(*c)] = new Node(*c); insert(p->childern[hf(*c)], c + 1); } }
void array_tests(T const& v) { boost::hash<typename T::value_type> hf; for(typename T::const_iterator i = v.begin(); i != v.end(); ++i) { for(typename T::const_iterator j = v.begin(); j != v.end(); ++j) { if (i != j) BOOST_TEST(hf(*i) != hf(*j)); else BOOST_TEST(hf(*i) == hf(*j)); } } }
void About::OnButtonTest(wxCommandEvent &event) { wxString InputName = ((wxTextCtrl *)FindWindow(ID_ABOUT_TESTNAME))->GetValue(); if (1|(InputName == wxT("Lucy"))) { // wxMessageBox(wxT("隐藏的功能被启动."), wxT("老邪淫_死呃")); HiddenFunc hf(m_parent); hf.ShowModal(); } else { DWORD dwAscii = 0; for(size_t ix = 0;ix != InputName.Len(); ++ix) { dwAscii += (DWORD)InputName.GetChar(ix); } dwAscii %= 40; wxMemoryInputStream mis(pimages[dwAscii].pimage, pimages[dwAscii].dwSize); wxImage image; image.LoadFile(mis); wxRect rect = FindWindow(ID_ABOUT_WHORU)->GetRect(); wxPoint point(rect.GetRight() - 150, rect.GetTop() + 15); if (TestResultImage) { TestResultImage->Destroy(); TestResultImage = NULL; } TestResultImage = new wxStaticBitmap(this, ID_ABOUT_TESTRESULT, wxBitmap(image), point, wxSize(image.GetWidth(), image.GetHeight())); // TestResultImage->Refresh(); } }
int main(int argc, char** argv) { ros::init(argc, argv, "robothw"); ros::NodeHandle nh("handsfree"); handsfree_hw::HF_HW_ros hf(nh, "serial:///dev/ttyUSB0", "~/config.txt"); hf.mainloop(); return 0; }
Node * find(Node * p, char * c) { if (*c == NULL) return p; else { Node * next = p->childern[hf(*c)]; if (next == NULL) return NULL; return find(next, c + 1); } }
bool OCSPClientCertID::compareToExist( const SecAsn1OCSPCertID &exist) { /* easy part */ if(!ocspdCompareCssmData(&mSubjectSerial, &exist.serialNumber)) { return false; } hashFcn hf = NULL; const CSSM_OID *alg = &exist.algId.algorithm; uint8 digest[OCSPD_MAX_DIGEST_LEN]; CSSM_DATA digestData = {0, digest}; if(ocspdCompareCssmData(alg, &CSSMOID_SHA1)) { hf = ocspdSha1; digestData.Length = CC_SHA1_DIGEST_LENGTH; } else if(ocspdCompareCssmData(alg, &CSSMOID_MD5)) { hf = ocspdMD5; digestData.Length = CC_MD5_DIGEST_LENGTH; } else if(ocspdCompareCssmData(alg, &CSSMOID_MD4)) { hf = ocspdMD4; digestData.Length = CC_MD4_DIGEST_LENGTH; } /* an OID for SHA256? */ else { return false; } /* generate digests using exist's hash algorithm */ hf(mIssuerName.Data, mIssuerName.Length, digest); if(!ocspdCompareCssmData(&digestData, &exist.issuerNameHash)) { return false; } hf(mIssuerPubKey.Data, mIssuerPubKey.Length, digest); if(!ocspdCompareCssmData(&digestData, &exist.issuerPubKeyHash)) { return false; } return true; }
gmVector3 CSGUnion::grad(const gmVector3 & x) { if ((m_f!=NULL) && (m_g!=NULL)) { double fx = m_f->proc(x); double gx = m_g->proc(x); return hf(fx,gx) * m_f->grad(x) + hg(fx,gx) * m_g->grad(x); } else return gmVector3(); }
static EString badFields( Header * h ) { EStringList bad; List<HeaderField>::Iterator hf( h->fields() ); while ( hf ) { if ( !hf->valid() ) bad.append( hf->unparsedValue() ); ++hf; } return bad.join( "\n" ); }
TEST(hub_test, engine_init){ gpf::hub_factory hf(5000); hf.ip("127.0.0.1").transport("tcp").hm_interval(100); boost::shared_ptr<gpf::hub> hub = hf.get(); zmq::context_t ctx(1); gpf::engine engine(ctx); engine.provide_service("test-service1"); engine.provide_service("test-service2"); schedule_reactor_shutdown(400, *hub, "temporary hub shutdown for testing"); schedule_reactor_shutdown(400, engine, "temporary engine shutdown for testing"); boost::thread engine_thread([&](){engine.run("engine0", hub->get_engine_info());}); hub->run(); engine_thread.join(); /*** * the engine should now be registered with the hub ***/ EXPECT_TRUE( engine.registered() ); EXPECT_ANY_THROW( hub->get_engine("dummy-engine-queue") ); EXPECT_NO_THROW(hub->get_engine("engine0-queue")); EXPECT_EQ(hub->get_num_engines(), 1); EXPECT_EQ(hub->get_engine("engine0-queue").services.size(), 2); EXPECT_EQ(hub->get_engine("engine0-queue").services[0], "test-service1"); EXPECT_EQ(hub->get_engine("engine0-queue").services[1], "test-service2"); /**** * continue execution ****/ schedule_reactor_shutdown(200, *hub, "2nd temporary hub shutdown for testing"); schedule_obj_shutdown(100, engine); // engine will shut down after half the time boost::thread engine_thread2([&](){engine.get_loop().run();}); LOG(INFO)<<"Running hub again until timeout..."; hub->run(); engine_thread2.join(); /*** * test unregistration of engine */ EXPECT_ANY_THROW(hub->get_engine("engine0-queue")); EXPECT_EQ(hub->get_num_engines(), 0); }
int main() { char filename[100], imagename[100]; //define test_image, file_reader, feature_extrator, classifier and detector IplImage* img; std::ifstream ifile; EdgeletFeatures hf(WIDTH,HEIGHT); CascadeClassifier cc; Detector dt; //load defult features // ifile.open("./data/haar_features.txt"); //hf.ReadFromFile(ifile); //ifile.close(); //load default classifier sprintf(filename,"%s/cascadeclassifier.txt",dir_prefix); ifile.open(filename); cc.ReadFromFile(ifile); dt.SetClassifier(&cc); dt.SetExtractor(&hf); std::vector<CvRect> results; std::ifstream f1; int num,i; //general test /**/ sprintf(filename,"%s/detect_samples.txt",dir_prefix); f1.open(filename); f1>>num; f1.ignore(256,'\n'); for(i=0;i<num;i++) { //read image f1>>imagename; img = cvLoadImage(imagename); std::vector<CvRect> results; std::clog<<"Checking the "<<i<<"st image: "<<imagename<<std::endl; dt.Check(img,results); dt.DrawResults(img,results); sprintf(filename,"%s/result_%d.bmp",dir_prefix,i); cvSaveImage(filename,img); cvReleaseImage(&img); } f1.close(); return 1; }
void crepo_conf_dialog::accept() { // QMessageBox::information( this, "", "save" ); QFile hf( QDir::homePath() + "/.gnurpgm/repos" ); hf.open( QIODevice::WriteOnly ); QTextStream out( &hf ); out << "<repoz>"; for ( int i = 0; i < this->dg_repo_list->count(); i++ ) { out << "\n\t<repo name=\"" << this->names[i] << "\" link=\"" << this->links[i] << "\" />"; } out << "\n</repoz>"; hf.close(); this->close(); }
void H5_LofarBFStokesWriterTest::test_method() { // generate test data DedispersionDataGenerator stokesData; unsigned nSamples = 20; unsigned nBlocks = 64; unsigned nSubbands = 4; float dm = 10.0; unsigned pol=0; // only one polarisation stokesData.setTimeSamplesPerBlock( nSamples ); stokesData.setSubbands( nSubbands ); QList<SpectrumDataSetStokes*> spectrumData = stokesData.generate( nBlocks, dm ); try { // Use case: // Stream out - most checks are done in the Base class test // so we only need to check that the output file is of the // correct size QString xml = "<H5_LofarBFStokesWriter>\n" + QString("<file filepath=\"%1\"").arg( _testDir->absolutePath() ) + " />" "<checkPoint interval=\"1\" />" "</H5_LofarBFStokesWriter>"; ConfigNode c; c.setFromString(xml); QString rawFile, h5File; H5_LofarBFStokesWriter out( c ); out.send("data", spectrumData[0] ); out.flush(); rawFile = out.rawFilename( pol ); h5File = out.metaFilename( pol ); QFile f(rawFile); CPPUNIT_ASSERT( f.exists() ); QFile hf(h5File); CPPUNIT_ASSERT( hf.exists() ); CPPUNIT_ASSERT_EQUAL( (int)(spectrumData[0]->size() * sizeof(float)), (int)f.size() ); // add more data to verify file grows out.send("data", spectrumData[1] ); out.flush(); CPPUNIT_ASSERT_EQUAL( (int)(spectrumData[0]->size() + spectrumData[1]->size()) * (int)sizeof(float) , (int)f.size() ); } catch( QString& s ) { CPPUNIT_FAIL(s.toStdString()); } stokesData.deleteData(spectrumData); }
int main(int argc, char** argv) { ros::init(argc, argv, "robothw"); ros::NodeHandle nh("handsfree"); std::string config_filename = "/config.txt" ; std::string config_filepath = CONFIG_PATH+config_filename ; std::cerr<<"the configure file path is: "<<config_filepath<<std::endl ; ros::NodeHandle nh_private("~"); std::string serial_port; nh_private.param<std::string>("serial_port", serial_port, "/dev/ttyUSB0"); std::string serial_port_path="serial://" + serial_port; std::cerr<<"the serial_port is: "<<serial_port_path<<std::endl ; handsfree_hw::HF_HW_ros hf(nh, serial_port_path , config_filepath); hf.mainloop(); return 0; }
void MigrateDialog::pageSelected(const QString&) { if (currentPage() != page2) return; backButton()->hide(); setFinishEnabled(page2, false); list<QCheckBox*>::iterator it; for (it = m_boxes.begin(); it != m_boxes.end(); ++it){ if ((*it)->isChecked()){ m_bProcess = true; break; } } if (!m_bProcess){ reject(); return; } unsigned totalSize = 0; for (it = m_boxes.begin(); it != m_boxes.end(); ++it){ if (!(*it)->isChecked()) continue; QString path = QFile::decodeName(user_file(QFile::encodeName((*it)->text())).c_str()); #ifdef WIN32 path += "\\"; #else path += "/"; #endif QFile icq_conf(path + "icq.conf"); totalSize += icq_conf.size(); QString history_path = path + "history"; #ifdef WIN32 history_path += "\\"; #else history_path += "/"; #endif QDir history(history_path); QStringList l = history.entryList("*.history", QDir::Files); for (QStringList::Iterator it = l.begin(); it != l.end(); ++it){ QFile hf(history_path + (*it)); totalSize += hf.size(); } } barCnv->setTotalSteps(totalSize); QTimer::singleShot(0, this, SLOT(process())); }
void CSGUnion::procq(const gmVector3 & x, double* q) { if( m_f != NULL && m_g != NULL ) { m_f->procq(x, q); m_g->procq(x, q + m_f->qlen()); double fx = m_f->proc(x); double gx = m_g->proc(x); double dhdf = hf(fx, gx); unsigned int i; for(i = 0; i < m_f->qlen(); i++) q[i] *= dhdf; double dhdg = hg(fx, gx); for(; i < m_f->qlen() + m_g->qlen(); i++) q[i] *= dhdg; } }
int main(int argc, char *argv[]) { if (argc != 4 || ((strcmp(argv[1], "-c") != 0) && (strcmp(argv[1], "-r") != 0))) { cout << "Usage:" << endl; cout << "To compress:" << "nscomp -c input_file output_file" << endl; cout << "To uncompress:" << "nscomp -r input_file output_file" << endl; return 0; } if (strcmp(argv[1], "-c") == 0) { Huffman hf(argv[2]); hf.Compress(argv[2], argv[3]); } if (strcmp(argv[1], "-r") == 0) { Huffman hf; hf.Uncompress(argv[2], argv[3]); } }
xtHelp* xtHelp::getInstance(QWidget *parent) { if(QHC_PATH.isEmpty()) { QFile hf(QDesktopServices::storageLocation(QDesktopServices::DataLocation)+"/XTupleGUIClient.qhc"); if(hf.exists()) QHC_PATH = hf.fileName(); else QHC_PATH = QCoreApplication::instance()->applicationDirPath() + QDir::separator() + #ifdef Q_OS_MAC "../Resources/" + #endif "XTupleGUIClient.qhc"; } if(!xtHelpSingleton) xtHelpSingleton = new xtHelp(parent); return xtHelpSingleton; }
static grub_err_t grub_linuxefi_boot (void) { handover_func hf; int offset = 0; #ifdef __x86_64__ offset = 512; #endif hf = (handover_func)((char *)kernel_mem + handover_offset + offset); asm volatile ("cli"); hf (grub_efi_image_handle, grub_efi_system_table, params); /* Not reached */ return GRUB_ERR_NONE; }
gmMatrix3 CSGUnion::hess(const gmVector3 & x) { if ((m_f!=NULL) && (m_g!=NULL)) { double fx = m_f->proc(x); double gx = m_g->proc(x); gmVector3 dfx = m_f->grad(x); gmVector3 dgx = m_g->grad(x); return hff(fx,gx) * outer(dfx,dfx) + hfg(fx,gx) * outer(dfx,dgx) + hfg(fx,gx) * outer(dgx,dfx) + hgg(fx,gx) * outer(dgx,dgx) + hf(fx,gx) * m_f->hess(x) + hg(fx,gx) * m_g->hess(x); } else return gmMatrix3(); }
int main(int argc, char * argv[]) { CyclicHash<uint64_t> hf(4, 64); string input = "XABCDY"; string base(input.begin() + 1, input.end() - 1); string extend(input.begin() + 1, input.end()); string prepend(input.begin(), input.end() - 1); for (string::const_iterator j = base.begin(); j != base.end(); ++j) { hf.eat(*j); } std::cout << base << " " << hf.hash(base) << std::endl; std::cout << prepend << " " << hf.hash_prepend(input[0]) << " " << hf.hash(prepend) << std::endl; std::cout << extend << " " << hf.hash_extend(input.back()) << " " << hf.hash(extend) << std::endl; assert(hf.hashvalue == hf.hash(base)); assert(hf.hash_prepend(input[0]) == hf.hash(prepend)); assert(hf.hash_extend(input.back()) == hf.hash(extend)); return 0; }
/*------------------------------------------------------------------------------------------------------------------------------ Export To Excell Bao cao tong hop nhap xuat ton kho ------------------------------------------------------------------------------------------------------------------------------*/ void rptDonthuoctonghop::OnExportToXLS(){ CMainFrame_E10 *pMF = (CMainFrame_E10 *) AfxGetMainWnd(); CString tmpStr,szSQL, szWhere, szTemp; CString szType, szTypeName; for (int i=0 ; i<= m_wndType.GetCount(); i++) { if(m_wndType.GetCheck(i)) { m_wndType.SetCurSel(i); if(!szType.IsEmpty()) { szType += _T(","); szTypeName +=_T(", "); } szType.AppendFormat(_T("'%s'"), m_wndType.GetCurrent(0)); szTypeName.AppendFormat(_T("%s"), m_wndType.GetCurrent(1)); } } if(!szType.IsEmpty()) szWhere.AppendFormat(_T(" and mp_producttype in(%s)"), szType); else szTypeName.Format(_T("T\x1EA5t \x63\x1EA3 lo\x1EA1i thu\x1ED1\x63")); if(!m_szGroupKey.IsEmpty()) { szWhere.AppendFormat(_T(" and substr(mp_product_class_id, 1, %d)= '%s' "), m_szGroupKey.GetLength(), m_szGroupKey); } if(str2int(m_szSourceKey) > 0) { szWhere.AppendFormat(_T(" and mpi_resource_id=%d "), str2int(m_szSourceKey)); } if (!m_szStockKey.IsEmpty()) szWhere.AppendFormat(_T(" and expstockid = %d"), ToInt(m_szStockKey)); szSQL.Format(_T(" SELECT ") \ _T(" mp_name as name, ") \ _T(" mpc_name as genericname, ") \ _T(" get_uomname(mp_uom_id) as unit, ") \ _T(" mpi_taxprice as price, ") \ _T(" sum(expqty) as qty,") \ _T(" sum(expqty*mpi_taxprice) as amount") \ _T(" FROM mev") \ _T(" LEFT JOIN m_product_item ON(mpi_product_item_id=sitemid)") \ _T(" LEFT JOIN m_product ON(mpi_product_id=mp_product_id)") \ _T(" LEFT JOIN m_product_class ON(mpc_product_class_id=mp_product_class_id) ") \ _T(" WHERE sitemid > 0 AND iotype = 'PPO' and expdate between cast_string2timestamp('%s') and cast_string2timestamp('%s') %s ") \ _T(" GROUP BY mp_name,mpc_name,mp_uom_id,mpi_taxprice") \ _T(" ORDER BY name,unit"), m_szFromDate, m_szToDate, szWhere); CReportSection* rptDetail=NULL; CRecord rs(&pMF->m_db); double cost = 0; int nItem = 1; rs.ExecSQL(szSQL); if(rs.IsEOF()){ ShowMessage(150, MB_ICONSTOP); return ; } CExcel xls; xls.CreateSheet(1); xls.SetWorksheet(0); CellFormat df(&xls), cf(&xls), hf(&xls); df.SetItalic(true); df.SetCellStyle(FMT_TEXT | FMT_CENTER); hf.SetBold(true); hf.SetCellStyle(FMT_TEXT | FMT_CENTER); cf.SetFontName(_T("Segoe UI")); xls.SetColumnWidth(0, 5); xls.SetColumnWidth(1, 35); xls.SetColumnWidth(2, 35); xls.SetColumnWidth(3, 10); xls.SetColumnWidth(4, 10); xls.SetColumnWidth(5, 10); xls.SetColumnWidth(6, 15); xls.SetCellMergedColumns(0, 0, 2); xls.SetCellMergedColumns(0, 1, 2); xls.SetCellText(0, 0, pMF->m_szHealthService, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(0, 1, pMF->m_szHospitalName, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellMergedColumns(0, 2, 7); TranslateString(_T("General Prescription"), szTemp); StringUpper(szTemp, tmpStr); xls.SetCellText(0, 2, tmpStr,FMT_TEXT | FMT_CENTER, true, 12); xls.SetCellMergedColumns(0, 3, 7); tmpStr.Format(_T("T\x1EEB ngày %s \x111\x1EBFn ngày %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmm, ddmmyyyy|hhmm), CDateTime::Convert(m_szToDate, yyyymmdd|hhmm, ddmmyyyy|hhmm)); xls.SetCellText(0, 3, tmpStr, &df); int nRow = 3; if (!m_szStockKey.IsEmpty()) { nRow++; tmpStr.Format(_T("T\x1EEB kho: %s"), m_wndStock.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } if(!m_szTypeKey.IsEmpty()) { nRow++; tmpStr.Format(_T("Lo\x1EA1i: %s"), m_wndType.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } if(!m_szGroupKey.IsEmpty()) { nRow++; tmpStr.Format(_T("Nhóm: %s"), m_wndGroup.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } if(!m_szSourceKey.IsEmpty()) { nRow++; tmpStr.Format(_T("Ngu\x1ED3n: %s"), m_wndSource.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } nRow++; xls.SetCellText(0, nRow, _T("STT"), &hf); xls.SetCellText(1, nRow, _T("Tên thu\x1ED1\x63/ HL"), &hf); xls.SetCellText(2, nRow, _T("T\xEAn ho\x1EA1t \x63h\x1EA5t"), &hf); xls.SetCellText(3, nRow, _T("\x110\x1A1n v\x1ECB"), &hf); xls.SetCellText(4, nRow, _T("\x110\x1A1n giá"), &hf); xls.SetCellText(5, nRow, _T("S\x1ED1 l\x1B0\x1EE3ng"), &hf); xls.SetCellText(6, nRow, _T("Th\xE0nh ti\x1EC1n"), &hf); double Amount=0.0, ttCost =0.0; while(!rs.IsEOF()) { //rs.GetValue(_T("expinvoice"), szNewLine); //if(szNewLine != szOldLine && !szNewLine.IsEmpty()) //{ // nRow++; // CString szField, szAmount; // xls.SetCellText(1, nRow, szNewLine, FMT_TEXT,true); // rs.GetValue(_T("iotype"), tmpStr); // xls.SetCellText(2,nRow,pMF->GetSelectionString(_T("pms_export_type"), tmpStr),FMT_TEXT,true); // rs.GetValue(_T("expdate"), tmpStr); // xls.SetCellText(3, nRow, CDate::Convert(tmpStr,yyyymmdd,ddmmyyyy), FMT_DATE,true); // rs.GetValue(_T("deptid"), tmpStr); // xls.SetCellText(4,nRow,tmpStr,FMT_TEXT, true); // if (grpCost >0) // { // tmpStr.Format(_T("%.2f"), grpCost); // xls.SetCellText(6,nRow-nItem,tmpStr,FMT_NUMBER1,true); // ttCost += grpCost; // } // szOldLine = szNewLine; // nItem=1; // grpCost= 0; //} nRow ++; tmpStr.Format(_T("%d"), nItem++); xls.SetCellText(0,nRow,tmpStr, FMT_NUMBER1); rs.GetValue(_T("name"), tmpStr); xls.SetCellText(1,nRow,tmpStr, FMT_TEXT); rs.GetValue(_T("genericname"), tmpStr); xls.SetCellText(2,nRow,tmpStr, FMT_TEXT); rs.GetValue(_T("unit"), tmpStr); xls.SetCellText(3,nRow,tmpStr, FMT_TEXT); rs.GetValue(_T("price"), tmpStr); xls.SetCellText(4,nRow,tmpStr, FMT_NUMBER1); rs.GetValue(_T("qty"), tmpStr); xls.SetCellText(5,nRow,tmpStr, FMT_NUMBER1); rs.GetValue(_T("amount"), Amount); ttCost +=Amount; tmpStr.Format(_T("%.2f"), Amount); xls.SetCellText(6,nRow,tmpStr, FMT_NUMBER1); rs.MoveNext(); } //if (grpCost >0) //{ nRow++; // tmpStr.Format(_T("%.2f"), grpCost); // xls.SetCellText(6,nRow-nItem,tmpStr,FMT_NUMBER1,true); // ttCost += grpCost; //} if (ttCost >0) { nRow++; xls.SetCellText(1,nRow,_T("T\x1ED5ng ti\x1EC1n:"), FMT_TEXT,true); tmpStr.Format(_T("%.2f"), ttCost); xls.SetCellText(6,nRow,tmpStr,FMT_NUMBER1,true); } xls.Save(_T("Exports\\Don Thuoc Tong Hop.XLS")); }
int main() { { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, test_compare<std::equal_to<int> >, test_allocator<std::pair<const int, std::string> > > C; typedef std::pair<int, std::string> P; P a[] = { P(1, "one"), P(2, "two"), P(3, "three"), P(4, "four"), P(1, "four"), P(2, "four"), }; C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0]))); assert(c.bucket_count() >= 5); assert(c.size() == 4); assert(c.at(1) == "one"); assert(c.at(2) == "two"); assert(c.at(3) == "three"); assert(c.at(4) == "four"); assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.get_allocator() == (test_allocator<std::pair<const int, std::string> >())); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, test_compare<std::equal_to<int> >, min_allocator<std::pair<const int, std::string> > > C; typedef std::pair<int, std::string> P; P a[] = { P(1, "one"), P(2, "two"), P(3, "three"), P(4, "four"), P(1, "four"), P(2, "four"), }; C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0]))); assert(c.bucket_count() >= 5); assert(c.size() == 4); assert(c.at(1) == "one"); assert(c.at(2) == "two"); assert(c.at(3) == "three"); assert(c.at(4) == "four"); assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.get_allocator() == (min_allocator<std::pair<const int, std::string> >())); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if _LIBCPP_STD_VER > 11 { typedef std::pair<int, std::string> P; typedef test_allocator<std::pair<const int, std::string>> A; typedef test_hash<std::hash<int>> HF; typedef test_compare<std::equal_to<int>> Comp; typedef std::unordered_map<int, std::string, HF, Comp, A> C; P arr[] = { P(1, "one"), P(2, "two"), P(3, "three"), P(4, "four"), P(1, "four"), P(2, "four"), }; C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14); assert(c.bucket_count() >= 14); assert(c.size() == 4); assert(c.at(1) == "one"); assert(c.at(2) == "two"); assert(c.at(3) == "three"); assert(c.at(4) == "four"); assert(c.hash_function() == HF()); assert(c.key_eq() == Comp()); assert(c.get_allocator() == A()); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } { typedef std::pair<int, std::string> P; typedef test_allocator<std::pair<const int, std::string>> A; typedef test_hash<std::hash<int>> HF; typedef test_compare<std::equal_to<int>> Comp; typedef std::unordered_map<int, std::string, HF, Comp, A> C; P arr[] = { P(1, "one"), P(2, "two"), P(3, "three"), P(4, "four"), P(1, "four"), P(2, "four"), }; HF hf(42); A a(43); C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, hf, a); assert(c.bucket_count() >= 14); assert(c.size() == 4); assert(c.at(1) == "one"); assert(c.at(2) == "two"); assert(c.at(3) == "three"); assert(c.at(4) == "four"); assert(c.hash_function() == hf); assert(!(c.hash_function() == HF())); assert(c.key_eq() == Comp()); assert(c.get_allocator() == a); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif #endif }
int main() { { typedef std::unordered_set<int, test_hash<std::hash<int> >, test_compare<std::equal_to<int> >, test_allocator<int> > C; typedef int P; P a[] = { P(1), P(2), P(3), P(4), P(1), P(2) }; C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0]))); assert(c.bucket_count() >= 5); assert(c.size() == 4); assert(c.count(1) == 1); assert(c.count(2) == 1); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.get_allocator() == test_allocator<int>()); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L { typedef std::unordered_set<int, test_hash<std::hash<int> >, test_compare<std::equal_to<int> >, min_allocator<int> > C; typedef int P; P a[] = { P(1), P(2), P(3), P(4), P(1), P(2) }; C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0]))); assert(c.bucket_count() >= 5); assert(c.size() == 4); assert(c.count(1) == 1); assert(c.count(2) == 1); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.get_allocator() == min_allocator<int>()); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if _LIBCPP_STD_VER > 11 { typedef int T; typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef test_allocator<T> A; typedef std::unordered_set<T, HF, Comp, A> C; T arr[] = { T(1), T(2), T(3), T(4), T(1), T(2) }; A a(42); C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a); assert(c.bucket_count() >= 12); assert(c.size() == 4); assert(c.count(1) == 1); assert(c.count(2) == 1); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == HF()); assert(c.key_eq() == Comp()); assert(c.get_allocator() == a); assert(!(c.get_allocator() == A())); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } { typedef int T; typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef test_allocator<T> A; typedef std::unordered_set<T, HF, Comp, A> C; T arr[] = { T(1), T(2), T(3), T(4), T(1), T(2) }; HF hf(43); A a(42); C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a); assert(c.bucket_count() >= 16); assert(c.size() == 4); assert(c.count(1) == 1); assert(c.count(2) == 1); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == hf); assert(!(c.hash_function() == HF())); assert(c.key_eq() == Comp()); assert(c.get_allocator() == a); assert(!(c.get_allocator() == A())); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif #endif }
int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, test_compare<std::equal_to<int> >, test_allocator<int> > C; typedef int P; C c = { P(1), P(2), P(3), P(4), P(1), P(2) }; assert(c.bucket_count() >= 7); assert(c.size() == 6); assert(c.count(1) == 2); assert(c.count(2) == 2); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.get_allocator() == test_allocator<int>()); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, test_compare<std::equal_to<int> >, min_allocator<int> > C; typedef int P; C c = { P(1), P(2), P(3), P(4), P(1), P(2) }; assert(c.bucket_count() >= 7); assert(c.size() == 6); assert(c.count(1) == 2); assert(c.count(2) == 2); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.get_allocator() == min_allocator<int>()); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if _LIBCPP_STD_VER > 11 { typedef int T; typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef test_allocator<T> A; typedef std::unordered_multiset<T, HF, Comp, A> C; A a(42); C c({ T(1), T(2), T(3), T(4), T(1), T(2) }, 12, a); assert(c.bucket_count() >= 12); assert(c.size() == 6); assert(c.count(1) == 2); assert(c.count(2) == 2); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == HF()); assert(c.key_eq() == Comp()); assert(c.get_allocator() == a); assert(!(c.get_allocator() == A())); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } { typedef int T; typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef test_allocator<T> A; typedef std::unordered_multiset<T, HF, Comp, A> C; A a(42); HF hf(43); C c({ T(1), T(2), T(3), T(4), T(1), T(2) }, 12, hf, a); assert(c.bucket_count() >= 12); assert(c.size() == 6); assert(c.count(1) == 2); assert(c.count(2) == 2); assert(c.count(3) == 1); assert(c.count(4) == 1); assert(c.hash_function() == hf); assert(!(c.hash_function() == HF())); assert(c.key_eq() == Comp()); assert(c.get_allocator() == a); assert(!(c.get_allocator() == A())); assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS }
int main() { { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, test_compare<std::equal_to<NotConstructible> >, test_allocator<NotConstructible> > C; C c(test_allocator<NotConstructible>(10)); LIBCPP_ASSERT(c.bucket_count() == 0); assert(c.hash_function() == test_hash<std::hash<NotConstructible> >()); assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >()); assert(c.get_allocator() == test_allocator<NotConstructible>(10)); assert(c.size() == 0); assert(c.empty()); assert(std::distance(c.begin(), c.end()) == 0); assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } #if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, test_compare<std::equal_to<NotConstructible> >, min_allocator<NotConstructible> > C; C c(min_allocator<NotConstructible>{}); LIBCPP_ASSERT(c.bucket_count() == 0); assert(c.hash_function() == test_hash<std::hash<NotConstructible> >()); assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >()); assert(c.get_allocator() == min_allocator<NotConstructible>()); assert(c.size() == 0); assert(c.empty()); assert(std::distance(c.begin(), c.end()) == 0); assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } #if _LIBCPP_STD_VER > 11 { typedef NotConstructible T; typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef test_allocator<T> A; typedef std::unordered_multiset<T, HF, Comp, A> C; A a(43); C c(3, a); LIBCPP_ASSERT(c.bucket_count() == 3); assert(c.hash_function() == HF()); assert(c.key_eq() == Comp ()); assert(c.get_allocator() == a); assert(!(c.get_allocator() == A())); assert(c.size() == 0); assert(c.empty()); assert(std::distance(c.begin(), c.end()) == 0); assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } { typedef NotConstructible T; typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef test_allocator<T> A; typedef std::unordered_multiset<T, HF, Comp, A> C; HF hf(42); A a(43); C c(4, hf, a); LIBCPP_ASSERT(c.bucket_count() == 4); assert(c.hash_function() == hf); assert(!(c.hash_function() == HF())); assert(c.key_eq() == Comp ()); assert(c.get_allocator() == a); assert(!(c.get_allocator() == A())); assert(c.size() == 0); assert(c.empty()); assert(std::distance(c.begin(), c.end()) == 0); assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } #endif #endif }
void Converter::convertSingleDocPrecise( const string_t& fileName ) { #ifdef SECURITY_ENABLED if ( !security_.getKey().updateCounters(0) ) { logContent(security_.getKey()); return; } #endif tDocumentsSp docs = word()->getDocuments(); tDocumentSp doc = docs->open(toUtf16(getInputAbsPath(fileName))); if (!doc) { logError(logger(), "Error while opening document: " + fileName); return; } /// -------------------------------------------/// usedFonts_.clear(); wstring_t docAsText; // tParagraphsSp paragraphs = doc->getParagraphs(); // int count = paragraphs->getCount(); // tSentencesSp sentences = doc->getSentences(); // int sentCount = sentences->getCount(); // for (int i = 1; i <= count; ++i) { // tParagraphSp p = paragraphs->getItem(i); // docAsText += processRangePrecise(p->getRange(), false); // std::cout << "\r" << percentageStr(i, count); // } tRangeSp r = doc->getContent(); int64 totalBytes = r->getStoryLength(); docAsText += processRangePreciseVer2(r, true); std::cout << std::endl; /// footnotes logInfo(logger(), "Processing [footnotes]: "); tFootnotesSp footnots = doc->getFootnotes(); int notesCount = footnots->getCount(); for (int i = 1; i <= notesCount; ++i) { tNoteSp note = footnots->getItem(i); tRangeSp r = note->getRange(); processRangePreciseVer2(r, false); std::cout << "\r" << percentageStr(i, notesCount); } if (notesCount > 0) std::cout << std::endl; tSectionsSp sections = doc->getSections(); int sectionsCount = sections->getCount(); for (int i = 1; i <= sectionsCount; ++i) { tSectionSp section(new Section(sections->getItem(i))); tHeadersFootersSp hfs = section->getHeaders(); if (hfs) { logInfo(logger(), "Processing [headers]: "); tHeaderFooterSp hf( new HeaderFooter(hfs->getItem(1)) ); tRangeSp r = hf->getRange(); processRangePreciseVer2(r, false); } hfs = section->getFooters(); if (hfs) { logInfo(logger(), "Processing [footers]: "); tHeaderFooterSp hf( new HeaderFooter(hfs->getItem(1)) ); tRangeSp r = hf->getRange(); processRangePreciseVer2(r, false); } } #ifdef SECURITY_ENABLED security_.getKey().updateCounters(totalBytes); #endif logUsedFonts(fileName, usedFonts_); usedFonts_.clear(); /// now save result in the appropriate folder string_t outputDir = getOutputAbsPath(fileName); Poco::File(outputDir).createDirectories(); Poco::Path p(fileName); logInfo(logger(), "Saving document..."); doc->saveAs( outputDir + p.getBaseName() + " UNICODE." + p.getExtension() ); doc->close(); logInfo(logger(), "Save was successful."); if ( wantUtf8Text_ ) writeFileAsBinary( outputDir + p.getBaseName() + " UTF8.txt", toUtf8(docAsText)); #ifdef SECURITY_ENABLED logContent(security_.getKey()); #endif }
int main( int, char** ) { // Creating the analysis factory std::auto_ptr<AIDA::IAnalysisFactory> af( AIDA_createAnalysisFactory() ); // Creating the tree factory std::auto_ptr<AIDA::ITreeFactory> tf( af->createTreeFactory() ); // Creating a memory-mapped tree std::auto_ptr<AIDA::ITree> tree( tf->create() ); // Creating a histogram factory attached to the tree std::auto_ptr<AIDA::IHistogramFactory> hf( af->createHistogramFactory( *tree ) ); // Creating a tree mapped to an hbook file bool readOnly = true; bool createNew = false; std::auto_ptr<AIDA::ITree> treeHBook( tf->create("histo.hbook", "hbook", readOnly, createNew ) ); // Creating a tree mapped to an XML file readOnly = false; createNew = true; std::auto_ptr<AIDA::ITree> treeXML( tf->create("histo.xml", "xml", readOnly, createNew ) ); // Mounting the hbook and xml trees under the master memory tree. tree->mkdir( "hbook" ); tree->mkdir( "xml" ); tree->mount( "/hbook", *treeHBook, "/" ); tree->mount( "/xml", *treeXML, "/" ); // Fetching the histograms from hbook AIDA::IHistogram1D& h1 = dynamic_cast<AIDA::IHistogram1D&>( *(tree->find( "/hbook/1" ) ) ); AIDA::IHistogram1D& h2 = dynamic_cast<AIDA::IHistogram1D&>( *(tree->find( "/hbook/2" ) ) ); std::cout << "Histogram 1 : " << std::endl; std::cout << " Entries : " << h1.entries() << std::endl; std::cout << " Mean : " << h1.mean() << std::endl; std::cout << " Rms : " << h1.rms() << std::endl; std::cout << "Histogram 2 : " << std::endl; std::cout << " Entries : " << h2.entries() << std::endl; std::cout << " Mean : " << h2.mean() << std::endl; std::cout << " Rms : " << h2.rms() << std::endl; // Adding the two histograms and putting the result in the xml file tree->cd( "/xml" ); AIDA::IHistogram1D& h3 = *( hf->add( "histo_3", h1, h2 ) ); h3.setTitle( "Sum histogram" ); std::cout << "Histogram 3 ( 1+2 ) : " << std::endl; std::cout << " Entries : " << h3.entries() << std::endl; std::cout << " Mean : " << h3.mean() << std::endl; std::cout << " Rms : " << h3.rms() << std::endl; // Plotting the three histograms // Creating the plotter factory /* std::auto_ptr< AIDA::IPlotterFactory > pf( af->createPlotterFactory() ); // Creating a plotter std::auto_ptr< AIDA::IPlotter > pl( pf->create() ); pl->show(); AIDA::IPlotterRegion& region = pl->currentRegion(); std::cout << "Press <ENTER> to plot the first histogram" << std::endl; std::cin.get(); region.plot( h1, "annotation" ); pl->refresh(); std::cout << "Press <ENTER> to plot the second histogram" << std::endl; std::cin.get(); region.clear(); region.plot( h2, "annotation" ); pl->refresh(); std::cout << "Press <ENTER> to plot the sum histogram" << std::endl; std::cin.get(); region.clear(); region.plot( h3, "annotation" ); pl->refresh(); std::cout << "Press <ENTER> to save the results in XML and exit" << std::endl; std::cin.get(); */ // Copying the first histogram from HBOOK to XML tree->cp( "/hbook/1", "." ); tree->mkdir( "dir1" ); tree->cp( "/hbook/2", "/xml/dir1" ); std::cout << "Full tree contents: " << std::endl; tree->ls( "/", true ); // Flushing the results into the XML file tree->commit(); // Explicitly closing the tree tree->close(); return 0; }
TEST(hub_test, hub_init){ gpf::hub_factory hf(5000); hf.ip("127.0.0.1").transport("tcp"); EXPECT_NO_THROW(hf.get()); }
node* insert(node* root, int val) { if (!root) { root = new node(); root->val = val; root->ht = 0; return root; } // // Insertion Phase // if (root->val <= val) { // insert into right sub-tree if (root->right) { root->right = insert(root->right, val); } else { node* n = new node(); n->val = val; n->ht = 0; root->right = n; } } else { // insert into left sub-tree if (root->left) { root->left = insert(root->left, val); } else { node* n = new node(); n->val = val; n->ht = 0; root->left = n; } } // set height root->ht = hf(root); // // Balance Phase // // check balance factor int f = bf(root); if (f > 1) { int lf = bf(root->left); if (lf < 0) { // Left Right Case node* lc = root->left; node* lrc = lc->right; lc->right = lrc->left; lrc->left = lc; root->left = lrc; lc->ht = hf(lc); lrc->ht = hf(lrc); } // Left Left Case node* lc = root->left; root->left = lc->right; lc->right = root; lc->right->ht = hf(lc->right); lc->ht = hf(lc); return lc; } else if (f < -1) { int rf = bf(root->right); if (rf > 0) { // Right Left Case node* rc = root->right; node* rlc = rc->left; rc->left = rlc->right; rlc->right = rc; root->right = rlc; rc->ht = hf(rc); rlc->ht = hf(rlc); } // Right Right Case node* rc = root->right; root->right = rc->left; rc->left = root; rc->left->ht = hf(rc->left); rc->ht = hf(rc); return rc; } return root; }
void CEMWeekSynthesisReport::OnExportSelect(){ _debug(_T("%s"), CString(typeid(this).name())); CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CExcel xls; CRecord rs(&pMF->m_db); CString szSQL, tmpStr, szTemp, szWhere; int nCol = 0, nRow = 0; int nTotal[12], nTemp = 0; szSQL = GetQueryString(); int nCount = rs.ExecSQL(szSQL); if (nCount <= 0) { ShowMessage(150, MB_ICONSTOP); return; } xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(0, 30); xls.SetColumnWidth(1, 10); xls.SetColumnWidth(2, 10); xls.SetColumnWidth(3, 10); xls.SetColumnWidth(4, 10); xls.SetColumnWidth(5, 10); xls.SetColumnWidth(6, 10); xls.SetColumnWidth(7, 10); xls.SetColumnWidth(8, 10); xls.SetColumnWidth(9, 10); xls.SetColumnWidth(10, 10); xls.SetColumnWidth(11, 13); CellFormat df(&xls), hf(&xls), nf(&xls); df.SetItalic(true); df.SetCellStyle(FMT_TEXT | FMT_CENTER); hf.SetBold(true); hf.SetCellStyle(FMT_TEXT | FMT_CENTER); nf.SetCellStyle(FMT_NUMBER1); //Header xls.SetCellMergedColumns(nCol, nRow, 3); xls.SetCellMergedColumns(nCol, nRow + 1, 3); xls.SetCellMergedColumns(nCol, nRow + 2, 11); xls.SetCellMergedColumns(nCol, nRow + 3, 11); xls.SetCellText(nCol, nRow, pMF->m_CompanyInfo.sc_pname, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(nCol, nRow + 1, pMF->m_CompanyInfo.sc_name, FMT_TEXT | FMT_CENTER, true, 10); TranslateString(_T("Weekly Synthesis Report"), szTemp); StringUpper(szTemp, tmpStr); xls.SetCellText(nCol, nRow + 2, tmpStr, FMT_TEXT | FMT_CENTER, true, 12); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x111\x1EBFn ng\xE0y %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); xls.SetCellText(nCol, nRow + 3, tmpStr, &df); //Column Header CStringArray arrCol; arrCol.Add(_T("Ph\xF2ng")); arrCol.Add(_T("Qu\xE2n")); arrCol.Add(_T("\x42HYT Qu\xE2n")); arrCol.Add(_T("\x42\x1EA1n")); arrCol.Add(_T("Tr\x1EBB < \x36t")); arrCol.Add(_T("\x43h\xEDnh s\xE1\x63h")); arrCol.Add(_T("\x44\xE2n")); arrCol.Add(_T("\x42HYT kh\xE1\x63")); arrCol.Add(_T("\x42H TNSQ")); arrCol.Add(_T("\x42H Qu\xE2n \x111\x1ED9i")); arrCol.Add(_T("BHYT Qu\xE2n nh\xE2n")); arrCol.Add(_T("BHYT(N\x1EE3 th\x1EBB)")); arrCol.Add(_T("T\x1ED5ng \x63\x1ED9ng")); nRow = 4; for (int i = 0; i < arrCol.GetCount(); i++) { xls.SetCellText(nCol+i, nRow, arrCol.GetAt(i), FMT_TEXT | FMT_CENTER, true, 10); } for (int i = 0; i< 12; i++) { nTotal[i] = 0; } nRow = 5; while (!rs.IsEOF()){ rs.GetValue(_T("roomid"), tmpStr); xls.SetCellText(nCol, nRow, tmpStr, FMT_TEXT); for (int i = 0; i< 12; i++) { szTemp.Format(_T("c%d"), i+1); rs.GetValue(szTemp, nTemp); tmpStr.Format(_T("%d"), nTemp); xls.SetCellText(nCol+i+1, nRow, tmpStr, &nf); nTotal[i] += nTemp; } nRow++; rs.MoveNext(); } TranslateString(_T("Total"), tmpStr); xls.SetCellText(nCol, nRow, tmpStr, FMT_TEXT | FMT_CENTER, true); for (int i = 0; i<12; i++) { tmpStr.Format(_T("%d"), nTotal[i]); xls.SetCellText(nCol+i+1, nRow, tmpStr, FMT_NUMBER1, true); } szWhere.Format(_T(" AND hcr_admitdate BETWEEN cast_string2timestamp('%s') AND cast_string2timestamp('%s')"), m_szFromDate, m_szToDate); if (pMF->GetModuleID() == _T("EM")) szWhere.AppendFormat(_T(" AND hd_enddept = '%s'"), pMF->GetCurrentDepartmentID()); szSQL.Format(_T(" SELECT sum(c1) as c1,") \ _T(" sum(c2) as c2,") \ _T(" sum(c3) as c3,") \ _T(" sum(c4) as c4,") \ _T(" sum(c5) as c5,") \ _T(" sum(c6) as c6,") \ _T(" sum(c7) as c7,") \ _T(" sum(c8) as c8,") \ _T(" sum(c9) as c9,") \ _T(" sum(c10) as c10, ") \ _T(" sum(c11) as c11, ") \ _T(" sum(c12) as c12 ") \ _T(" FROM") \ _T(" (") \ _T(" SELECT") \ _T(" case when hd_object=1 then 1 else 0 end as c1,") \ _T(" case when hd_object=2 then 1 else 0 end as c2,") \ _T(" case when hd_object=8 then 1 else 0 end as c3,") \ _T(" case when hd_object in(6, 9) then 1 else 0 end as c4,") \ _T(" case when hd_object=3 then 1 else 0 end as c5,") \ _T(" case when hd_object=7 then 1 else 0 end as c6,") \ _T(" case when hd_object=4 then 1 else 0 end as c7,") \ _T(" case when hd_object=5 then 1 else 0 end as c8,") \ _T(" case when hd_object=10 then 1 else 0 end as c9,") \ _T(" case when hd_object=11 then 1 else 0 end as c10,") \ _T(" case when hd_object=12 then 1 else 0 end as c11,") \ _T(" 1 as c12 ") \ _T(" FROM hms_doc") \ _T(" LEFT JOIN hms_exam ON (he_docno = hd_docno AND hd_doctor = he_doctor)") \ _T(" LEFT JOIN hms_clinical_record ON(hcr_docno=hd_docno)") \ _T(" WHERE hcr_numinward > 0 %s") \ _T(" ) tbl"), szWhere); rs.ExecSQL(szSQL); _fmsg(_T("%s"), szSQL); if (!rs.IsEOF()){ nRow++; xls.SetCellText(nCol, nRow, _T("V\xE0o vi\x1EC7n"), FMT_TEXT | FMT_CENTER, true); for (int i = 0; i< 12; i++) { szTemp.Format(_T("c%d"), i+1); rs.GetValue(szTemp, tmpStr); xls.SetCellText(nCol+i+1, nRow, tmpStr, FMT_NUMBER1, true); } } else { ShowMessage(150, MB_ICONSTOP); return; } xls.Save(_T("Exports\\Bao Cao Tong Hop Tuan C1_1.xls")); }