Пример #1
0
/**
Output a table row to the html file

@param colNames descriptor array containing rows to be written in the resulting html file

*/
void CDbDbmsDumper::OutputTableColDataToFileL(const CDesCArray& colNames)
	{
	TInt counter = 0;
	const TInt KNumberOfCols( (iDbTable.ColCount() ));  
	iDbTable.GetL(); // get the row to be output

    // cols are from 1, to maxCols. not from 0 to KNumberOfCols-1.
	for (counter = 1; counter <= KNumberOfCols; ++counter)   // for each column value in this row 
		{
		iFile.Write(KCell);

		if (iDbTable.IsColNull(counter) )
			{
			iBuffer->Des().Format(KNullCol); // write out 'NULL' to the file
			}
		else
			{
			switch ( iDbTable.ColType(counter) )
				{
				case EDbColInt8:
				case EDbColInt16:
				case EDbColInt32:
					{
					TInt32 val = iDbTable.ColInt32(counter); 
					iBuffer->Des().Format(KInt32String, val);
					}
				break;
				case EDbColBit:
				case EDbColUint8:
				case EDbColUint16:
				case EDbColUint32:
					{
					TUint32 val = iDbTable.ColUint32(counter); 
					iBuffer->Des().Format(KUInt32String, val);
					}
				break;
				case EDbColInt64:
					{
					TInt64 val = iDbTable.ColInt64(counter);
					iBuffer->Des().Format(KUInt64String, I64HIGH(val), I64LOW(val) );
					}
				break;
				case EDbColReal32:
					{
					TReal32 val = iDbTable.ColReal32(counter);
					iBuffer->Des().Format(KRealString, val);
					}
				break;
				case EDbColReal64:
					{
					TReal64 val = iDbTable.ColReal64(counter);
					iBuffer->Des().Format(KRealString, val);
					}
				break;
				case EDbColDateTime:
					{
					TTime val = iDbTable.ColTime(counter);
					TBuf<80> tmpBuffer;
					val.FormatL(tmpBuffer, KFormatDate);
					iBuffer->Des().Copy(tmpBuffer);
					}
				break;
				case EDbColBinary:
				case EDbColText8:
					{
					TPtrC8 val = iDbTable.ColDes8(counter);
					iBuffer->Des().Copy(val);
					}
				break;
				case EDbColText16:
					{
					TPtrC16 val = iDbTable.ColDes16(counter);
					iBuffer->Des().Copy(val);
					}
				break;
				case EDbColLongText8:
					iBuffer->Des().Format(KLongText8);   
				break;
				case EDbColLongText16:
					LongBinaryL(counter);
				break;
				case EDbColLongBinary:
					if (colNames[counter-1] == KFieldHeaderColName)
						{
						FieldHeaderColL(counter);
						}
					else 
						{
						LongBinaryL(counter);
						}
				break;
				default:
					iBuffer->Des().Format(KUnknownMessage);
				break;
				} // switch
			} // if

		iFile.Write(*iBuffer);
		iFile.Write(KCellEnd);
		
		} // for
	}
Пример #2
0
/**
Outputs one row of a tables data.

@param	aTableIndex	table index in the table array

*/
void CDbSqlDumper::OutputTableColDataToFileL(TInt aTableIndex)
	{
	TInt counter = 0;
	const TInt KNumberOfCols( iDbStructure->ColumnNo(aTableIndex) );  

    // cols are from 1, to maxCols. not from 0 to KNumberOfCols-1.
	for (counter = 0; counter < KNumberOfCols; ++counter)   // for each column value in this row 
		{
		iFile.Write(KCell);

		if (iSqlStatement.IsNull(counter) )
			{
			iBuffer->Des().Format(KNullCol); // write out 'NULL' to the file
			}
		else
			{
			switch ( iSqlStatement.ColumnType(counter) )
				{
				case ESqlInt:
					{
					TInt32 val = iSqlStatement.ColumnInt(counter); 
					iBuffer->Des().Format(KInt32String, val);
					}
				break;
				case ESqlInt64:
					{
					TInt64 val = iSqlStatement.ColumnInt64(counter);
					iBuffer->Des().Format(KUInt64String, I64HIGH(val), I64LOW(val) );
					}
				break;
				case ESqlReal:
					{
					TReal32 val = iSqlStatement.ColumnReal(counter);
					iBuffer->Des().Format(KRealString, val);
					}
				break;
				case ESqlText:
					{
					iBuffer->Des().Copy(iSqlStatement.ColumnTextL(counter));
					}
				break;
				case ESqlBinary:
					if ((iDbStructure->Column(aTableIndex, counter) == KContactTextFieldHeader) ||
						(iDbStructure->Column(aTableIndex, counter) == KContactBinaryFieldHeader))
						{
						FieldHeaderColL(counter);
						}
					else 
						{
						LongBinaryL(counter);
						}
				break;
				default:
					iBuffer->Des().Format(KUnknownMessage);
				break;
				} // switch
			} // if

		iFile.Write(*iBuffer);
		iFile.Write(KCellEnd);
		
		} // for
	}