Salome HOME
662a680d903424cb92f5fe94b02bba4ba6739a09
[modules/superv.git] / src / GraphBase / DataFlowBase_XmlHandler.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_XmlHandler.cxx
25 //  Author : Arnaud RES
26 //  Module : SUPERV
27 //  $Header$
28
29 using namespace std;
30 #include "DataFlowBase_XmlHandler.hxx"
31
32 #include <qstring.h>
33 //#include <qxmlattributes.h>
34 #include <qxml.h>
35
36 #define TRACE 0
37
38 //static string NULLSTRING = string("") ;
39
40 GraphBase::XmlHandler::XmlHandler( CORBA::ORB_ptr Orb ,
41                                    const bool aConstructor ) :
42   _Orb( Orb ) , dataflowxml(false), depth(0), constructor(aConstructor) {
43   int i ;
44   for ( i = 0 ; i < maxlevel ; i++ ) {
45     fieldname[i] = NULLSTRING ;
46     fieldvalue[i] = NULLSTRING ;
47     step[i] = 0 ;
48   }
49   VXSize = 0 ;
50 }
51
52 GraphBase::XmlHandler::XmlHandler() {}
53
54 GraphBase::XmlHandler::~XmlHandler() {}
55
56 QString GraphBase::XmlHandler::errorProtocol()
57 {
58     return errorProt;
59 }
60
61 bool GraphBase::XmlHandler::startDocument()
62 {
63     // at the beginning of parsing: do some initialization
64     errorProt = "";
65     return TRUE;
66 }
67
68 bool GraphBase::XmlHandler::startElement( const QString&, const QString&, 
69                                           const QString& qName, 
70                                           const QXmlAttributes& atts ) {
71   // do different actions depending on the name of the tag and the
72   // state you are in
73
74 #if TRACE
75   MESSAGE( "====================startElement " << depth << " " << qName)
76    
77 #endif
78   if ( qName == "dataflow" && depth == 0 ) {
79     // Dataflow detected
80     dataflowxml = TRUE;
81   }
82   if ( dataflowxml ) {
83     fieldname[depth++] = (const char * ) qName ;
84   }
85   if ( depth == maxlevel+1 )
86     return false ;
87   return dataflowxml ;
88
89 }
90
91 static bool returnfalse( GraphBase::XmlHandler *myXmlHandler ,
92                          const char *msg ,
93                          const QString& qName ) {
94   MESSAGE( "returnfalse ERROR qName " << qName << " " << msg
95            << " fieldname " << myXmlHandler->getfieldname(myXmlHandler->getdepth())
96            << " fieldvalue '"
97            << myXmlHandler->getfieldvalue(myXmlHandler->getdepth()) << "'" )
98   return false ;
99 }
100
101 bool GraphBase::XmlHandler::endElement( const QString&,
102                                         const QString&,
103                                         const QString& qName) {
104
105   if ( !dataflowxml ||
106        ( qName != QString( fieldname[depth].c_str() ) &&
107          fieldvalue[depth] != NULLSTRING ) ) {
108     MESSAGE( "endElement ERROR " << dataflowxml << " qName " << qName
109              << " fieldname" << fieldname[depth] << " fieldvalue "
110              << fieldvalue[depth] )
111     return returnfalse( this , "top" , qName ) ;
112   }
113   if ( fieldvalue[depth] == NULLSTRING )
114     depth -= 1 ;
115
116 #if TRACE
117   MESSAGE( " ==========endElement step[" << depth << "]="
118            << step[depth] << " qName " << qName << " fieldvalue '"
119            << fieldvalue[depth] << "'")
120 #endif
121   switch ( depth ) {
122     case 0 : {
123       if ( step[depth] == 0 && qName == "dataflow" ) {
124         dataflowxml = false ;
125       }
126       else
127         return returnfalse( this , "depth0" , qName ) ;
128       break ;
129     }
130
131     case 1 : {
132       switch ( step[depth] ) {
133         case 0 :
134           if ( qName == "info-list" ) {
135 //            aDataFlow.Info = aNode ;
136             step[depth]++ ;
137           }
138           else
139             return returnfalse( this , "depth1-0" , qName ) ;
140           break ;
141         case 1 :
142           if ( qName == "node-list" ) {
143 // node-list ok
144             step[depth]++ ;
145             step[3] = 16 ;
146             step[4] = 3 ;
147           }
148           else
149             return returnfalse( this , "depth1-1" , qName ) ;
150           break ;
151         case 2 :
152           if ( qName == "link-list" ) {
153             step[depth]++ ;
154           }
155           else
156             return returnfalse( this , "depth1-2" , qName ) ;
157           break ;
158         case 3 :
159           if ( qName == "data-list" ) {
160             step[depth]++ ;
161           }
162           else
163             return returnfalse( this , "depth1-3" , qName ) ;
164           break ;
165         default:
166           return returnfalse( this , "depth1-d" , qName ) ;
167           break ;
168         }
169       break ;
170     }
171
172     case 2 : {
173       switch ( step[depth] ) {
174         case 0 :
175           if ( qName == "node" ) {
176 // Node ok
177             if ( step[1] == 0 ) {
178               aDataFlow.Info = aNode ;
179             }
180             else if ( step[1] == 1 ) {
181               int sizenode = aDataFlow.Nodes.size() ;
182               aDataFlow.Nodes.resize( sizenode+1 ) ;                
183               aDataFlow.Nodes[ sizenode ] = aNode ;               
184             }
185             step[3] = 0 ;
186             aNode.theService.ServiceinParameter.length( 0 ) ;
187             aNode.theService.ServiceoutParameter.length( 0 ) ;
188             aNode.theListOfParameters.resize( 0 ) ;
189             aNode.theListOfFuncName.resize( 0 ) ;
190             aNode.theListOfPythonFunctions.resize( 0 ) ;
191             break ;
192           }
193           else if ( qName == "link" || qName == "data" ) {
194             step[depth]++ ;
195           }
196           else {
197             return returnfalse( this , "depth2-0" , qName ) ;
198             break ;
199           }
200         case 1 :
201           if ( qName == "link" ) {
202             int sizelink = aDataFlow.Links.size() ;
203             aDataFlow.Links.resize( sizelink+1 ) ;                
204             aDataFlow.Links[ sizelink ] = aLink ;               
205             if ( VXSize ) {
206               aDataFlow.Links[ sizelink ].aListOfCoords.resize( VXSize ) ;
207               int ic ;
208               for ( ic = 0 ; ic < VXSize ; ic++ ) {
209                 aDataFlow.Links[ sizelink ].aListOfCoords[ ic ].theX = VX[ic] ;
210                 aDataFlow.Links[ sizelink ].aListOfCoords[ ic ].theY = VY[ic] ;
211               }
212             }
213             VXSize = 0 ;
214             step[3] = 16 ;
215             break ;
216           }
217           else if ( qName == "data" ) {
218             step[depth]++ ;
219           }
220           else {
221             return returnfalse( this , "depth2-1" , qName ) ;
222             break ;
223           }
224         case 2 :
225           if ( qName == "data" ) {
226 // Data ok
227             if ( constructor ) {
228               int sizedata = aDataFlow.Datas.size() ;
229               aDataFlow.Datas.resize( sizedata+1 ) ;                
230               aDataFlow.Datas[ sizedata ] = aLink ;               
231               if ( VXSize ) {
232                 aDataFlow.Datas[ sizedata ].aListOfCoords.resize( VXSize ) ;
233                 int ic ;
234                 for ( ic = 0 ; ic < VXSize ; ic++ ) {
235                   aDataFlow.Datas[ sizedata ].aListOfCoords[ ic ].theX = VX[ic] ;
236                   aDataFlow.Datas[ sizedata ].aListOfCoords[ ic ].theY = VY[ic] ;
237                 }
238               }
239             }
240             VXSize = 0 ;
241             step[3] = 16 ;
242           }
243           else
244             return returnfalse( this , "depth2-2" , qName ) ;
245           break ;
246         default:
247           return returnfalse( this , "depth2-d" , qName ) ;
248           break ;
249         }
250       break ;
251     }
252
253     case 3 : {
254       switch ( step[depth] ) {
255         case 0 :
256           if ( qName == "component-name" ) {
257             if ( fieldvalue[depth] == NULLSTRING )
258               return returnfalse( this , "depth3-0" , qName ) ;
259             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
260               aNode.theComponentName = fieldvalue[depth].c_str() ;
261             else
262               aNode.theComponentName = "" ;
263             fieldvalue[depth] = NULLSTRING ;
264             step[depth]++ ;
265           }
266           else
267             return returnfalse( this , "depth3-0" , qName ) ;
268           break ;
269         case 1 :
270           if ( qName == "interface-name" ) {
271             if ( fieldvalue[depth] == NULLSTRING )
272               return returnfalse( this , "depth3-1" , qName ) ;
273             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
274               aNode.theInterfaceName = fieldvalue[depth].c_str() ;
275             else
276               aNode.theInterfaceName = "" ;
277             fieldvalue[depth] = NULLSTRING ;
278             step[depth]++ ;
279           }
280           else
281             return returnfalse( this , "depth3-1" , qName ) ;
282           break ;
283         case 2 :
284           if ( qName == "node-name" ) {
285             if ( fieldvalue[depth] == NULLSTRING )
286               return returnfalse( this , "depth3-2" , qName ) ;
287             aNode.theName = fieldvalue[depth].c_str() ;
288             fieldvalue[depth] = NULLSTRING ;
289             step[depth]++ ;
290           }
291           else
292             return returnfalse( this , "depth3-2" , qName ) ;
293           break ;
294         case 3 :
295           if ( qName == "kind" ) {
296             if ( fieldvalue[depth] == NULLSTRING )
297               return returnfalse( this , "depth3-3" , qName ) ;
298 // kind ok
299             sscanf( fieldvalue[depth].c_str() ,"%d" , (int * ) &aNode.theKind ) ;
300             fieldvalue[depth] = NULLSTRING ;
301             step[depth]++ ;
302             step[4] = 0 ;
303           }
304           else
305             return returnfalse( this , "depth3-3" , qName ) ;
306           break ;
307         case 4 :
308           if ( qName == "coupled-node" ) {
309             if ( fieldvalue[depth] == NULLSTRING )
310               return returnfalse( this , "depth3-4" , qName ) ;
311             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
312               aNode.theCoupledNode = fieldvalue[depth].c_str() ;
313             else
314               aNode.theCoupledNode = "" ;
315             fieldvalue[depth] = NULLSTRING ;
316             step[depth]++ ;
317             break ;
318           }
319           else
320             step[depth]++ ;
321 //            return returnfalse( this , "depth3-4" , qName ) ;
322 //          break ;
323         case 5 :
324           if ( qName == "service" ) {
325             if ( fieldvalue[depth] != NULLSTRING )
326               return returnfalse( this , "depth3-5" , qName ) ;
327             fieldvalue[depth] = NULLSTRING ;
328             step[depth]++ ;
329             step[4] = 6;
330             step[5] = 4 ;
331 // service ok
332           }
333           else
334             return returnfalse( this , "depth3-5" , qName ) ;
335           break ;
336         case 6 :
337           if ( qName == "Parameter-list" ) {
338             if ( fieldvalue[depth] != NULLSTRING )
339               return returnfalse( this , "depth3-6" , qName ) ;
340             fieldvalue[depth] = NULLSTRING ;
341             step[depth]++ ;
342             step[4] = 8 ;
343             step[5] = 8 ;
344 // Parameter-list ok
345           break ;
346           }
347           else
348             step[depth]++ ;
349             step[5] = 0 ;
350             step[6] = 0 ;
351 // NO Parameter-list
352 //            return returnfalse( this , "depth3-6" , qName ) ;
353 //          break ;
354         case 7 :
355           if ( qName == "PyFunction-list" ) {
356             if ( fieldvalue[depth] != NULLSTRING )
357               return returnfalse( this , "depth3-7" , qName ) ;
358             fieldvalue[depth] = NULLSTRING ;
359             step[depth]++ ;
360             step[5] = 0 ;
361             step[6] = 0 ;
362 // Parameter-list ok
363           break ;
364           }
365           else
366             step[depth]++ ;
367             step[5] = 0 ;
368             step[6] = 0 ;
369 // NO PyFunction-list
370 //            return returnfalse( this , "depth3-7" , qName ) ;
371 //          break ;
372         case 8 :
373           if ( qName == "creation-date" ) {
374             SUPERV::SDate D ;
375             char Date[23] ;
376             strcpy( Date , fieldvalue[depth].c_str() ) ;
377             int i ;
378             for ( i = 0 ; i < (int ) strlen(Date) ; i++ ) {
379               if ( Date[i] == '/' || Date[i] == '-' || Date[i] == ':' )
380                 Date[i] = ' ' ;
381             }
382 //            MESSAGE( "Date(" << Date << ")" );
383             int Day , Month , Year , Hour , Minute , Second ;
384             sscanf( Date ,"%d%d%d%d%d%d" , &Day ,
385                                            &Month ,
386                                            &Year ,
387                                            &Hour ,
388                                            &Minute ,
389                                            &Second ) ;
390             D.Day = Day ;
391             D.Month = Month ;
392             D.Year = Year ;
393             D.Hour = Hour ;
394             D.Minute = Minute ;
395             D.Second = Second ;
396             aNode.theFirstCreation = D ;
397             fieldvalue[depth] = NULLSTRING ;
398             step[depth]++ ;
399           }
400           else
401             return returnfalse( this , "depth3-8" , qName ) ;
402           break ;
403         case 9 :
404           if ( qName == "lastmodification-date" ) {
405             SUPERV::SDate D ;
406             char Date[23] ;
407             strcpy( Date , fieldvalue[depth].c_str() ) ;
408             int i ;
409             for ( i = 0 ; i < (int ) strlen(Date) ; i++ ) {
410               if ( Date[i] == '/' || Date[i] == '-' || Date[i] == ':' )
411                 Date[i] = ' ' ;
412             }
413 //            MESSAGE( "Date(" << Date << ")" );
414             int Day , Month , Year , Hour , Minute , Second ;
415             sscanf( Date ,"%d%d%d%d%d%d" , &Day ,
416                                            &Month ,
417                                            &Year ,
418                                            &Hour ,
419                                            &Minute ,
420                                            &Second ) ;
421             D.Day = Day ;
422             D.Month = Month ;
423             D.Year = Year ;
424             D.Hour = Hour ;
425             D.Minute = Minute ;
426             D.Second = Second ;
427             aNode.theLastModification = D ;
428             fieldvalue[depth] = NULLSTRING ;
429             step[depth]++ ;
430           }
431           else
432             return returnfalse( this , "depth3-9" , qName ) ;
433           break ;
434         case 10 :
435           if ( qName == "editor-release" ) {
436             aNode.theEditorRelease = fieldvalue[depth].c_str() ;
437             fieldvalue[depth] = NULLSTRING ;
438             step[depth]++ ;
439           }
440           else
441             return returnfalse( this , "depth3-10" , qName ) ;
442           break ;
443         case 11 :
444           if ( qName == "author" ) {
445             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
446               aNode.theAuthor = fieldvalue[depth].c_str() ;
447             else
448               aNode.theAuthor = "" ;
449             fieldvalue[depth] = NULLSTRING ;
450             step[depth]++ ;
451           }
452           else
453             return returnfalse( this , "depth3-11" , qName ) ;
454           break ;
455         case 12 :
456           if ( qName == "container" ) {
457             if ( fieldvalue[depth] == NULLSTRING )
458               return returnfalse( this , "depth3-12" , qName ) ;
459 // computer ok
460             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
461               aNode.theContainer = fieldvalue[depth].c_str() ;
462             else
463               aNode.theContainer = "" ;
464             fieldvalue[depth] = NULLSTRING ;
465             step[depth]++ ;
466           }
467           else
468             return returnfalse( this , "depth3-12" , qName ) ;
469           break ;
470         case 13 :
471           if ( qName == "comment" ) {
472             if ( fieldvalue[depth] == NULLSTRING )
473               return returnfalse( this , "depth3-13" , qName ) ;
474 // comment ok
475             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
476               aNode.theComment = fieldvalue[depth].c_str() ;
477             else
478               aNode.theComment = "" ;
479             fieldvalue[depth] = NULLSTRING ;
480             step[depth]++ ;
481           }
482           else
483             return returnfalse( this , "depth3-13" , qName ) ;
484           break ;
485         case 14 :
486           if ( qName == "x-position" ) {
487             if ( fieldvalue[depth] == NULLSTRING )
488               return returnfalse( this , "depth3-14" , qName ) ;
489             sscanf( fieldvalue[depth].c_str() , "%ld" , &aNode.theCoords.theX ) ;
490             fieldvalue[depth] = NULLSTRING ;
491             step[depth]++ ;
492 // x-position ok
493           }
494           else
495             return returnfalse( this , "depth3-14" , qName ) ;
496           break ;
497         case 15 :
498           if ( qName == "y-position" ) {
499             if ( fieldvalue[depth] == NULLSTRING )
500               return returnfalse( this , "depth3-15" , qName ) ;
501             sscanf( fieldvalue[depth].c_str() , "%ld" , &aNode.theCoords.theY ) ;
502             fieldvalue[depth] = NULLSTRING ;
503             step[depth]++ ;
504 // y-position ok
505           }
506           else
507             return returnfalse( this , "depth3-15" , qName ) ;
508           break ;
509         case 16 :
510           if ( qName == "fromnode-name" ) {
511             if ( fieldvalue[depth] == NULLSTRING )
512               return returnfalse( this , "depth3-16" , qName ) ;
513             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
514               aLink.FromNodeName = fieldvalue[depth].c_str() ;
515             else
516               aLink.FromNodeName = "" ;
517             fieldvalue[depth] = NULLSTRING ;
518             step[depth]++ ;
519             step[4] = 3 ;
520           }
521           else
522             return returnfalse( this , "depth3-16" , qName ) ;
523           break ;
524         case 17 :
525           if ( qName == "fromserviceparameter-name" ) {
526             if ( fieldvalue[depth] == NULLSTRING )
527               return returnfalse( this , "depth3-17" , qName ) ;
528             aLink.FromServiceParameterName = fieldvalue[depth].c_str() ;
529             fieldvalue[depth] = NULLSTRING ;
530             step[depth]++ ;
531           }
532           else
533             return returnfalse( this , "depth3-17" , qName ) ;
534           break ;
535         case 18 :
536           if ( qName == "tonode-name" ) {
537             if ( fieldvalue[depth] == NULLSTRING )
538               return returnfalse( this , "depth3-18" , qName ) ;
539             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
540               aLink.ToNodeName = fieldvalue[depth].c_str() ;
541             else
542               aLink.ToNodeName = "" ;
543             fieldvalue[depth] = NULLSTRING ;
544             step[depth]++ ;
545           }
546           else
547             return returnfalse( this , "depth3-18" , qName ) ;
548           break ;
549         case 19 :
550           if ( qName == "toserviceparameter-name" ) {
551             if ( fieldvalue[depth] == NULLSTRING )
552               return returnfalse( this , "depth3-19" , qName ) ;
553             aLink.ToServiceParameterName = fieldvalue[depth].c_str() ;
554             fieldvalue[depth] = NULLSTRING ;
555             step[depth]++ ;
556           }
557           else
558             return returnfalse( this , "depth3-19" , qName ) ;
559           step[5] = 2 ;
560           break ;
561         case 20 :
562           if ( qName == "data-value" ) {
563             if ( fieldvalue[depth] != NULLSTRING )
564               return returnfalse( this , "depth3-20" , qName ) ;
565 // data-value ok
566             step[depth]++ ;
567 //            step[4] = 3 ;
568             break ;
569           }
570           else
571             step[depth]++ ;
572 //            return returnfalse( this , "depth3-20" , qName ) ;
573 //          break ;
574         case 21 :
575           if ( qName == "coord-list" ) {
576             if ( fieldvalue[depth] != NULLSTRING )
577               return returnfalse( this , "depth3-21" , qName ) ;
578 // coord-list ok
579             step[depth] = 14 ;
580             step[4] = 5 ;
581           }
582           else
583             return returnfalse( this , "depth3-21" , qName ) ;
584           break ;
585         default:
586           return returnfalse( this , "depth3-d" , qName ) ;
587           break ;
588         }
589       break ;
590     }
591
592
593     case 4 : {
594       switch ( step[depth] ) {
595         case 0 :
596           if ( qName == "service-name" ) {
597             if ( fieldvalue[depth] == NULLSTRING )
598               return returnfalse( this , "depth4-0" , qName ) ;
599             if ( strcmp( fieldvalue[depth].c_str() , "?" ) )
600               aNode.theService.ServiceName = fieldvalue[depth].c_str() ;
601             else
602               aNode.theService.ServiceName = "" ;
603             aNode.theService.ServiceinParameter.length( 0 ) ;
604             aNode.theService.ServiceoutParameter.length( 0 ) ;
605             fieldvalue[depth] = NULLSTRING ;
606             step[depth]++ ;
607           }
608           else
609             return returnfalse( this , "depth4-0" , qName ) ;
610           break ;
611         case 1 :
612           if ( qName == "inParameter-list" ) {
613             if ( fieldvalue[depth] != NULLSTRING )
614               return returnfalse( this , "depth4-1" , qName ) ;
615             fieldvalue[depth] = NULLSTRING ;
616             step[depth]++ ;
617             step[5] = 1 ;
618             step[6] = 2 ; // First outParameter
619 // inParameterlist ok
620           }
621           else
622             return returnfalse( this , "depth4-1" , qName ) ;
623           break ;
624         case 2 :
625           if ( qName == "outParameter-list" ) {
626             if ( fieldvalue[depth] != NULLSTRING )
627               return returnfalse( this , "depth4-2" , qName ) ;
628             fieldvalue[depth] = NULLSTRING ;
629             step[depth] = 0 ;
630 // outParameterlist ok
631             step[5] = 0 ;
632             step[6] = 0 ;
633           }
634           else
635             return returnfalse( this , "depth4-2" , qName ) ;
636           break ;
637         case 3 :
638           if ( qName == "value-type" ) {
639             if ( fieldvalue[depth] == NULLSTRING )
640               return returnfalse( this , "depth4-3" , qName ) ;
641             int Kind ;
642             sscanf( fieldvalue[depth].c_str() , "%d" , &Kind ) ;
643 //            switch ( D.Value.type()->kind() ) {
644             aLink.aLinkValue = CORBA::Any() ;
645             switch ( Kind ) {
646             case CORBA::tk_string: {
647               aLink.aLinkValue <<= (char *) NULL ;
648               char * t;
649               aLink.aLinkValue >>= t;
650 #if TRACE
651               MESSAGE( t << " (string)" );
652 #endif
653               break;
654             }
655             case CORBA::tk_double: {
656               aLink.aLinkValue <<= (double ) 0. ;
657               double d;
658               aLink.aLinkValue >>= d;
659 #if TRACE
660               MESSAGE( d << " (double)" );
661 #endif
662               break;
663             }
664             case CORBA::tk_long: {
665               aLink.aLinkValue <<= (long ) 0 ;
666               long l;
667               aLink.aLinkValue >>= l;
668 #if TRACE
669               MESSAGE( l << " (long)" );
670 #endif
671               break;
672             }
673             case CORBA::tk_objref: {
674 //              aLink.aLinkValue.replace(CORBA::_tc_Object, NULL);
675               aLink.aLinkValue <<= CORBA::Object::_nil() ;
676 #if TRACE
677               MESSAGE( " (object reference)" );
678 #endif
679               break;
680             }
681             default:
682               MESSAGE( "(other ERROR)" );
683             }
684             fieldvalue[depth] = NULLSTRING ;
685             step[depth]++ ;
686             break ;
687           }
688           else
689             step[depth]++ ;
690 //            return returnfalse( this , "depth4-3" , qName ) ;
691 //          break ;
692         case 4 :
693           if ( qName == "value" ) {
694             if ( fieldvalue[depth] == NULLSTRING )
695               return returnfalse( this , "depth4-4" , qName ) ;
696             if ( !strcmp( fieldvalue[depth].c_str() , "?" ) ) {
697 //              aLink.aLinkValue.Value = fieldvalue[depth].c_str() ;
698               aLink.aLinkValue = CORBA::Any() ; // ???
699             }
700             else {
701               switch ( aLink.aLinkValue.type()->kind() ) {
702               case CORBA::tk_string: {
703                 aLink.aLinkValue <<= fieldvalue[depth].c_str() ;
704                 char * t;
705                 aLink.aLinkValue >>= t;
706 #if TRACE
707                 MESSAGE( t << " (string)" );
708 #endif
709                 break;
710               }
711               case CORBA::tk_double: {
712                 double d;
713                 sscanf( fieldvalue[depth].c_str() , "%lf" , &d ) ;
714                 aLink.aLinkValue <<= d;
715 #if TRACE
716                 MESSAGE( d << " (double)" );
717 #endif
718                 break;
719               }
720               case CORBA::tk_long: {
721                 long l;
722                 sscanf( fieldvalue[depth].c_str() , "%ld" , &l ) ;
723                 aLink.aLinkValue <<= l;
724 #if TRACE
725                 MESSAGE( l << " (long)" );
726 #endif
727                 break;
728               }
729               case CORBA::tk_objref: {
730                 CORBA::Object_ptr ObjRef ;
731                 const char * IORObjRef = fieldvalue[depth].c_str() ;
732                 ObjRef = _Orb->string_to_object( IORObjRef ) ;
733                 aLink.aLinkValue <<= ObjRef;
734 #if TRACE
735                 MESSAGE( IORObjRef << "(object reference)" );
736 #endif
737                 break;
738               }
739               default: {
740                 aLink.aLinkValue <<= _Orb->string_to_object( fieldvalue[depth].c_str() ) ;
741                 MESSAGE( "(other ERROR)" );
742               }
743               }
744             }
745             fieldvalue[depth] = NULLSTRING ;
746             step[depth]++ ;
747             step[5] = 2 ;
748           break ;
749           }
750           else
751             step[depth]++ ;
752 //            return returnfalse( this , "depth4-4" , qName ) ;
753 //          break ;
754         case 5 :
755           if ( qName == "coord" ) {
756             if ( fieldvalue[depth] != NULLSTRING )
757               return returnfalse( this , "depth4-5" , qName ) ;
758             if ( VXSize == (int ) VX.size() ) {
759               VX.resize( VX.size() + 10 ) ;
760               VY.resize( VY.size() + 10 ) ;
761             }
762             VX[ VXSize ] = X ;
763             VY[ VXSize ] = Y ;
764             VXSize++ ;
765             step[5] = 2 ;
766           }
767           else
768             return returnfalse( this , "depth4-5" , qName ) ;
769           break ;
770         case 6 :
771           if ( qName == "inParameter" ) {
772             if ( fieldvalue[depth] != NULLSTRING )
773               return returnfalse( this , "depth4-6" , qName ) ;
774             int size = aNode.theListOfParameters.size() ;
775             aNode.theListOfParameters.resize( size+1 ) ;
776             aNode.theListOfParameters[size].theInParameter = aParameter ;
777             step[depth]++ ;
778 // One more aParameter input
779           }
780           else
781             return returnfalse( this , "depth4-6" , qName ) ;
782           break ;
783         case 7 :
784           if ( qName == "outParameter" ) {
785             if ( fieldvalue[depth] != NULLSTRING )
786               return returnfalse( this , "depth4-7" , qName ) ;
787             int size = aNode.theListOfParameters.size() ;
788             aNode.theListOfParameters[size-1].theOutParameter = aParameter ;
789 // One more aParameter output
790             step[4] = 6 ;
791             step[5] = 4 ;
792           }
793           else
794             return returnfalse( this , "depth4-7" , qName ) ;
795           break ;
796         case 8 :
797           if ( qName == "PyFunction" ) {
798             if ( fieldvalue[depth] != NULLSTRING )
799               return returnfalse( this , "depth4-8" , qName ) ;
800 // One more PyFunction
801             step[4] = 8 ;
802             step[5] = 8 ;
803           }
804           else
805             return returnfalse( this , "depth4-8" , qName ) ;
806           break ;
807         default:
808           return returnfalse( this , "depth4-d" , qName ) ;
809           break ;
810         }
811       break ;
812     }
813
814
815     case 5 : {
816       switch ( step[depth] ) {
817         case 0 :
818           if ( qName == "inParameter" ) {
819             if ( fieldvalue[depth] != NULLSTRING )
820               return returnfalse( this , "depth5-0" , qName ) ;
821             fieldvalue[depth] = NULLSTRING ;
822             int size = aNode.theService.ServiceinParameter.length() ;
823             aNode.theService.ServiceinParameter.length( size+1 ) ;
824             aNode.theService.ServiceinParameter[size] = aParameter ;
825 // One more aParameter input
826             step[6] = 0 ; // Next one
827           }
828           else
829             return returnfalse( this , "depth5-0" , qName ) ;
830           break ;
831         case 1 :
832           if ( qName == "outParameter" ) {
833             if ( fieldvalue[depth] != NULLSTRING )
834               return returnfalse( this , "depth5-1" , qName ) ;
835             fieldvalue[depth] = NULLSTRING ;
836             int size = aNode.theService.ServiceoutParameter.length() ;
837             aNode.theService.ServiceoutParameter.length( size+1 ) ;
838             aNode.theService.ServiceoutParameter[size] = aParameter ;
839 // One more aParameter Output
840             step[6] = 2 ; // Next one
841           }
842           else
843             return returnfalse( this , "depth5-1" , qName ) ;
844           break ;
845         case 2 :
846           if ( qName == "x" ) {
847             if ( fieldvalue[depth] == NULLSTRING )
848               return returnfalse( this , "depth5-2" , qName ) ;
849             sscanf( fieldvalue[depth].c_str() , "%d" , &X ) ;
850             fieldvalue[depth] = NULLSTRING ;
851             step[depth]++ ;
852           }
853           else
854             return returnfalse( this , "depth5-2" , qName ) ;
855           break ;
856         case 3 :
857           if ( qName == "y" ) {
858             if ( fieldvalue[depth] == NULLSTRING )
859               return returnfalse( this , "depth5-3" , qName ) ;
860             sscanf( fieldvalue[depth].c_str() , "%d" , &Y ) ;
861             fieldvalue[depth] = NULLSTRING ;
862           }
863           else
864             return returnfalse( this , "depth5-3" , qName ) ;
865           break ;
866         case 4 :
867           if ( qName == "inParameter-type" ) {
868             if ( fieldvalue[depth] == NULLSTRING )
869               return returnfalse( this , "depth5-4" , qName ) ;
870             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
871               aParameter.Parametertype = fieldvalue[depth].c_str() ;
872             }
873             else {
874               aParameter.Parametertype = "" ;
875             }
876             fieldvalue[depth] = NULLSTRING ;
877             step[depth]++ ;
878           }
879           else
880             return returnfalse( this , "depth5-4" , qName ) ;
881           break ;
882         case 5 :
883           if ( qName == "inParameter-name" ) {
884             if ( fieldvalue[depth] == NULLSTRING )
885               return returnfalse( this , "depth5-5" , qName ) ;
886             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
887               aParameter.Parametername = fieldvalue[depth].c_str() ;
888             }
889             else {
890               aParameter.Parametername = "" ;
891             }
892             fieldvalue[depth] = NULLSTRING ;
893             step[depth]++ ;
894           }
895           else
896             return returnfalse( this , "depth5-5" , qName ) ;
897           break ;
898         case 6 :
899           if ( qName == "outParameter-type" ) {
900             if ( fieldvalue[depth] == NULLSTRING )
901               return returnfalse( this , "depth5-6" , qName ) ;
902             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
903               aParameter.Parametertype = fieldvalue[depth].c_str() ;
904             }
905             else {
906               aParameter.Parametertype = "" ;
907             }
908             fieldvalue[depth] = NULLSTRING ;
909             step[depth]++ ;
910           }
911           else
912             return returnfalse( this , "depth5-6" , qName ) ;
913           break ;
914         case 7 : 
915           if ( qName == "outParameter-name" ) {
916             if ( fieldvalue[depth] == NULLSTRING )
917               return returnfalse( this , "depth5-7" , qName ) ;
918             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
919               aParameter.Parametername = fieldvalue[depth].c_str() ;
920             }
921             else {
922               aParameter.Parametername = "" ;
923             }
924             fieldvalue[depth] = NULLSTRING ;
925             step[depth]++ ;
926           }
927           else
928             return returnfalse( this , "depth5-7" , qName ) ;
929           break ;
930         case 8 :
931           if ( qName == "FuncName" ) {
932             if ( fieldvalue[depth] == NULLSTRING )
933               return returnfalse( this , "depth5-8" , qName ) ;
934             int l = aNode.theListOfFuncName.size() ;
935             aNode.theListOfFuncName.resize( l+1 ) ;
936             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
937               aNode.theListOfFuncName[ l ] = fieldvalue[depth].c_str() ;
938             }
939             else {
940               aNode.theListOfFuncName[ l ] = "" ;
941             }
942             aNode.theListOfPythonFunctions.resize( l+1 ) ;
943             aNode.theListOfPythonFunctions[ l ] = new SUPERV::ListOfStrings() ;
944 #if TRACE
945             MESSAGE( " ==========theListOfFuncName/theListOfPythonFunctions size "
946                      << l+1 )
947 #endif
948             fieldvalue[depth] = NULLSTRING ;
949             step[depth]++ ;
950           }
951           else
952             return returnfalse( this , "depth5-8" , qName ) ;
953           break ;
954         case 9 :
955           if ( qName == "PyFunc" ) {
956             if ( fieldvalue[depth] == NULLSTRING )
957               return returnfalse( this , "depth5-9" , qName ) ;
958             int l = aNode.theListOfPythonFunctions.size() - 1 ;
959             SUPERV::ListOfStrings aPythonFunction = *aNode.theListOfPythonFunctions[ l ] ;
960             int ll = aPythonFunction.length() ;
961             aPythonFunction.length( ll+1 ) ;
962             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
963               aPythonFunction[ ll ] = fieldvalue[depth].c_str() ;
964             }
965             else {
966               aPythonFunction[ ll ] = NULLSTRING ;
967             }
968             if ( ll ) {
969               aNode.theListOfPythonFunctions.resize( l ) ;
970               aNode.theListOfPythonFunctions.resize( l+1 ) ;
971             }
972             aNode.theListOfPythonFunctions[ l ] = new SUPERV::ListOfStrings( aPythonFunction ) ;
973 #if TRACE
974             MESSAGE( " ==========theListOfPythonFunctions[" << l << "] size " << ll+1
975                      << " [" << ll << "] = " << aPythonFunction[ ll ] )
976 #endif
977             fieldvalue[depth] = NULLSTRING ;
978 //            step[depth]++ ;
979           }
980           else
981             return returnfalse( this , "depth5-9" , qName ) ;
982           break ;
983         default:
984           return returnfalse( this , "depth5-d" , qName ) ;
985           break ;
986         }
987       break ;
988     }
989
990     case 6 : {
991       switch ( step[depth] ) {
992         case 0 :
993           if ( qName == "inParameter-type" ) {
994             if ( fieldvalue[depth] == NULLSTRING )
995               return returnfalse( this , "depth6-0" , qName ) ;
996             aParameter.Parametertype = fieldvalue[depth].c_str() ;
997             fieldvalue[depth] = NULLSTRING ;
998             step[depth]++ ;
999           }
1000           else
1001             return returnfalse( this , "depth6-0" , qName ) ;
1002           break ;
1003         case 1 :
1004           if ( qName == "inParameter-name" ) {
1005             if ( fieldvalue[depth] == NULLSTRING )
1006               return returnfalse( this , "depth6-1" , qName ) ;
1007             aParameter.Parametername = fieldvalue[depth].c_str() ;
1008             fieldvalue[depth] = NULLSTRING ;
1009             step[depth]++ ;
1010           }
1011           else
1012             return returnfalse( this , "depth6-1" , qName ) ;
1013           break ;
1014         case 2 :
1015           if ( qName == "outParameter-type" ) {
1016             if ( fieldvalue[depth] == NULLSTRING )
1017               return returnfalse( this , "depth6-2" , qName ) ;
1018             aParameter.Parametertype = fieldvalue[depth].c_str() ;
1019             fieldvalue[depth] = NULLSTRING ;
1020             step[depth]++ ;
1021           }
1022           else
1023             return returnfalse( this , "depth6-2" , qName ) ;
1024           break ;
1025         case 3 :
1026           if ( qName == "outParameter-name" ) {
1027             if ( fieldvalue[depth] == NULLSTRING )
1028               return returnfalse( this , "depth6-3" , qName ) ;
1029             aParameter.Parametername = fieldvalue[depth].c_str() ;
1030             fieldvalue[depth] = NULLSTRING ;
1031             step[depth]++ ;
1032           }
1033           else
1034             return returnfalse( this , "depth6-3" , qName ) ;
1035           break ;
1036         default:
1037           return returnfalse( this , "depth6-d" , qName ) ;
1038           break ;
1039         }
1040       break ;
1041     }
1042   }
1043
1044   return TRUE;
1045 }
1046
1047
1048 bool GraphBase::XmlHandler::characters( const QString& ch ) {
1049   // we are not interested in whitespaces
1050   QString ch_simplified = ch.simplifyWhiteSpace();
1051   if ( ch_simplified.isEmpty() ) {
1052     return TRUE;
1053   }
1054   depth -= 1 ;
1055 #if TRACE
1056   MESSAGE( "characters step[" << depth << "]=" << step[depth]
1057        << " ch " << ch << " fieldvalue_must_be_NULL " << fieldvalue[depth] )
1058 #endif
1059   if ( depth < 0 || fieldvalue[depth] != NULLSTRING )
1060     return returnfalse( this , "characters " , ch ) ;
1061
1062   fieldvalue[depth] = (const char * ) ch ;
1063   return TRUE;
1064 }
1065
1066
1067 QString GraphBase::XmlHandler::errorString() {
1068   cout << "the document is not in the quote file format" << endl ;
1069   return "the document is not in the quote file format";
1070 }
1071
1072
1073 bool GraphBase::XmlHandler::fatalError( const QXmlParseException& exception ) {
1074   errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" )
1075     .arg( exception.message() )
1076     .arg( exception.lineNumber() )
1077     .arg( exception.columnNumber() );
1078   cout << "GraphBase::XmlHandler::fatalError " << errorProt.latin1() << endl ;
1079   return QXmlDefaultHandler::fatalError( exception );
1080 }
1081
1082 #if 0
1083 SALOME_SuperVision::Date GraphBase::XmlHandler::StringToDate( QString& myStrDate) const
1084 {
1085   SALOME_SuperVision::Date aDate;
1086   QString qstrDate(myStrDate);
1087   QString qstrTemp;
1088
1089   // Date
1090   int iPos = qstrDate.find("/");
1091   qstrTemp = qstrDate.left(iPos).stripWhiteSpace();
1092   aDate.Day = qstrTemp.toShort();
1093   qstrDate = qstrDate.right(qstrDate.length()-iPos);
1094   iPos = qstrDate.find("/");
1095   qstrTemp = qstrDate.left(iPos).stripWhiteSpace();
1096   aDate.Month = qstrTemp.toShort();
1097   qstrDate = qstrDate.right(qstrDate.length()-iPos);
1098   iPos = qstrDate.find(" ");
1099   qstrTemp = qstrDate.left(iPos).stripWhiteSpace();
1100   aDate.Year = qstrTemp.toShort();
1101
1102   // Time
1103   qstrDate = qstrDate.right(qstrDate.length()-iPos);
1104   iPos = qstrDate.find(":");
1105   qstrTemp = qstrDate.left(iPos).stripWhiteSpace();
1106   aDate.Hour = qstrTemp.toShort();
1107   qstrDate = qstrDate.right(qstrDate.length()-iPos);
1108   iPos = qstrDate.find(":");
1109   qstrTemp = qstrDate.left(iPos).stripWhiteSpace();
1110   aDate.Minute = qstrTemp.toShort();
1111   qstrDate = qstrDate.right(qstrDate.length()-iPos).stripWhiteSpace();
1112   aDate.Second = qstrDate.toShort();
1113
1114   return aDate;
1115 }
1116 #endif
1117
1118