From 087145a41802fc856467d40a1379f31bc1401172 Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 8 Oct 2007 07:50:27 +0000 Subject: [PATCH] NPAL16955: syntax storage in a python supervisiongraph. Correct \\ case. --- src/GraphBase/DataFlowBase_ComputingNode.cxx | 44 ++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index 51b902f..0328a38 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -35,11 +35,32 @@ using namespace std; static string protectQuotes (const string theText) { string aRes (theText); - for (unsigned int pos = 0; pos < aRes.size(); pos+=2) { + unsigned int pos; + + // screen back slash + for (pos = 0; pos < aRes.size(); pos++) { + pos = aRes.find("\\", pos); + if (pos < 0 || pos > aRes.size()) break; + + aRes.insert(pos, "\\"); + pos++; + + // screen symbol after back slash (except single quote, which will be processed below) + if (pos + 1 < aRes.size() && aRes[pos + 1] != '\'') { + aRes.insert(pos + 1, "\\"); + pos += 2; + } + } + + // screen single quote + for (pos = 0; pos < aRes.size(); pos++) { pos = aRes.find("'", pos); if (pos < 0 || pos > aRes.size()) break; - aRes.replace(pos, 1, "\\\'"); + + aRes.insert(pos, "\\"); + pos++; } + return aRes; } @@ -67,7 +88,7 @@ static void InitFields( //SUPERV::KindOfNode &_Kind , _FirstCreation.Hour = _LastModification.Hour = Tm->tm_hour; _FirstCreation.Day = _LastModification.Day = Tm->tm_mday; _FirstCreation.Month = _LastModification.Month = Tm->tm_mon + 1; - _FirstCreation.Year = _LastModification.Year = Tm->tm_year + 1900; + _FirstCreation.Year = _LastModification.Year = Tm->tm_year + 1900; _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ; strcpy( _EditorRelease , SuperVision_Version ) ; @@ -163,7 +184,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , // cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ; // } DefPortsOfNode( ORB , SALOME_ModuleCatalog::Service() , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ; - cdebug << "GraphBase::ComputingNode::ComputingNode " << this + cdebug << "GraphBase::ComputingNode::ComputingNode " << this << " Name '" << Name() << "' " << _FirstCreation << " " << _LastModification << endl ; } @@ -204,7 +225,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , _FirstCreation.Hour = _LastModification.Hour = Tm->tm_hour; _FirstCreation.Day = _LastModification.Day = Tm->tm_mday; _FirstCreation.Month = _LastModification.Month = Tm->tm_mon + 1; - _FirstCreation.Year = _LastModification.Year = Tm->tm_year + 1900; + _FirstCreation.Year = _LastModification.Year = Tm->tm_year + 1900; if ( NodeEditorRelease != NULLSTRING ) { _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ; @@ -259,7 +280,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ; - cdebug << "GraphBase::ComputingNode::ComputingNode " << this + cdebug << "GraphBase::ComputingNode::ComputingNode " << this << " Name '" << Name() << "' KindOfNode " << Kind() << " ServiceName '" << ServiceName() << "' In(" << ServiceInParameter().length() @@ -269,7 +290,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , } GraphBase::ComputingNode::~ComputingNode() { - cdebug << "GraphBase::ComputingNode::~ComputingNode " << this + cdebug << "GraphBase::ComputingNode::~ComputingNode " << this << " Name() "<< Name() << " _Comment " << (void *) _Comment << " " << _Comment << " " << endl ; } @@ -288,7 +309,7 @@ GraphBase::ComputingNode::~ComputingNode() { SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const { // cdebug << "GraphBase::ComputingNode::FirstCreation " -// << " Name '" << Name() << "' " << _FirstCreation << " " +// << " Name '" << Name() << "' " << _FirstCreation << " " // << _LastModification << endl ; return _FirstCreation; } @@ -363,7 +384,7 @@ void GraphBase::ComputingNode::NodePort( const char * NodeName , bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName, bool isInput ) { bool RetVal = false ; if ( isInput ) { // mkr : PAL8060 - // we have to know the type of the port, because of input and output ports + // we have to know the type of the port, because of input and output ports // belong to one node may have the same names const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ; if ( thePort ) { @@ -952,7 +973,7 @@ bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode , << LinkedFromNodesSize() << " ERROR false" << endl; return false ; } -// We have to check that all nodes linked from that node go to the beginning of LoopNode : +// We have to check that all nodes linked from that node go to the beginning of LoopNode : for ( i = 0 ; i < LinkedFromNodesSize() ; i++ ) { GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ; cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ; @@ -1421,7 +1442,7 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ; } } -// f << Tabs << "" << endl ; +// f << Tabs << "" << endl ; // f << Tabs << "" << endl ; QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ; @@ -2056,4 +2077,3 @@ ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) { // cdebug_out << "operator<< GraphEditor::Date" << endl; return fOut; } - -- 2.39.2