------------------------------------------------------------------------------
| 885 | |
| 886 | //------------------------------------------------------------------------------ |
| 887 | size_t vtkXMLDataParser::ReadAsciiData( |
| 888 | void* buffer, vtkTypeUInt64 startWord, size_t numWords, int wordType) |
| 889 | { |
| 890 | // Skip real read if aborting. |
| 891 | if (this->Abort) |
| 892 | { |
| 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | // We assume that ascii data are not very large and parse the entire |
| 897 | // block into memory. |
| 898 | this->UpdateProgress(0); |
| 899 | |
| 900 | // Parse the ascii data from the file. |
| 901 | if (!this->ParseAsciiData(wordType)) |
| 902 | { |
| 903 | return 0; |
| 904 | } |
| 905 | |
| 906 | // Make sure we don't read outside the range of data available. |
| 907 | vtkTypeUInt64 endWord = startWord + numWords; |
| 908 | if (this->AsciiDataBufferLength < startWord) |
| 909 | { |
| 910 | return 0; |
| 911 | } |
| 912 | endWord = std::min<vtkTypeUInt64>(endWord, this->AsciiDataBufferLength); |
| 913 | size_t wordSize = this->GetWordTypeSize(wordType); |
| 914 | size_t actualWords = endWord - startWord; |
| 915 | size_t actualBytes = wordSize * actualWords; |
| 916 | size_t startByte = wordSize * startWord; |
| 917 | |
| 918 | this->UpdateProgress(0.5); |
| 919 | |
| 920 | // Copy the data from the pre-parsed ascii data buffer. |
| 921 | if (buffer && actualBytes) |
| 922 | { |
| 923 | memcpy(buffer, this->AsciiDataBuffer + startByte, actualBytes); |
| 924 | } |
| 925 | |
| 926 | this->UpdateProgress(1); |
| 927 | |
| 928 | return this->Abort ? 0 : actualWords; |
| 929 | } |
| 930 | |
| 931 | //------------------------------------------------------------------------------ |
| 932 | size_t vtkXMLDataParser::ReadInlineData(vtkXMLDataElement* element, int isAscii, void* buffer, |
no test coverage detected