------------------------------------------------------------------------------
| 298 | |
| 299 | //------------------------------------------------------------------------------ |
| 300 | int vtkDelimitedTextReader::ReadData(vtkTable* output_table) |
| 301 | { |
| 302 | this->LastError = ""; |
| 303 | |
| 304 | if (!this->PedigreeIdArrayName) |
| 305 | { |
| 306 | vtkErrorMacro("You must specify a pedigree id array name"); |
| 307 | return 1; |
| 308 | } |
| 309 | |
| 310 | if (!this->ReadFromInputString && !this->FileName) |
| 311 | { |
| 312 | vtkWarningMacro("Cannot read from file without a file name set. Nothing read."); |
| 313 | return 1; |
| 314 | } |
| 315 | |
| 316 | std::unique_ptr<std::istream> input_stream = this->OpenStream(); |
| 317 | if (!input_stream) |
| 318 | { |
| 319 | vtkWarningMacro("Unable to open file, ReadData aborted."); |
| 320 | return 1; |
| 321 | } |
| 322 | |
| 323 | this->ReadBOM(input_stream.get()); |
| 324 | |
| 325 | auto transCodec = vtkSmartPointer<vtkTextCodec>::Take(this->CreateTextCodec(input_stream.get())); |
| 326 | |
| 327 | char tstring[2]; |
| 328 | tstring[1] = '\0'; |
| 329 | tstring[0] = this->StringDelimiter; |
| 330 | // don't use Set* methods since they change the MTime in |
| 331 | // RequestData() !!!!! |
| 332 | std::string fieldDelimiterCharacters = this->FieldDelimiterCharacters; |
| 333 | if (this->AddTabFieldDelimiter) |
| 334 | { |
| 335 | fieldDelimiterCharacters.push_back('\t'); |
| 336 | } |
| 337 | this->UnicodeFieldDelimiters = fieldDelimiterCharacters; |
| 338 | this->UnicodeStringDelimiters = tstring; |
| 339 | |
| 340 | if (nullptr == transCodec) |
| 341 | { |
| 342 | // should this use the locale instead?? |
| 343 | return 1; |
| 344 | } |
| 345 | |
| 346 | try |
| 347 | { |
| 348 | vtkDelimitedTextCodecIteratorPrivate iterator(this->SkippedRecords, this->MaxRecords, |
| 349 | this->UnicodeRecordDelimiters, this->UnicodeFieldDelimiters, this->UnicodeStringDelimiters, |
| 350 | this->UnicodeWhitespace, this->CommentCharacters, this->UnicodeEscapeCharacter, |
| 351 | this->HaveHeaders, this->MergeConsecutiveDelimiters, this->UseStringDelimiter, |
| 352 | this->DetectNumericColumns, this->ForceDouble, this->DefaultIntegerValue, |
| 353 | this->DefaultDoubleValue, output_table); |
| 354 | |
| 355 | transCodec->ToUnicode(*input_stream, iterator); |
| 356 | iterator.ReachedEndOfInput(); |
| 357 |
no test coverage detected