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