Ejemplo n.º 1
0
DataColumnBase* DataSet::getCellValue( const unsigned int row, const unsigned int columnIndex )
{
	DataRow* myRow = NULL;

	if ( row >= this->size() )
		throw invalid_argument( "Row index out of bounds" );

	myRow = ( *this )[ row ];
	if ( myRow == NULL )
		throw runtime_error( "Unable to access row" );

	if ( columnIndex > myRow->size() )
		throw invalid_argument( "Column index out of bounds" );

	string columnName = "";
	map< std::string, DataColumnBase* >::iterator myIterator = myRow->begin();
	for ( unsigned int j = 0; j<=columnIndex; myIterator++, j++ )
	{
		columnName = myIterator->first;
	}

	DataColumnBase* result = NULL;
	try
	{
		result = ( *myRow )[ columnName ];

		if ( result == NULL )
		{
			DEBUG( "Warning : cell empty for request : " <<
			       row << ", " << columnIndex << " (" << columnName << ")" );
			myRow->DumpHeader();
		}
	}
	catch( ... )
	{
		throw invalid_argument( "columnIndex" );
	}

	return result;
}