| 77 | //------------------------------------------------------------------------------ |
| 78 | |
| 79 | vtkVariant vtkPostgreSQLQuery::DataValue(vtkIdType column) |
| 80 | { |
| 81 | if (!this->IsActive()) |
| 82 | { |
| 83 | vtkWarningMacro("DataValue() called on inactive query"); |
| 84 | return vtkVariant(); |
| 85 | } |
| 86 | else if (column < 0 || column >= this->GetNumberOfFields()) |
| 87 | { |
| 88 | vtkWarningMacro("DataValue() called with out-of-range column index " << column); |
| 89 | return vtkVariant(); |
| 90 | } |
| 91 | else if (this->QueryInternals->CurrentRow < 0) |
| 92 | { |
| 93 | vtkWarningMacro( |
| 94 | "DataValue() cannot be called before advancing to the first row with NextRow()."); |
| 95 | return vtkVariant(); |
| 96 | } |
| 97 | |
| 98 | // Since null is independent of data type, check that next |
| 99 | if (PQgetisnull(this->QueryInternals->QueryResults, this->QueryInternals->CurrentRow, column)) |
| 100 | { |
| 101 | return vtkVariant(); |
| 102 | } |
| 103 | |
| 104 | int colType = this->GetFieldType(column); |
| 105 | bool isBinary = this->IsColumnBinary(column); |
| 106 | const char* rawData = this->GetColumnRawData(column); |
| 107 | switch (colType) |
| 108 | { |
| 109 | case VTK_VOID: |
| 110 | return vtkVariant(); |
| 111 | case VTK_BIT: |
| 112 | { |
| 113 | return ConvertStringToBoolean(isBinary, rawData); |
| 114 | } |
| 115 | case VTK_CHAR: |
| 116 | case VTK_SIGNED_CHAR: |
| 117 | { |
| 118 | return ConvertStringToSignedChar(isBinary, rawData); |
| 119 | } |
| 120 | case VTK_UNSIGNED_CHAR: |
| 121 | { |
| 122 | return ConvertStringToUnsignedChar(isBinary, rawData); |
| 123 | } |
| 124 | case VTK_SHORT: |
| 125 | { |
| 126 | return ConvertStringToSignedShort(isBinary, rawData); |
| 127 | } |
| 128 | case VTK_UNSIGNED_SHORT: |
| 129 | { |
| 130 | return ConvertStringToUnsignedShort(isBinary, rawData); |
| 131 | } |
| 132 | case VTK_INT: |
| 133 | { |
| 134 | return ConvertStringToSignedInt(isBinary, rawData); |
| 135 | } |
| 136 | case VTK_UNSIGNED_INT: |