------------------------------------------------------------------------------ Returns 0 for end of file. Returns 1 for start block, Returns 2 for parameter-value pair (occurs after 1 but before 3). Returns 3 for termination of start block. Returns 4 for string inside block. Puts string in retVal. (param = nullptr) Returns 5 for end block. ======= The statistics should be instance variables ...
| 195 | // ======= |
| 196 | // The statistics should be instance variables ... |
| 197 | int vtkPDataSetReader::ReadXML(istream* file, char** retBlock, char** retParam, char** retVal) |
| 198 | { |
| 199 | static char str[1024]; |
| 200 | static char* ptr = nullptr; |
| 201 | static char block[256]; |
| 202 | static char param[256]; |
| 203 | static char value[512]; |
| 204 | // I could keep track of the blocks on a stack, but I don't need to. |
| 205 | static int inStartBlock = 0; |
| 206 | char* tmp; |
| 207 | |
| 208 | // Initialize the strings. |
| 209 | if (ptr == nullptr) |
| 210 | { |
| 211 | block[0] = param[0] = value[0] = '\0'; |
| 212 | } |
| 213 | |
| 214 | // Skip white space |
| 215 | // We could do this with a get char ... |
| 216 | while (ptr == nullptr || *ptr == ' ' || *ptr == '\t' || *ptr == '\n' || *ptr == '\0') |
| 217 | { |
| 218 | if (ptr == nullptr || *ptr == '\0') |
| 219 | { // At the end of a line. Read another. |
| 220 | file->getline(str, 1024); |
| 221 | if (file->fail()) |
| 222 | { |
| 223 | *retBlock = nullptr; |
| 224 | *retParam = nullptr; |
| 225 | *retVal = nullptr; |
| 226 | return 0; |
| 227 | } |
| 228 | str[1023] = '\0'; |
| 229 | ptr = str; |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | ++ptr; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | // Handle normal end block. </Block> |
| 238 | if (!inStartBlock && ptr[0] == '<' && ptr[1] == '/') |
| 239 | { // Assumes no spaces |
| 240 | ptr += 2; |
| 241 | // We could check to see if the block name matches the start block... |
| 242 | // Copy block name into block var. |
| 243 | tmp = block; |
| 244 | while (*ptr != '>' && *ptr != ' ' && *ptr != '\0') |
| 245 | { |
| 246 | *tmp++ = *ptr++; |
| 247 | } |
| 248 | *tmp = '\0'; |
| 249 | // Now scan to the end of the end block. |
| 250 | while (*ptr != '>' && *ptr != '\0') |
| 251 | { |
| 252 | *tmp++ = *ptr++; |
| 253 | } |
| 254 | *retBlock = block; |
no outgoing calls
no test coverage detected