示例#1
0
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
{
	if (useFilter && isFiltered() && !isAllowed(row))
		throw InvalidAccessException("Row not allowed");

	if (isNull(col, row)) return Poco::Dynamic::Var();

	switch (columnType(col))
	{
		case MetaColumn::FDT_BOOL:      return value<bool>(col, row, useFilter);
		case MetaColumn::FDT_INT8:      return value<Int8>(col, row, useFilter);
		case MetaColumn::FDT_UINT8:     return value<UInt8>(col, row, useFilter);
		case MetaColumn::FDT_INT16:     return value<Int16>(col, row, useFilter);
		case MetaColumn::FDT_UINT16:    return value<UInt16>(col, row, useFilter);
		case MetaColumn::FDT_INT32:	    return value<Int32>(col, row, useFilter);
		case MetaColumn::FDT_UINT32:    return value<UInt32>(col, row, useFilter);
		case MetaColumn::FDT_INT64:     return value<Int64>(col, row, useFilter);
		case MetaColumn::FDT_UINT64:    return value<UInt64>(col, row, useFilter);
		case MetaColumn::FDT_FLOAT:     return value<float>(col, row, useFilter);
		case MetaColumn::FDT_DOUBLE:    return value<double>(col, row, useFilter);
		case MetaColumn::FDT_STRING:    return value<std::string>(col, row, useFilter);
		case MetaColumn::FDT_BLOB:      return value<BLOB>(col, row, useFilter);
		case MetaColumn::FDT_CLOB:      return value<CLOB>(col, row, useFilter);
		case MetaColumn::FDT_DATE:      return value<Date>(col, row, useFilter);
		case MetaColumn::FDT_TIME:      return value<Time>(col, row, useFilter);
		case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(col, row);
		default:
			throw UnknownTypeException("Data type not supported.");
	}
}
示例#2
0
bool ClipboardBrowser::hideFiltered(int row)
{
    d.setRowVisible(row, false); // show in preload()

    bool hide = isFiltered(row);
    setRowHidden(row, hide);

    return hide;
}
/*
 * Return the number of children.
 *
 * Logically this routine is equivalent to:
 *   return childCount(indexPath) != 0
 * But with some underlying data models it may be expensive to ask
 * for the child count but fast to check if there are any children at all.
 * So mimic the code of childCOunt to detect our exception,
 * and pass the request along for everything else.
 */
bool FilteredDataModel::hasChildren(const QVariantList& indexPath)
{
    if (isFiltered(indexPath))
    {
        // Unexpanded header
        return false;
    }
    return m_fullDataModel->hasChildren(indexPath); // pointer always initialized
}
/*
 * Return the number of children.
 * Defer to the underlying data model unless the header is filtered.
 * Note: assumes m_fullDataModel is initialized
 */
