----------------------------------------------------------------------------
| 1518 | |
| 1519 | //---------------------------------------------------------------------------- |
| 1520 | int vtkClientServerStream::SetData(const unsigned char* data, size_t length) |
| 1521 | { |
| 1522 | // Reset and remove the byte order entry from the stream. |
| 1523 | this->Reset(); |
| 1524 | this->Internal->Data.erase(this->Internal->Data.begin(), this->Internal->Data.end()); |
| 1525 | |
| 1526 | // Store the given data in the stream. |
| 1527 | if (data) |
| 1528 | { |
| 1529 | this->Internal->Data.insert(this->Internal->Data.begin(), data, data + length); |
| 1530 | } |
| 1531 | |
| 1532 | // Parse the stream to fill in ValueOffsets and MessageIndexes and |
| 1533 | // to perform byte-swapping if necessary. |
| 1534 | if (this->ParseData()) |
| 1535 | { |
| 1536 | // Data have been byte-swapped to the native representation. |
| 1537 | #ifdef VTK_WORDS_BIGENDIAN |
| 1538 | this->Internal->Data[0] = vtkClientServerStream::BigEndian; |
| 1539 | #else |
| 1540 | this->Internal->Data[0] = vtkClientServerStream::LittleEndian; |
| 1541 | #endif |
| 1542 | return 1; |
| 1543 | } |
| 1544 | else |
| 1545 | { |
| 1546 | // Data are invalid. Reset the stream and report failure. |
| 1547 | this->Reset(); |
| 1548 | return 0; |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | //---------------------------------------------------------------------------- |
| 1553 | int vtkClientServerStream::ParseData() |