int main() { struct fish snappy = {"Snappy", "Piranha", 69, 4, {{"meat", 0.2}, {"swim in the jacuxxi", 7.5}}}; catalog(snappy); label(snappy); }
// Load Hipparcos catalog // The catalog is a (n,3) cv::Mat of mag, ra, de cv::Mat load_catalog(const char* filename) { cv::Mat catalog(0, 3, CV_32FC1); std::ifstream file(filename); std::string line, cell; if (!file) { std::cerr << "Can't open catalog " << filename << std::endl; return catalog; } // Skip first line std::getline(file, line); // Extract each line data while (std::getline(file, line)) { std::stringstream line_str(line); // Read fields double hip(0.0), mag(0.0), ra(0.0), de(0.0); line_str >> hip; line_str.get(); line_str >> mag; line_str.get(); line_str >> ra; line_str.get(); line_str >> de; line_str.get(); // Convert angles to radians const double deg_to_rad = M_PI / 180.0; cv::Mat catline = (cv::Mat_<float>(1,3) << mag, ra * deg_to_rad, de * deg_to_rad); catalog.push_back(catline); } return catalog; }
void KatalogListView::setupChapters() { Katalog *cat = catalog(); if( ! cat ) return; if( m_root ) { delete m_root; mChapterDict.clear(); } kDebug() << "Creating root item!" << endl; QStringList list; list << cat->getName(); m_root = new QTreeWidgetItem( this, list ); m_root->setIcon( 0, SmallIcon("kraft")); m_root->setExpanded(true); m_root->setFont( 0, mChapterFont ); repaint(); const QList<CatalogChapter> chapters = cat->getKatalogChapters( true ); kDebug() << "Have count of chapters: " << chapters.size() << endl; QList<CatalogChapter> strayCats; foreach( CatalogChapter chapter, chapters ) { QTreeWidgetItem *item = tryAddingCatalogChapter( chapter ); if( ! item ) { strayCats.append( chapter ); } else { kDebug() << "Creating katalog chapter item for " << chapter.name() << endl; } }
int main(int argc, const char * argv[]) { struct fish snappy = {"Snappy", "Pirahna", 4, 69}; catalog(snappy); label(snappy); return 0; }
static void TestCatalog(skiatest::Reporter* reporter) { SkPDFCatalog catalog((SkPDFDocument::Flags)0); SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2)); SkAutoTUnref<SkPDFInt> int3(new SkPDFInt(3)); int1.get()->ref(); SkAutoTUnref<SkPDFInt> int1Again(int1.get()); catalog.addObject(int1.get(), false); catalog.addObject(int2.get(), false); catalog.addObject(int3.get(), false); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int3.get()) == 3); SkDynamicMemoryWStream buffer; catalog.emitObjectNumber(&buffer, int1.get()); catalog.emitObjectNumber(&buffer, int2.get()); catalog.emitObjectNumber(&buffer, int3.get()); catalog.emitObjectNumber(&buffer, int1Again.get()); char expectedResult[] = "1 02 03 01 0"; REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, strlen(expectedResult))); }
void TemplKatalogListView::slFreshupItem( QTreeWidgetItem *item, FloskelTemplate *tmpl, bool remChildren ) { if( !(item && tmpl) ) return; Geld g = tmpl->unitPrice(); QString ck = tmpl->calcKindString(); QString t = Portal::textWrap(tmpl->getText(), 60); item->setText( 0, t ); QString h; h = QString( "%1 / %2" ).arg( g.toString( catalog()->locale() ) ) .arg( tmpl->unit().einheitSingular() ); item->setText( 1, h ); item->setText( 2, ck ); // item->setText( 4, QString::number(tmpl->getTemplID())); if( remChildren ) { /* remove all children and insert them again afterwards. * That updates the view */ for( int i = 0; i < item->childCount(); i++ ) { QTreeWidgetItem *it = item->child(i); if( it ) { item->removeChild( it ); delete it; } } addCalcParts(tmpl); // Insert to update the view again. } }
static void TestSubstitute(skiatest::Reporter* reporter) { SkAutoTUnref<SkPDFTestDict> proxy(new SkPDFTestDict()); SkAutoTUnref<SkPDFTestDict> stub(new SkPDFTestDict()); SkAutoTUnref<SkPDFInt> int33(new SkPDFInt(33)); SkAutoTUnref<SkPDFDict> stubResource(new SkPDFDict()); SkAutoTUnref<SkPDFInt> int44(new SkPDFInt(44)); stub->insert("Value", int33.get()); stubResource->insert("InnerValue", int44.get()); stub->addResource(stubResource.get()); SkPDFCatalog catalog((SkPDFDocument::Flags)0); catalog.addObject(proxy.get(), false); catalog.setSubstitute(proxy.get(), stub.get()); SkDynamicMemoryWStream buffer; proxy->emit(&buffer, &catalog, false); catalog.emitSubstituteResources(&buffer, false); char objectResult[] = "2 0 obj\n<</Value 33\n>>\nendobj\n"; REPORTER_ASSERT( reporter, catalog.setFileOffset(proxy.get(), 0) == strlen(objectResult)); char expectedResult[] = "<</Value 33\n>>1 0 obj\n<</InnerValue 44\n>>\nendobj\n"; REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult)); REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, buffer.getOffset())); }
void TemplKatalogListView::addCalcParts( FloskelTemplate *tmpl ) { QTreeWidgetItem *item = tmpl->getListViewItem(); if( ! item ) return; CalcPartList parts = tmpl->getCalcPartsList(); CalcPartListIterator it(parts); while( it.hasNext() ) { CalcPart *cp = it.next(); QString title = cp->getName(); QString type = cp->getType(); kDebug() << "Type is " << type << endl; if( type == KALKPART_TIME ) { TimeCalcPart *zcp = static_cast<TimeCalcPart*>(cp); StdSatz stdsatz = zcp->getStundensatz(); title = QString( "%1, %2 Min. %3" ).arg( cp->getName() ) .arg( QString::number( zcp->getMinuten() ) ) .arg( stdsatz.getName() ); } QStringList list; list << title; list << cp->kosten().toString( catalog()->locale() ); list << cp->getType(); QTreeWidgetItem *cpItem = new QTreeWidgetItem( item, list ); cpItem->setDisabled(true); } }
void Tycho2Test::testAccess() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testAccess() begin"); Tycho2 catalog("/usr/local/starcatalogs/tycho2/tyc2.dat"); debug(LOG_DEBUG, DEBUG_LOG, 0, "retrieving record 0"); Tycho2Star firststar = catalog.find((unsigned int)0); debug(LOG_DEBUG, DEBUG_LOG, 0, "found first star: %s", firststar.name().c_str()); CPPUNIT_ASSERT(firststar.name() == std::string("T0001 00008 1")); debug(LOG_DEBUG, DEBUG_LOG, 0, "getting last star"); Tycho2Star laststar = catalog.find(catalog.nstars() - 1); CPPUNIT_ASSERT(laststar.name() == std::string("T9537 00387 1")); debug(LOG_DEBUG, DEBUG_LOG, 0, "found last star: %s", laststar.name().c_str()); Star star1 = catalog.find("T9522 00134 1"); CPPUNIT_ASSERT(star1.name() == std::string("T9522 00134 1")); CPPUNIT_ASSERT(fabs(star1.ra().degrees() - 244.18369114) < 1e-7); CPPUNIT_ASSERT(fabs(star1.dec().degrees() - (-82.77286513)) < 1e-7); Star star2 = catalog.find("T4711 00015 1"); CPPUNIT_ASSERT(star2.name() == std::string("T4711 00015 1")); CPPUNIT_ASSERT(fabs(star2.ra().degrees() - 47.70148132) < 1e-7); CPPUNIT_ASSERT(fabs(star2.dec().degrees() - (-2.70543639)) < 1e-7); debug(LOG_DEBUG, DEBUG_LOG, 0, "testAccess() end"); }
int main() { struct fish snappy = {"Snappy", "Piranha", 69, 4}; catalog(snappy); label(snappy); return 0; }
static void TestCatalog(skiatest::Reporter* reporter) { SkPDFCatalog catalog((SkPDFDocument::Flags)0); SkRefPtr<SkPDFInt> int1 = new SkPDFInt(1); int1->unref(); // SkRefPtr and new both took a reference. SkRefPtr<SkPDFInt> int2 = new SkPDFInt(2); int2->unref(); // SkRefPtr and new both took a reference. SkRefPtr<SkPDFInt> int3 = new SkPDFInt(3); int3->unref(); // SkRefPtr and new both took a reference. SkRefPtr<SkPDFInt> int1Again(int1.get()); catalog.addObject(int1.get(), false); catalog.addObject(int2.get(), false); catalog.addObject(int3.get(), false); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int3.get()) == 3); SkDynamicMemoryWStream buffer; catalog.emitObjectNumber(&buffer, int1.get()); catalog.emitObjectNumber(&buffer, int2.get()); catalog.emitObjectNumber(&buffer, int3.get()); catalog.emitObjectNumber(&buffer, int1Again.get()); char expectedResult[] = "1 02 03 01 0"; REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, strlen(expectedResult))); }
int main() { struct fish snappy = {"スナッピー","ピラニア",69,4}; catalog(snappy); label(snappy); return 0; }
int main() { struct fish Matt = {"Matt","Robot",65535,999}; catalog(Matt); label(Matt); return 0; }
void BootPromptWindow::_PopulateLanguages() { // Disable sending the selection message while we change the selection. fLanguagesListView->SetSelectionMessage(NULL); // Clear the list view first while (BListItem* item = fLanguagesListView->RemoveItem( fLanguagesListView->CountItems() - 1)) { delete item; } // Get current first preferred language of the user BMessage preferredLanguages; be_locale_roster->GetPreferredLanguages(&preferredLanguages); const char* firstPreferredLanguage; if (preferredLanguages.FindString("language", &firstPreferredLanguage) != B_OK) { // Fall back to built-in language of this application. firstPreferredLanguage = "en"; } // TODO: Use this API instead once it's ready. // BMessage installedCatalogs; // be_locale_roster->GetInstalledCatalogs(&installedCatalogs); // installedCatalogs.PrintToStream(); // Try to instantiate a BCatalog for each language, it will only work // for translations of this application. So the list of languages will be // limited to catalogs written for this application, which is on purpose! const char* languageString; for (int32 i = 0; fInstalledLanguages.FindString("langs", i, &languageString) == B_OK; i++) { BCatalog catalog("x-vnd.Antares-ReadOnlyBootPrompt", languageString); if (catalog.InitCheck() == B_OK) { BLanguage* language; if (be_locale_roster->GetLanguage(&language, BString(languageString)) == B_OK) { BString name; language->GetName(&name); LanguageItem* item = new LanguageItem(name.String(), languageString); fLanguagesListView->AddItem(item); // Select this item if it is the first preferred language if (strcmp(firstPreferredLanguage, languageString) == 0) { fLanguagesListView->Select( fLanguagesListView->CountItems() - 1); } } else printf("failed to get BLanguage for %s\n", languageString); } } // Re-enable sending the selection message. fLanguagesListView->SetSelectionMessage( new BMessage(MSG_LANGUAGE_SELECTED)); }
int main() { struct pet snappy = {"Snappy", "Piranha", 69, 4, {"meat", 7.5}}; catalog(snappy); print(snappy); return 0; }
int main() { char name[] = "Matt"; char species[] = "Robot"; int teeth = 65535; int age = 999; catalog(name,species,teeth,age); label(name,species,teeth,age); return 0; }
int main() { struct fish snappy = {"Snappy", "Piranha", 69, 4, {{"Meat", 0.2}, {"swim", 7.5}}}; catalog(snappy); label(snappy); //printf("Snappy likes to eat %s", snappy.care.food); //printf("Snappy likes to exercise for %f hours", snappy.care.exercise_hours); return 0; }
int main(int argc, char **argv) { ZArgs zargs; args_init(&zargs, argc, argv, standard_malloc_factory_init()); SyncFactory_Pthreads sf; Catalog catalog(&zargs, &sf); catalog.scan(zargs.log, zargs.dep_file, zargs.zar); catalog.emit(zargs.zar); return 0; }
int main() { std::string catalog("./"); std::string indFileName("ind.sba"); std::string crdFileName("crd.sba"); std::string mtrFileName("mtr001.sba"); std::string fixFileName("fix.sba"); std::string forceFileName("force.sba"); // std::unique_ptr<sbfMesh> = return 0; }
static int copy_files(const boost::program_options::variables_map &vm) { std::unique_ptr<edm::SiteLocalConfig> slcptr = std::make_unique<edm::service::SiteLocalConfigService>(edm::ParameterSet()); auto slc = std::make_shared<edm::serviceregistry::ServiceWrapper<edm::SiteLocalConfig> >(std::move(slcptr)); edm::ServiceToken slcToken = edm::ServiceRegistry::createContaining(slc); edm::ServiceRegistry::Operate operate(slcToken); auto in = (vm.count("file") ? vm["file"].as<std::vector<std::string> >() : std::vector<std::string>()); if (in.size() < 2) { std::cerr << "Not enough arguments!" << std::endl; std::cerr << "Usage: edmCopyUtil [file1] [file2] [file3] dest_dir" << std::endl; return 1; } boost::filesystem::path destdir(in.back()); in.pop_back(); if (!boost::filesystem::is_directory(destdir)) { std::cerr << "Last argument must be destination directory; " << destdir << " is not a directory!" << std::endl; return 1; } std::string catalogIn = (vm.count("catalog") ? vm["catalog"].as<std::string>() : std::string()); edm::InputFileCatalog catalog(in, catalogIn, true); std::vector<std::string> const& filesIn = catalog.fileNames(); for(unsigned int j = 0; j < in.size(); ++j) { boost::filesystem::path pathOut = destdir; pathOut /= boost::filesystem::path(in[j]).filename(); boost::filesystem::ofstream ofs; ofs.exceptions(std::ofstream::failbit | std::ofstream::badbit); ofs.open(pathOut); std::unique_ptr<Storage> s = StorageFactory::get()->open(filesIn[j]); assert(s); // StorageFactory should throw if file open fails. static unsigned int const COPYBUFSIZE = 10*1024*1024; // 10MB buffer std::vector<char> buffer; buffer.reserve(COPYBUFSIZE); IOSize n; while ((n = s->read(&buffer[0], COPYBUFSIZE))) { // Note Storage throws on error ofs.write(&buffer[0], n); } ofs.close(); s->close(); } return 0; }
PDFDictionaryIterator PDFArrayIterator::DictAt(int ndx) { if(! mArray.GetPtr()) return PDFDictionaryIterator(mParser); PDFObjectCastPtr<PDFIndirectObjectReference> foundReference(mArray->QueryObject(ndx)); if(!foundReference) return PDFDictionaryIterator(mParser); PDFObjectCastPtr<PDFDictionary> catalog(mParser.ParseNewObject(foundReference->mObjectID)); if(!catalog) return PDFDictionaryIterator(mParser); return PDFDictionaryIterator(mParser, catalog); }
int main() { /* [ADDED] Also note: struct names (such as 'fish') do not appear to * conflict with local variables, i.e. I can have an integer variable called * fish apparently without issue. Same with variables inside structs, such * as 'name'. Specific instances of structs (e.g. 'snappy') do conflict. */ struct fish snappy = {"Snappy", "Piranha", 69, 4, {"Meat", 7.5}}; catalog(snappy); label(snappy); printf("Snappy likes to eat %s\n", snappy.care.food); printf("Snappy likes to exercise for %f hours\n", snappy.care.exercise_hours); return 0; }
int main() { pet snappy = {"Snappy", "Piranha", 69, 4}; catalog(snappy); puts("---- Before bday\n"); print(snappy); happy_birthday(snappy); puts("---- After bday\n"); print(snappy); return 0; }
void Tycho2Test::testIterator() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testIterator() begin"); Tycho2 catalog("/usr/local/starcatalogs/tycho2/tyc2.dat"); CatalogIterator i; unsigned long counter = 0; for (i = catalog.begin(); i != catalog.end(); ++i) { counter++; if (counter == 100) { Star s = *i; CPPUNIT_ASSERT(s.name() == std::string("T0001 00779 1")); } } debug(LOG_DEBUG, DEBUG_LOG, 0, "iterations: %ld", counter); CPPUNIT_ASSERT(counter == catalog.numberOfStars()); debug(LOG_DEBUG, DEBUG_LOG, 0, "testIterator() end"); }
void env::scan() try { // // reset child envs and components // // open catalog file boost::filesystem::path catalog( this->get_paths().get_dpm_file( boost::filesystem::path( this->config.get<string_t>( CONST_DPM_CONF_CATALOG_FILE ) ) ) ); if ( boost::filesystem::exists( catalog ) ) { boost::property_tree::ptree catalog_pt; boost::property_tree::read_json( catalog.string(), catalog_pt ); // BOOST_FOREACH( const boost::property_tree::ptree::value_type& child, catalog_pt.get_child( CONST_CATALOG_CONF_COMPONENT )) { comp::create( this->get_logger(), this->get_appl(), this->shared_from_this(), child.second )->update(); } } else { throw std::exception( "Environment catalog.conf file doesn't exist" );
void CatalogDB::GetCatalogData(const QString& catalog_name, CatalogData& load_catalog) { skydb_.open(); QSqlTableModel catalog(0, skydb_); catalog.setTable("Catalog"); catalog.setFilter("Name LIKE \'" + catalog_name + "\'"); catalog.select(); QSqlRecord record = catalog.record(0); load_catalog.prefix = record.value("Prefix").toString(); load_catalog.color = record.value("Color").toString(); load_catalog.fluxfreq = record.value("FluxFreq").toString(); load_catalog.fluxunit = record.value("FluxUnit").toString(); load_catalog.epoch = record.value("Epoch").toFloat(); catalog.clear(); skydb_.close(); }
static void TestObjectRef(skiatest::Reporter* reporter) { SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2)); SkAutoTUnref<SkPDFObjRef> int2ref(new SkPDFObjRef(int2.get())); SkPDFCatalog catalog((SkPDFDocument::Flags)0); catalog.addObject(int1.get(), false); catalog.addObject(int2.get(), false); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3); char expectedResult[] = "2 0 R"; SkDynamicMemoryWStream buffer; int2ref->emitObject(&buffer, &catalog, false); REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult)); REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, buffer.getOffset())); }
void Tycho2Test::testWindowIterator() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindowIterator() begin"); Tycho2 catalog("/usr/local/starcatalogs/tycho2/tyc2.dat"); RaDec center(0, 0); center.ra().hours(6.75247702777777777777); center.dec().degrees(-16.71611583333333333333); Angle width; width.hours(1); Angle height; height.degrees(15); SkyWindow window(center, width, height); CatalogIterator i = catalog.findIter(window, MagnitudeRange(-30., 4.5)); unsigned long long counter = 0; for (; !i.isEnd(); ++i) { counter++; Star s = *i; debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", s.toString().c_str()); } CPPUNIT_ASSERT(counter == 7); debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindowIterator() end"); }
void Tycho2Test::testWindow() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindow() begin"); Tycho2 catalog("/usr/local/starcatalogs/tycho2/tyc2.dat"); RaDec center(0, 0); center.ra().hours(6.75247702777777777777); center.dec().degrees(-16.71611583333333333333); Angle width; width.hours(1); Angle height; height.degrees(15); SkyWindow window(center, width, height); Tycho2::starsetptr stars = catalog.find(window, MagnitudeRange(-30., 4.5)); Tycho2::starset::const_iterator s; for (s = stars->begin(); s != stars->end(); s++) { debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", s->toString().c_str()); } debug(LOG_DEBUG, DEBUG_LOG, 0, "%d stars", stars->size()); CPPUNIT_ASSERT(stars->size() == 7); debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindow() end"); }
void CatalogDB::RemoveCatalog(const QString& catalog_name) { // Part 1 Clear DSO Entries ClearDSOEntries(FindCatalog(catalog_name)); skydb_.open(); QSqlTableModel catalog(0, skydb_); // Part 2 Clear Catalog Table catalog.setTable("Catalog"); catalog.setFilter("Name LIKE \'" + catalog_name + "\'"); catalog.select(); catalog.removeRows(0, catalog.rowCount()); catalog.submitAll(); catalog.clear(); skydb_.close(); RefreshCatalogList(); }