Пример #1
0
/*
 * At any point we should be able to construct an ascii representation of
 * the type descriptor. Including the variable references.
 */
str
getTypeName(malType tpe)
{
	char buf[PATHLENGTH], *s;
	size_t l = PATHLENGTH;
	int k;

	if (tpe == TYPE_any)
		return GDKstrdup("any");
	if (isaBatType(tpe)) {
		snprintf(buf, l, "bat[");
		l -= strlen(buf);
		s = buf + strlen(buf);
		k = getColumnIndex(tpe);
		if (k)
			snprintf(s, l, ":any%c%d]",TMPMARKER,  k);
		else if (getColumnType(tpe) == TYPE_any)
			snprintf(s, l, ":any]");
		else
			snprintf(s, l, ":%s]", ATOMname(getColumnType(tpe)));
		return GDKstrdup(buf);
	}
	if (isAnyExpression(tpe)) {
		strncpy(buf, "any", 4);
		if (isAnyExpression(tpe))
			snprintf(buf + 3, PATHLENGTH - 3, "%c%d",
					TMPMARKER, getColumnIndex(tpe));
		return GDKstrdup(buf);
	}
	return GDKstrdup(ATOMname(tpe));
}
Пример #2
0
void RcppModelData::sumByGroup(std::vector<double>& out, const IdType covariate, const IdType groupBy, int power) {
    size_t covariateIndex = getColumnIndex(covariate);
    size_t groupByIndex = getColumnIndex(groupBy);
    out.resize(2);
    if (power == 0) {
    	reduceByGroup(out, covariateIndex, groupByIndex, ZeroPower());
    } else if (power == 1) {
  		reduceByGroup(out, covariateIndex, groupByIndex, FirstPower());  
    } else {
    	reduceByGroup(out, covariateIndex, groupByIndex, SecondPower());    
    }   
}
Пример #3
0
void MemoryPacketModel::transformUpdated()
{
    TransformAbstract * transform = dynamic_cast<TransformAbstract *>(sender());
    if (transform != nullptr) {
        QString colName;
        //retrieving the column name
        QHashIterator<QString, Usercolumn> i(userColumnsDef);
         while (i.hasNext()) {
             i.next();
             if (i.value().transform == transform) {
                 colName = i.key();
                 break;
             }
         }

         if (colName.isEmpty()) {
             qCritical() << tr("[MemoryPacketModel::transformUpdated] cannot find the column name based on the Transform object T_T");
             return;
         }

         int column = getColumnIndex(colName);
         if (column == -1) {
             return;
         }
         launchUpdate(transform, 0,column);

    } else {
        qCritical() << tr("[MemoryPacketModel::transformUpdated] dynamic cast failed T_T");
    }
}
Пример #4
0
bool TeSQLitePortal::getBlob(const string& s, unsigned char* &data, long& size)
{
	errorMessage_ = "";
	
	const char* bValue = (const char*) sqlite3_column_blob(_recordSet, getColumnIndex("spatial_data"));
	size = (unsigned int)sqlite3_column_bytes(_recordSet, getColumnIndex("spatial_data"));	

	if(data == NULL)
	{
		data = new unsigned char[size];
	}

	memcpy(data, bValue, size);

	return true;
}
Пример #5
0
int ResultSet::getColumnSize(const QString &column_name)
{
	int col_idx=-1;

	try
	{
		/* Raises an error if the user try to get the value of a column in
		 a tuple of an empty result or generated from an INSERT, DELETE, UPDATE,
		 that is, which command do not return lines but only do updates or removal */
		if(getTupleCount()==0 || empty_result)
			throw Exception(ERR_REF_TUPLE_INEXISTENT, __PRETTY_FUNCTION__, __FILE__, __LINE__);
		else if(current_tuple < 0 || current_tuple >= getTupleCount())
			throw Exception(ERR_REF_INV_TUPLE_COLUMN, __PRETTY_FUNCTION__, __FILE__, __LINE__);

		//Get the column index wich length must be detected
		col_idx=getColumnIndex(column_name);
	}
	catch(Exception &e)
	{
		//Capture and redirect any generated exception
		throw Exception(e.getErrorMessage(), e.getErrorType(), __PRETTY_FUNCTION__, __FILE__, __LINE__, &e);
	}

	//Returns the column value length on the current tuple
	return(PQgetlength(sql_result, current_tuple, col_idx));
}
Пример #6
0
		unsigned int DBResult::_getColumnIndexInternal(const std::string& columnName) const
		{
			int index = getColumnIndex(columnName);
			if (index == -1)
				throw DBException("No such column " + columnName);
			return (unsigned int)index;
		}
