MCPcopy Create free account
hub / github.com/Kitware/ParaView / ExpandMessage

Method ExpandMessage

Remoting/ClientServerStream/vtkClientServerInterpreter.cxx:574–659  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

572
573//----------------------------------------------------------------------------
574int 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.

Callers 2

ProcessCommandInvokeMethod · 0.95
ProcessCommandAssignMethod · 0.95

Calls 8

GetMessageFromIDMethod · 0.95
ProcessStreamMethod · 0.95
GetNumberOfMessagesMethod · 0.80
GetNumberOfArgumentsMethod · 0.80
GetArgumentMethod · 0.80
GetArgumentTypeMethod · 0.80
ResetMethod · 0.45
GetCommandMethod · 0.45

Tested by

no test coverage detected