int FilteredDataModel::childCount(const QVariantList& indexPath)
{
    if (isFiltered(indexPath))
    {
        // Unexpanded header
        return 0;
    }
    return m_fullDataModel->childCount(indexPath); // pointer always initialized
}
bool FileFilterIndex::showFile(FileData* game)
{
	// this shouldn't happen, but just in case let's get it out of the way
	if (!isFiltered())
		return true;

	// if folder, needs further inspection - i.e. see if folder contains at least one element
	// that should be shown
	if (game->getType() == FOLDER) {
		std::vector<FileData*> children = game->getChildren();
		// iterate through all of the children, until there's a match

		for (std::vector<FileData*>::const_iterator it = children.cbegin(); it != children.cend(); ++it ) {
			if (showFile(*it))
			{
				return true;
			}
		}
		return false;
	}

	bool keepGoing = false;

	for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it ) {
		FilterDataDecl filterData = (*it);
		if(*(filterData.filteredByRef))
		{
			// try to find a match
			std::string key = getIndexableKey(game, filterData.type, false);
			keepGoing = isKeyBeingFilteredBy(key, filterData.type);

			// if we didn't find a match, try for secondary keys - i.e. publisher and dev, or first genre
			if (!keepGoing)
			{
				if (!filterData.hasSecondaryKey)
				{
					return false;
				}
				std::string secKey = getIndexableKey(game, filterData.type, true);
				if (secKey != UNKNOWN_LABEL)
				{
					keepGoing = isKeyBeingFilteredBy(secKey, filterData.type);
				}
			}
			// if still nothing, then it's not a match
			if (!keepGoing)
				return false;

		}

	}

	return keepGoing;
}
示例#6
0
bool RecordSet::movePrevious()
{
	std::size_t currentRow = _currentRow;
	do
	{
		if (currentRow <= 0) return false;
		--currentRow;
	} while (isFiltered() && !isAllowed(currentRow));

	_currentRow = currentRow;
	return true;
}
示例#7
0
bool RecordSet::moveNext()
{
	std::size_t currentRow = _currentRow;
	do
	{
		if (currentRow >= subTotalRowCount() - 1) return false;
		++currentRow;
	} while (isFiltered() && !isAllowed(currentRow));

	_currentRow = currentRow;
	return true;
}
示例#8
0
void TiledMapLoader::registerCallbackForGID(const int gid, const Callback& callback, const std::list<std::string>& layerFilter)
{
    if (!gidFactories.count(gid)) {
        gidFactories[gid] = CallbackList();
    }

    gidFactories[gid].push_back([this, callback, layerFilter](const Configuration& config) {
        if (!isFiltered(config.layer, layerFilter)) {
            callback(config);
        }
    });
}
示例#9
0
void TiledMapLoader::registerCallbackForName(const std::string& name, const Callback& callback, const std::list<std::string>& layerFilter)
{
    if (!nameFactories.count(name)) {
        nameFactories[name] = CallbackList();
    }

    nameFactories[name].push_back([this, callback, layerFilter](const Configuration& config) {
        if (!isFiltered(config.layer, layerFilter)) {
            callback(config);
        }
    });
}
示例#10
0
std::size_t RecordSet::rowCount() const
{
	poco_assert (extractions().size());
	std::size_t rc = subTotalRowCount();
	if (!isFiltered()) return rc;

	std::size_t counter = 0;
	for (int row = 0; row < rc; ++row)
	{
		if (isAllowed(row)) ++counter;
	}

	return counter;
}
示例#11
0
bool RecordSet::moveLast()
{
	if (subTotalRowCount() > 0)
	{
		std::size_t currentRow = subTotalRowCount() - 1;
		if (!isFiltered())
		{
			_currentRow = currentRow;
			return true;
		}

		while (!isAllowed(currentRow))
		{
			if (currentRow <= 0) return false;
			--currentRow;
		}

		_currentRow = currentRow;
		return true;
	}
	else return false;
}
示例#12
0
bool RecordSet::moveFirst()
{
	if (subTotalRowCount() > 0)
	{
		if (!isFiltered())
		{
			_currentRow = 0;
			return true;
		}

		std::size_t currentRow = 0;
		while (!isAllowed(currentRow))
		{
			if (currentRow >= subTotalRowCount() - 1) return false;
			++currentRow;
		}

		_currentRow = currentRow;
		return true;
	}
	else return false;
}
示例#13
0
bool RecordSet::isAllowed(std::size_t row) const
{
	if (!isFiltered()) return true;
	return _pFilter->isAllowed(row);
}
示例#14
0
bool TraceAnalyzer::exportTraceFile(const char *fileName, int *ts_errno,
				    exporttype_t export_type)
{
	bool isFtrace = false, isPerf = false;
	char *wbuf, *wb;
	int fd, w;
	int written, written_io, space, nrspaces, write_rval;
	int nr_elements;
	int idx;
	int i;
	const TraceEvent *eptr;
	bool rval = true;
	const char *ename;
	char tbuf[40];
	event_t cpuevent_type = (event_t) 0;
	bool ok;
	bool filtered = isFiltered();

	nr_elements = filtered ? filteredEvents.size() : events->size();
	*ts_errno = 0;

	if (!isOpen()) {
		*ts_errno = - TS_ERROR_INTERNAL;
		return false;
	}

	switch (getTraceType()) {
	case TRACE_TYPE_FTRACE:
		isFtrace = true;
		break;
	case TRACE_TYPE_PERF:
		isPerf = true;
		break;
	default:
		*ts_errno = - TS_ERROR_INTERNAL;
		return false;
	}

	wbuf = (char*) mmap(nullptr, (size_t) WRITE_BUFFER_SIZE,
			    PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
			    -1, 0);

	if (wbuf == MAP_FAILED)
		mmap_err();

	if (!parser->traceFile->isIntact(ts_errno)) {
		rval = false;
		if (*ts_errno == 0)
			*ts_errno = - TS_ERROR_FILECHANGED;
		goto error_munmap;
	}

	parser->traceFile->allocMmap();
	fd =  clib_open(fileName, O_WRONLY | O_CREAT,
			(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH));

	if (fd < 0) {
		rval = false;
		*ts_errno = errno;
		goto error_munmap;
	}

	idx = 0;

	if (export_type == EXPORT_TYPE_CPU_CYCLES) {
		cpuevent_type = determineCPUEvent(ok);
		if (!ok) {
			rval = false;
			*ts_errno = - TS_ERROR_NOCPUEV;
			goto error_close;
		}
	}

	if (!isPerf)
		goto skip_perf;

	do {
		written = 0;
		space = WRITE_BUFFER_SIZE;
		wb = wbuf;

		while (idx < nr_elements && written < WRITE_BUFFER_LIMIT) {
			if (filtered)
				eptr = filteredEvents[idx];
			else
				eptr = &(*events)[idx];
			idx++;
			if (export_type == EXPORT_TYPE_CPU_CYCLES &&
			    eptr->type != cpuevent_type)
				continue;
			eptr->time.sprint(tbuf);
			w = snprintf(wb, space,
				     "%s %5u [%03u] %s: ",
				     eptr->taskName->ptr, eptr->pid,
				     eptr->cpu, tbuf);
			if (w > 0) {
				written += w;
				space   -= w;
				wb      += w;
			}
			if (eptr->intArg != 0) {
				w = snprintf(wb, space, "%10u ",
					     eptr->intArg);
				if (w > 0) {
					written += w;
					space   -= w;
					wb      += w;
				}
			}

			ename = eptr->getEventName()->ptr;
			nrspaces = TSMAX(1, spaceStrLen - strlen(ename));
			nrspaces = TSMIN(nrspaces, space);
			if (nrspaces > 0) {
				strncpy(wb, spaceStr, nrspaces);
				written += nrspaces;
				space   -= nrspaces;
				wb      += nrspaces;
			}

			w = snprintf(wb, space, "%s:", ename);
			if (w > 0) {
				written += w;
				space   -= w;
				wb      += w;
			}

			for (i = 0; i < eptr->argc; i++) {
				w = snprintf(wb, space, " %s",
					     eptr->argv[i]->ptr);
				if (w > 0) {
					written += w;
					space   -= w;
					wb      += w;
				}
			}
			w = snprintf(wb, space, "\n");
			if (w > 0) {
				written += w;
				space   -= w;
				wb      += w;
			}
			if (eptr->postEventInfo != nullptr &&
			    eptr->postEventInfo->len > 0) {
				size_t cs = TSMIN(space,
						  eptr->postEventInfo->len);
				parser->traceFile->readChunk(
					eptr->postEventInfo, wb, space,
					ts_errno);
				if (*ts_errno != 0) {
					rval = false;
					goto error_close;
				}
				if (cs > 0) {
					written += cs;
					space   -= cs;
					wb      += cs;
				}
			}
		}

		if (written > 0) {
			written_io = 0;
			do {
				write_rval = write(fd, wbuf, written);
				if (write_rval > 0) {
					written_io += write_rval;
				}
				if (write_rval < 0 && errno != EINTR) {
					rval = false;
					*ts_errno = errno;
					goto error_close;
				}
			} while(written_io < written);
		}
		if (idx >= nr_elements)
			break;
	} while(true);

	if (!parser->traceFile->isIntact(ts_errno)) {
		rval = false;
		if (*ts_errno == 0)
			*ts_errno = - TS_ERROR_FILECHANGED;
		goto error_close;
	}

skip_perf:
	if (!isFtrace)
		goto skip_ftrace;

/* Insert ftrace code here */

skip_ftrace:
error_close:
	if (clib_close(fd) != 0) {
		if (errno != EINTR) {
			rval = false;
			*ts_errno = errno;
		}
	}

error_munmap:
	parser->traceFile->freeMmap();
	if (munmap(wbuf, WRITE_BUFFER_SIZE) != 0)
		munmap_err();

	return rval;
}
示例#15
0
//---
// This method is called back by the ossimFileWalker::walk method for each file it finds that it
// deems can be processed.
//---
void ossimImageUtil::processFile(const ossimFilename& file)
{
   static const char M[] = "ossimImageUtil::processFile";
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << M << " entered...\n" << "file: " << file << "\n";
   }

   bool processFileFlag = true;
   if ( !getOverrideFilteredImagesFlag() )
   {
      processFileFlag = !isFiltered( file );
   }

   if ( processFileFlag )
   {
      ossimNotify(ossimNotifyLevel_NOTICE) << "Processing file: " << file << std::endl;

      m_mutex.lock();
      ossimRefPtr<ossimImageHandler> ih =
         ossimImageHandlerRegistry::instance()->open(file, true, true);
      m_mutex.unlock();
      
      if ( ih.valid() && !ih->hasError() )
      {
         if ( isDirectoryBasedImage( ih.get() ) )
         {
            // Tell the walker not to recurse this directory.
            m_mutex.lock();
            m_fileWalker->setRecurseFlag(false);
            m_mutex.unlock();
         }
         
         // Set any reader props:
         ossimPropertyInterface* pi = dynamic_cast<ossimPropertyInterface*>(ih.get());
         if ( pi ) setProps(pi);
         
         bool consumedHistogramOptions  = false;
         bool consumedCmmOptionsOptions = false;
         
         if ( getOutputFileNamesFlag() )
         {
            // Simply output the file name of any images we can open:
            ossimNotify(ossimNotifyLevel_NOTICE) << ih->getFilename().expand(); 
         }
         
         if ( createOverviews() )
         {
            // Skip shape files...
            if ( ih->getClassName() != "ossimOgrGdalTileSource" )
            {
               createOverview(ih, consumedHistogramOptions, consumedCmmOptionsOptions);
            }
         }
         
         // Build stand alone histogram.  Note the overview sequencer may have computed for us.
         if ( hasHistogramOption() && !consumedHistogramOptions)
         {
            createHistogram( ih );
         }
      }
      else
      {
         ossimNotify(ossimNotifyLevel_WARN) << M << "\nCould not open: " << file << std::endl;
      }
   }
   else // Matches: if ( processFileFlag )
   {
      ossimNotify(ossimNotifyLevel_NOTICE)
         << "Filtered file, not processing: " << file << std::endl;
   }
   
   if(traceDebug())
   {
      // Since ossimFileWalker is threaded output the file so we know which job exited.
      ossimNotify(ossimNotifyLevel_DEBUG) << M << "\nfile: " << file << "\nexited...\n";
   }
}