コード例 #1
0
ファイル: ObfPoiSection.cpp プロジェクト: cdavila/OsmAnd-core
void OsmAnd::ObfPoiSection::loadCategories( OsmAnd::ObfReader* reader, OsmAnd::ObfPoiSection* section, QList< std::shared_ptr<OsmAnd::Model::Amenity::Category> >& categories )
{
    auto cis = reader->_codedInputStream.get();
    cis->Seek(section->_offset);
    auto oldLimit = cis->PushLimit(section->_length);
    readCategories(reader, section, categories);
    cis->PopLimit(oldLimit);
}
コード例 #2
0
void OsmAnd::ObfPoiSectionReader_P::loadCategories(
    const std::unique_ptr<ObfReader_P>& reader, const std::shared_ptr<const ObfPoiSectionInfo>& section,
    QList< std::shared_ptr<const OsmAnd::Model::AmenityCategory> >& categories )
{
    auto cis = reader->_codedInputStream.get();
    cis->Seek(section->_offset);
    auto oldLimit = cis->PushLimit(section->_length);
    readCategories(reader, section, categories);
    cis->PopLimit(oldLimit);
}
コード例 #3
0
ファイル: satdialog.cpp プロジェクト: AlterScribus/ece15
void SATDialog::addCategories(const QString& dir)
{
	// Read categories from the dir itself
	QString tmplFile = findTemplateXml(dir);
	if (QFile::exists(tmplFile))
		readCategories(tmplFile);

	// And from all the subdirectories. template.xml file is only searched one dir level deeper than the dir
	QDir tmpldir(dir);
	if (tmpldir.exists())
	{
		tmpldir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
		QStringList dirs = tmpldir.entryList();
		for (int i = 0; i < dirs.size(); ++i)
		{
			tmplFile = findTemplateXml(dir + "/" + dirs[i]);
			if (QFile::exists(tmplFile))
				readCategories(tmplFile);
		}
	}
}
コード例 #4
0
int readInputFiles(std::vector<ItemCategory> &categories,
                   std::vector<Conversion> &conversions)
{
	if (readCategories(categories) > 0)
		return 1;
	if (readItems(categories) > 0)
		return 2;
	if (readConversions(categories, conversions) > 0)
		return 3;

	return 0;
}
コード例 #5
0
void OsmAnd::ObfPoiSectionReader_P::loadCategories(
    const ObfReader_P& reader, const std::shared_ptr<const ObfPoiSectionInfo>& section,
    QList< std::shared_ptr<const OsmAnd::AmenityCategory> >& categories )
{
    const auto cis = reader.getCodedInputStream().get();
    cis->Seek(section->offset);
    auto oldLimit = cis->PushLimit(section->length);

    readCategories(reader, section, categories);

    ObfReaderUtilities::ensureAllDataWasRead(cis);
    cis->PopLimit(oldLimit);
}
コード例 #6
0
ファイル: widgetboxtreewidget.cpp プロジェクト: mohdpatah/qt
bool WidgetBoxTreeWidget::loadContents(const QString &contents)
{
    QString errorMessage;
    CategoryList cat_list;
    if (!readCategories(m_file_name, contents, &cat_list, &errorMessage)) {
        qdesigner_internal::designerWarning(errorMessage);
        return false;
    }

    foreach(const Category &cat, cat_list)
        addCategory(cat);

    addCustomCategories(false);
    // Restore which items are expanded
    restoreExpandedState();
    return true;
}
コード例 #7
0
ファイル: bookOrder.c プロジェクト: DavidAwad/BookOrder
int main(int argc, char **argv){
	if( argc != 4 ){
		printf( "Must specify a Database File, book order file, and a category names. \n Feel Free to refer to the readme for usage.\n" );
		_exit( 1 );	// crash and burn
	}
	FILE *fp;

	if( (fp = fopen(argv[1], "r") ) == NULL ) {
		printf("fopen didn't work in %s line %d.\n", __FILE__ , __LINE__ );
		printf("Please Enter Valid Database File \n");
		_exit(1); // crash and burn
	}
	else if( (fp = fopen(argv[2], "r") ) == NULL ) {
		printf("fopen didn't work in %s line %d.\n", __FILE__ , __LINE__ );
		printf("Please Enter Valid Book Order File \n");
		_exit(1); // crash and burn
	}
	else if( (fp = fopen(argv[3], "r") ) == NULL ) {
		printf("fopen didn't work in %s line %d.\n", __FILE__ , __LINE__ );
		printf("Please Enter Valid Category File \n");
		_exit(1); // crash and burn
	}
	/* Done with error checking. */
	fp = fopen(argv[1], "r");
	int fSize;
	fseek(fp, 0L, SEEK_END);
	fSize = ftell(fp);
	fseek(fp, 0 , SEEK_SET);
	if(fSize == 0){
		printf("The database file is empty, cannot procceed \n");
		_exit(1);
	}
	customerList = readDatabase(fp);
	if( (error = fclose( fp ) ) > 0 ){
		printf("fclose died in %s line %d: %s \n", __FILE__ , __LINE__ , strerror(error));
		_exit(1); // crash and burn
	}
	totalProfit = 0;
	/*
	   this gives us the full set of orders that we can
	   then separate into the array of smaller queues based on the category.
	 */
	fp = fopen(argv[3], "r");
	fseek(fp, 0L, SEEK_END);
	fSize = ftell(fp);
	fseek(fp , 0 , SEEK_SET);
	if(fSize == 0){
		printf("The category file is empty, cannot procceed \n");
		_exit(1);
	}
	numcats = readCategories(fp);
	categoryList = (category*)malloc(sizeof(category)*numcats);
	fillCategory(fp);
	if(( error = fclose( fp ) )> 0 ){
		printf("fclose stuck it's nose where it didn't belong in %s line %d: %s\n", __FILE__ , __LINE__ , strerror( error ) );
		_exit(1); // crash and burn
	}
	fp = fopen(argv[2], "r");
	pthread_t	tid;
	if ((error = pthread_create( &tid, NULL , readBookOrders , fp ))){
		printf( "pthread_create() sparked the flames of revolution in %s line %d: %s\n", __FILE__ , __LINE__ , strerror( error ) );
		_exit( 1 );	// crash and burn
	}
	createThreads();
	/*create the consumer threads to wait for the producer,
	  force a join on the producer after we create the consumers
	  that way all threads are guaranteed to finish.
	 */
	if ((error = pthread_join(tid, NULL))) {
		printf( "pthread_join()ed the dark side in %s line %d: %s \n", __FILE__, __LINE__, strerror( error ) );
		_exit(1);	// crash and burn
	}

	if( (error = fclose(fp) ) > 0 ) {
		printf("fclose was beaten down by the mob in %s line %d: %s \n", __FILE__ , __LINE__ , strerror( error ) );
		_exit(1); // crash and burn
	}
	finalReport();
	free(categoryList);
	printf("Total Revenue Gained: \x1b[32m$\x1b[0m%.2lf\n", totalProfit);
	return 0; //success
}