}
/**
- * Replaces "def*origName*" string with "def*newName*" string
+ * Replaces origName string with newName string in all lines of theFunc
+ * origName must be preceeded by space and end by space or '('.
*/
bool replaceName( SUPERV::ListOfStrings_var& theFunc, const QString& origName, const QString& newName ) {
- // asv : 30.12.04 : it's a mistake to replace all function_name-s in all function_strings.
- // must be only in "def XXX():", with "do-while" I want to skip all empty and comment lines..
- int i( 0 ), index( -1 );
- do {
+ for ( int i = 0, n = theFunc->length(); i < n; i++ ) {
QString aLine( theFunc[i] );
- index = aLine.find(origName);
- if ( index >= 0 && aLine.startsWith( "def" ) ) { // looking for "def*origName*"
- theFunc[i] = aLine.replace( index, origName.length(), newName ).latin1();
- return true;
+ int index = aLine.find( origName, 0 ); // find FIRST occurance of origName in aLine
+ while ( index >= 0 ) {
+ bool preceedingCharOk = ( index==0 || ( index > 0 && aLine[index-1].isSpace() ) );
+ const int ll = aLine.length();
+ const int ol = origName.length();
+ const int ni = index + ol;
+ bool nextCharOk = ( ll==ni || ( ll>ni && ( aLine[ni].isSpace() || aLine[ni]=='(' ) ) );
+ if ( preceedingCharOk && nextCharOk ) {
+ aLine = aLine.replace( index, origName.length(), newName );
+ theFunc[i] = aLine.latin1();
+ }
+ index = aLine.find( origName, index+newName.length() ); // find NEXT occurance of origName in aLine
}
- i++;
}
- while ( i < theFunc->length() );
- return false;
}
/**
}
}
+/**
+ * Constructor
+ */
+SUPERVGUI_Clipboard::SUPERVGUI_Clipboard( QObject* parent )
+: QObject( parent ) {
+}
+
+/**
+ * Destructor
+ */
+SUPERVGUI_Clipboard::~SUPERVGUI_Clipboard() {
+}
+
/**
* Called on Paste Node command. Inserts a new node to the dataflow equal to the copied node.
* For InLine nodes the Python function name is changed ("_N" added).