------------------------------------------------------------------------------
| 186 | |
| 187 | //------------------------------------------------------------------------------ |
| 188 | void vtkBiomTableReader::ParseDataType() |
| 189 | { |
| 190 | // find "matrix_element_type": |
| 191 | size_t pos1 = this->FileContents.find("\"matrix_element_type\":"); |
| 192 | if (pos1 == std::string::npos) |
| 193 | { |
| 194 | vtkErrorMacro(<< "matrix_element_type not found in input file"); |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | // find : |
| 199 | size_t pos2 = this->FileContents.find(':', pos1 + 1); |
| 200 | if (pos2 == std::string::npos) |
| 201 | { |
| 202 | vtkErrorMacro(<< "matrix_element_type field not formatted properly"); |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | // find first double quote |
| 207 | size_t pos3 = this->FileContents.find('\"', pos2 + 1); |
| 208 | if (pos3 == std::string::npos) |
| 209 | { |
| 210 | vtkErrorMacro(<< "matrix_element_type field not formatted properly"); |
| 211 | return; |
| 212 | } |
| 213 | |
| 214 | // find second double quote |
| 215 | size_t pos4 = this->FileContents.find('\"', pos3 + 1); |
| 216 | if (pos4 == std::string::npos) |
| 217 | { |
| 218 | vtkErrorMacro(<< "matrix_element_type field not formatted properly"); |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | // element type lies between these quotes |
| 223 | std::string data_type = this->FileContents.substr(pos3 + 1, pos4 - pos3 - 1); |
| 224 | if (data_type == "int") |
| 225 | { |
| 226 | this->DataType = VTK_INT; |
| 227 | } |
| 228 | else if (data_type == "float") |
| 229 | { |
| 230 | this->DataType = VTK_FLOAT; |
| 231 | } |
| 232 | else if (data_type == "unicode") |
| 233 | { |
| 234 | this->DataType = VTK_STRING; |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | vtkErrorMacro(<< "unrecognized value found for matrix_element_type"); |
| 239 | this->DataType = VTK_VOID; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | //------------------------------------------------------------------------------ |
| 244 | void vtkBiomTableReader::InitializeData() |