public method IO2GAccountRow.getCell

Brief

Gets value of a table cell.

Declaration
C++
virtual const void *  getCell (int column) = 0

Parameters
column

The index of the column. The index should be between 0 and columns().size() - 1.

Returns

Returns the cell value that can be of different types. To determine a type, it is necessary to get a column by using the IO2GGenericTableResponseReader.columns and the IO2GTableColumnCollection.get methods. The index passed to the latter method should be the same as the column parameter. The type of value is defined by using the IO2GTableColumn.getType method. The IO2GTableColumn::O2GTableColumnType enumerator returned by the above method contains the returned value type. A client application must cast void* data to the returned type and copy the value.
Column types and cast operations:

Column type

getCell value

IO2GTableColumn.Integer

The method returns a pointer to a 32-bit integer value on a 32-bit operation system or a 64 bit integer on a 64-bit system.
Cast operation: int value = *(int*)reader.getCell(columnIndex);

IO2GTableColumn.Double

The method returns a pointer to a 64-bit floating-point value.
Cast operation: double value = *(double*)reader.getCell(column);

IO2GTableColumn.Boolean

The method returns a pointer to a boolean value.
Cast operation: bool value = *(bool*)reader.getCell(column);

IO2GTableColumn.Date

The method returns a pointer to a 64-bit floating-point value.
Cast operation: double OLEdate= *(double*)reader.getCell(column);

The date is in the OLE Automation Date format. An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, December 30, 1899, and whose fractional component represents the time on that day divided by 24.

If it is not specified explicitly, all the date/time values are in the UTC time zone.

IO2GTableColumn.String

The method returns a pointer to a zero-terminated ASCII string.
Cast operation: std::string value = (const char*)reader.getCell(column);

Details

The method is used to work with an abstract table. The method provides common access to a row value independently of a row type (a table type).

Example

Prints rows by using a GenericTableResponseReader [hide]

    void printGenericTableInterface(IO2GGenericTableResponseReader *genericReader)
    {
    char szBuffer[3072];
    IO2GTableColumnCollection *columns = genericReader->columns();
 
    // Print table values
    for (int i = 0; i < genericReader->size(); i++)
    {
        std::ostringstream stream;
        int count = columns->size();
        IO2GRow *row = genericReader->getGenericRow(i);
        for (int j = 0; j < count; j++)
        {
            const void* value = row->getCell(j);
            IO2GTableColumn *column = columns->get(j);
            std::string sIsValid = row->isCellValid(j) ? "True" : "False";
            switch (column->getType())
            {
            case IO2GTableColumn::Integer:
            {
                int iValue = *(const int*)(value);
                stream << column->getID() << "=" << iValue << " Valid=" << sIsValid << " ";
            }
            break;
            case IO2GTableColumn::Double:
            {
                double dblValue = *(const double*)(value);
                stream << column->getID() << "=" << dblValue << " Valid=" << sIsValid << " ";
            }
            break;
            case IO2GTableColumn::Boolean:
            {
                bool bValue = *(const bool*)(value);
                const char* value = bValue ? "True" : "False";
                stream << column->getID() << "=" << value << " Valid=" << sIsValid << " ";
            }
            break;
            case IO2GTableColumn::Date:
            {
                DATE date = *(DATE*)(value);
                std::string sDate = dateToString(date);
                stream << column->getID() << "=" << sDate.c_str() << " Valid=" << sIsValid << " ";
            }
            break;
            case IO2GTableColumn::String:
            {
                const char* szValue = (const char*)value;
                stream << column->getID() << "=" << szValue << " Valid=" << sIsValid << " ";
            }
            break;
            }
            column->release();
        }
        row->release();!
        stream << std::ends;
        std::cout << stream.str().c_str();
    }
    columns->release();
 
}

Declared in IO2GRow

back