----------------------------------------------------------------------------
| 1551 | |
| 1552 | //---------------------------------------------------------------------------- |
| 1553 | int vtkClientServerStream::ParseData() |
| 1554 | { |
| 1555 | // Make sure we have at least one byte. |
| 1556 | if (this->Internal->Data.empty()) |
| 1557 | { |
| 1558 | return 0; |
| 1559 | } |
| 1560 | |
| 1561 | // We are not modifying the vector size. It is safe to use pointers |
| 1562 | // into it. |
| 1563 | unsigned char* begin = &*this->Internal->Data.begin(); |
| 1564 | unsigned char* end = begin + this->Internal->Data.size(); |
| 1565 | |
| 1566 | // Save the byte order. |
| 1567 | int order = *begin; |
| 1568 | |
| 1569 | // Traverse the data until no more commands are found. |
| 1570 | unsigned char* data = begin + 1; |
| 1571 | while (data && data < end) |
| 1572 | { |
| 1573 | // Parse the command. |
| 1574 | data = this->ParseCommand(order, data, begin, end); |
| 1575 | |
| 1576 | // Parse the arguments until End is reached. |
| 1577 | int foundEnd = 0; |
| 1578 | while (!foundEnd && data && data < end) |
| 1579 | { |
| 1580 | // Parse the type identifier. |
| 1581 | vtkClientServerStream::Types type; |
| 1582 | data = this->ParseType(order, data, begin, end, &type); |
| 1583 | if (!data) |
| 1584 | { |
| 1585 | break; |
| 1586 | } |
| 1587 | |
| 1588 | // Process the rest of the value based on its type. |
| 1589 | switch (type) |
| 1590 | { |
| 1591 | case vtkClientServerStream::int8_value: |
| 1592 | case vtkClientServerStream::uint8_value: |
| 1593 | case vtkClientServerStream::bool_value: |
| 1594 | data = this->ParseValue(order, data, end, 1); |
| 1595 | break; |
| 1596 | case vtkClientServerStream::int8_array: |
| 1597 | case vtkClientServerStream::uint8_array: |
| 1598 | data = this->ParseArray(order, data, end, 1); |
| 1599 | break; |
| 1600 | case vtkClientServerStream::int16_value: |
| 1601 | case vtkClientServerStream::uint16_value: |
| 1602 | data = this->ParseValue(order, data, end, 2); |
| 1603 | break; |
| 1604 | case vtkClientServerStream::int16_array: |
| 1605 | case vtkClientServerStream::uint16_array: |
| 1606 | data = this->ParseArray(order, data, end, 2); |
| 1607 | break; |
| 1608 | case vtkClientServerStream::id_value: |
| 1609 | case vtkClientServerStream::int32_value: |
| 1610 | case vtkClientServerStream::uint32_value: |
no test coverage detected