newntui/discovermdi/src/disgraphnode.cpp
//------------------------------------------------------------------------------------
// This private function will parse the results of the relations script send as 
// a string of '/n' separated 4-digit IDs like shown:
// <source node> <source field> <target node> <target field> \n
//  .........................................................
// <source node> <source field> <target node> <target field> \n
// It will allocate memory for the array of
// node IDs and it will place all node ID's in this array. It is your task to free
// this array when no longer needed.
//------------------------------------------------------------------------------------
This private function will parse the results of the relations script send as
a string of '/n' separated 4-digit IDs like shown:
    \n

    \n
It will allocate memory for the array of
node IDs and it will place all node ID's in this array. It is your task to free
this array when no longer needed.
This private function will parse the results of the relations script send as a string of ' / n ' separated 4 - digit IDs like shown : \ n \ n It will allocate memory for the array of node IDs and it will place all node ID ' s in this array . It is your task to free this array when no longer needed .
int CDisGraph::ParseRelationResults(CString& str, int** srcNodeIDs, int** srcFieldIDs, int** targetNodeIDs, int** targetFieldIDs) {
register i;
int     idCounter;
int     colCounter;
CString val[4];
    idCounter=0;
	for(i=0;i<str.GetLength();i++) {
		if(str[i]=='\n') idCounter++;
	}
	if(idCounter==0) return 0;
	*srcNodeIDs     = new int [idCounter];
	*srcFieldIDs    = new int [idCounter];
	*targetNodeIDs  = new int [idCounter];
	*targetFieldIDs = new int [idCounter];
    idCounter=0;
	colCounter=0;
	val[0]="";
	val[1]="";
	val[2]="";
	val[3]="";
	for(i=0;i<str.GetLength();i++) {
		if((str[i]==' ' || str[i]==':') && (colCounter<3)) {
			colCounter++;
			continue;
		}
		if(str[i]=='\n') {
			int id1 = atoi(val[0]);
			int id2 = atoi(val[1]);
			int id3 = atoi(val[2]);
			int id4 = atoi(val[3]);
			(*srcNodeIDs)[idCounter]=id1;
			(*srcFieldIDs)[idCounter]=id2;
			(*targetNodeIDs)[idCounter]=id3;
			(*targetFieldIDs)[idCounter]=id4;
			val[0]="";
			val[1]="";
			val[2]="";
			val[3]="";
			if(colCounter>=3) idCounter++;
			colCounter=0;
			continue;
		}
		val[colCounter]+=str[i];
	}
	return idCounter;
}
int CDisGraph :: ParseRelationResults ( CString & str , int * * srcNodeIDs , int * * srcFieldIDs , int * * targetNodeIDs , int * * targetFieldIDs ) { register i ; int idCounter ; int colCounter ; CString val [ 4 ] ; idCounter = 0 ; for ( i = 0 ; i < str . GetLength ( ) ; i ++ ) { if ( str [ i ] == ' \n ' ) idCounter ++ ; } if ( idCounter == 0 ) return 0 ; * srcNodeIDs = new int [ idCounter ] ; * srcFieldIDs = new int [ idCounter ] ; * targetNodeIDs = new int [ idCounter ] ; * targetFieldIDs = new int [ idCounter ] ; idCounter = 0 ; colCounter = 0 ; val [ 0 ] = " " ; val [ 1 ] = " " ; val [ 2 ] = " " ; val [ 3 ] = " " ; for ( i = 0 ; i < str . GetLength ( ) ; i ++ ) { if ( ( str [ i ] == ' ' || str [ i ] == ' ' ) && ( colCounter < 3 ) ) { colCounter ++ ; continue ; } if ( str [ i ] == ' \n ' ) { int id1 = atoi ( val [ 0 ] ) ; int id2 = atoi ( val [ 1 ] ) ; int id3 = atoi ( val [ 2 ] ) ; int id4 = atoi ( val [ 3 ] ) ; ( * srcNodeIDs ) [ idCounter ] = id1 ; ( * srcFieldIDs ) [ idCounter ] = id2 ; ( * targetNodeIDs ) [ idCounter ] = id3 ; ( * targetFieldIDs ) [ idCounter ] = id4 ; val [ 0 ] = " " ; val [ 1 ] = " " ; val [ 2 ] = " " ; val [ 3 ] = " " ; if ( colCounter >= 3 ) idCounter ++ ; colCounter = 0 ; continue ; } val [ colCounter ] += str [ i ] ; } return idCounter ; }
This private function will parse the results of the relations script send as
a string of '/n' separated 4-digit IDs like shown:
<source node> <source field> <target node> <target field> \n
.........................................................
<source node> <source field> <target node> <target field> \n
It will allocate memory for the array of
node IDs and it will place all node ID's in this array.
This private function will parse the results of the relations script send as a string of ' / n ' separated 4 - digit IDs like shown : <source node > <source field > <target node > <target field > \ n ......................................................... <source node > <source field > <target node > <target field > \ n It will allocate memory for the array of node IDs and it will place all node ID ' s in this array .