Пример #7
0
int WorldMap::pickColumn(const v3di_t& pos) const {
  int columnIndex = getColumnIndex(pos);

  if (mColumns[columnIndex].isInColumn(pos)) {
    return columnIndex;
  }
  return -1;
}
Пример #8
0
// Return a copy of the column data specified by its column name starting at 0
// (use the Column copy-constructor)
Column  Statement::getColumn(const char* apName)
{
    checkRow();
    const int index = getColumnIndex(apName);

    // Share the Statement Object handle with the new Column created
    return Column(mStmtPtr, index);
}
Пример #9
0
void MemoryPacketModel::internalAddUserColumn(const QString &name, TransformAbstract *transform)
{
    int column = getColumnIndex(name);
    if (column == -1) {
        return;
    }

    launchUpdate(transform, 0,column);
}
QRect ImageOverlayRegionFinder::growRegion(int row, int column, QBitArray &mask)
{
    QRect region;
    region.setCoords(column, row, column, row);

    QQueue<int> queue;
    queue.enqueue(getDataIndex(row, column));

    while (!queue.isEmpty())
    {
        int i = queue.dequeue();

        if (m_overlay.getData()[i] > 0 && !mask.testBit(i))
        {
            mask.setBit(i);
            row = getRowIndex(i);
            column = getColumnIndex(i);
            
            if (row < region.top())
            {
                region.setTop(row);
            }
            if (row > region.bottom())
            {
                region.setBottom(row);
            }
            if (column < region.left())
            {
                region.setLeft(column);
            }
            if (column > region.right())
            {
                region.setRight(column);
            }

            if (column - 1 >= 0)
            {
                queue.enqueue(getDataIndex(row, column - 1));
            }
            if (column + 1 < static_cast<signed>(m_overlay.getColumns()))
            {
                queue.enqueue(getDataIndex(row, column + 1));
            }
            if (row - 1 >= 0)
            {
                queue.enqueue(getDataIndex(row - 1, column));
            }
            if (row + 1 < static_cast<signed>(m_overlay.getRows()))
            {
                queue.enqueue(getDataIndex(row + 1, column));
            }
        }
    }

    return region;
}
Пример #11
0
double RcppModelData::sum(const IdType covariate, int power) {
    size_t index = getColumnIndex(covariate); 
    if (power == 0) {  
		return reduce(index, ZeroPower());
	} else if (power == 1) {
		return reduce(index, FirstPower());
	} else {
		return reduce(index, SecondPower());	
	}
}
Пример #12
0
bool table::createColumn(char * cName, int cType, bool cNotNull)
{
    if (usedColumns < numberOfColumns && getColumnIndex(cName) == notFound)
    {
        columnArray[usedColumns] = new column(cName, cType, cNotNull);
        usedColumns++;
        return true;
    }
    return false;
}
Пример #13
0
void RcppModelData::sumByGroup(std::vector<double>& out, const IdType covariate, int power) {
    size_t covariateIndex = getColumnIndex(covariate);
    out.resize(nPatients);
    if (power == 0) {
    	reduceByGroup(out, covariateIndex, pid, ZeroPower());
    } else if (power == 1) {
  		reduceByGroup(out, covariateIndex, pid, FirstPower());  
    } else {
    	reduceByGroup(out, covariateIndex, pid, SecondPower());    
    }    
}
Пример #14
0
void MemoryPacketModel::refreshColumn(const QString colName)
{
    if (userColumnsDef.contains(colName) && packetsList.size() > 0) {
        TransformAbstract * transform = userColumnsDef.value(colName).transform;
        int column = getColumnIndex(colName);
        if (column == -1) {
            return;
        }
        launchUpdate(transform, 0,column);
    }
}
Пример #15
0
bool ResultSet::isColumnBinaryFormat(const QString &column_name)
{
	int col_idx=-1;

	try
	{
		col_idx=getColumnIndex(column_name);
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(), e.getErrorType(), __PRETTY_FUNCTION__, __FILE__, __LINE__, &e);
	}

	/* Returns the column format in the current tuple.
		According to libpq documentation, value = 0, indicates column text format,
		value = 1 the column has binary format, the other values are reserved */
	return(PQfformat(sql_result, col_idx)==1);
}
Пример #16
0
bool TeSQLitePortal::getBool(const string& s)
{
	return getBool(getColumnIndex(s));
}
Пример #17
0
TeTime TeSQLitePortal::getDate(const string& s)
{
	return getDate(getColumnIndex(s));
}
Пример #18
0
 void MultiListBox::setColumnWidth(MultiListItem* _item, int _width)
 {
     setColumnWidthAt(getColumnIndex(_item), _width);
 }
Пример #19
0
 void MultiListBox::setColumnResizingPolicy(MultiListItem* _item, ResizingPolicy _value)
 {
     setColumnResizingPolicyAt(getColumnIndex(_item), _value);
 }
Пример #20
0
 const UString& MultiListBox::getColumnName(MultiListItem* _item)
 {
     return getColumnNameAt(getColumnIndex(_item));
 }
Пример #21
0
 void MultiListBox::setColumnName(MultiListItem* _item, const UString& _name)
 {
     setColumnNameAt(getColumnIndex(_item), _name);
 }
Пример #22
0
// get a design matrix column by name
vnl_vector<double> RtDesignMatrix::getColumn(const string &name) {
  return get_column(getColumnIndex(name));
}
Пример #23
0
int TeSQLitePortal::getInt(const string& s)
{
	return getInt(getColumnIndex(s));
}
Пример #24
0
		bool DBResult::isDefined( const std::string& fieldName ) const
		{
			return getColumnIndex(fieldName) != -1;
		}
Пример #25
0
bool Statement::isColumnNull(const char* apName) const
{
    checkRow();
    const int index = getColumnIndex(apName);
    return (SQLITE_NULL == sqlite3_column_type(mStmtPtr, index));
}
Пример #26
0
char* TeSQLitePortal::getData(const string& s)
{
	return getData(getColumnIndex(s));
}