----------------------------------------------------------------------------
| 572 | |
| 573 | //---------------------------------------------------------------------------- |
| 574 | int vtkClientServerInterpreter::ExpandMessage( |
| 575 | const vtkClientServerStream& in, int inIndex, int startArgument, vtkClientServerStream& out) |
| 576 | { |
| 577 | // Reset the output and make sure we have input. |
| 578 | out.Reset(); |
| 579 | if (inIndex < 0 || inIndex >= in.GetNumberOfMessages()) |
| 580 | { |
| 581 | std::ostringstream error; |
| 582 | error << "ExpandMessage called to expand message index " << inIndex << " in a stream with " |
| 583 | << in.GetNumberOfMessages() << " messages." << ends; |
| 584 | this->LastResultMessage->Reset(); |
| 585 | *this->LastResultMessage << vtkClientServerStream::Error << error.str().c_str() |
| 586 | << vtkClientServerStream::End; |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | // Copy the command. |
| 591 | out << in.GetCommand(inIndex); |
| 592 | |
| 593 | // Just copy the first arguments. |
| 594 | int a; |
| 595 | for (a = 0; a < startArgument && a < in.GetNumberOfArguments(inIndex); ++a) |
| 596 | { |
| 597 | out << in.GetArgument(inIndex, a); |
| 598 | } |
| 599 | |
| 600 | // Expand id_value for remaining arguments. |
| 601 | for (a = startArgument; a < in.GetNumberOfArguments(inIndex); ++a) |
| 602 | { |
| 603 | if (in.GetArgumentType(inIndex, a) == vtkClientServerStream::id_value) |
| 604 | { |
| 605 | vtkClientServerID id; |
| 606 | in.GetArgument(inIndex, a, &id); |
| 607 | |
| 608 | // If the ID is in the map, expand it. Otherwise, leave it. |
| 609 | if (const vtkClientServerStream* tmp = this->GetMessageFromID(id)) |
| 610 | { |
| 611 | for (int b = 0; b < tmp->GetNumberOfArguments(0); ++b) |
| 612 | { |
| 613 | out << tmp->GetArgument(0, b); |
| 614 | } |
| 615 | } |
| 616 | else |
| 617 | { |
| 618 | out << in.GetArgument(inIndex, a); |
| 619 | } |
| 620 | } |
| 621 | else if (in.GetArgumentType(inIndex, a) == vtkClientServerStream::LastResult) |
| 622 | { |
| 623 | // Insert the last result value. |
| 624 | for (int b = 0; b < this->LastResultMessage->GetNumberOfArguments(0); ++b) |
| 625 | { |
| 626 | out << this->LastResultMessage->GetArgument(0, b); |
| 627 | } |
| 628 | } |
| 629 | else if (in.GetArgumentType(inIndex, a) == vtkClientServerStream::stream_value) |
| 630 | { |
| 631 | // Evaluate the expression and insert the result. |
no test coverage detected