source: trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Parser/src/Parse_open_file.cpp @ 34

Last change on this file since 34 was 34, checked in by rosiere, 17 years ago

Viewer : les noms des composants sont construit à partir de l'attribut "name" et nom à partir de l'attribut "type"

File size: 1.6 KB
Line 
1/*
2 *
3 * [desc.]
4 */
5#include "Tools/Viewer/Parser/include/parser.h"
6#include "qfileinfo.h"
7namespace morpheo{
8namespace tools{
9namespace viewer{
10namespace parser{
11
12   int Parse::open_file(string name,int level){
13     
14     bool pere=false;
15    QFile file(QString::fromStdString(name));
16    QFileInfo info(file);
17    QString testname;
18    absolutePath=info.absolutePath().toStdString();
19    absolutePath.append("/");
20    testname=info.baseName();
21    if(testname.contains('-') && level==0) //file not top level (first open file)
22      {
23        testname=testname.left(testname.lastIndexOf('-',-1,Qt::CaseSensitive));
24      }
25    else
26      pere=true;
27   
28   
29     if( !file.open( QIODevice::ReadOnly ) )
30       {
31         cerr << "Position File :: Failed to load file : \"" << name << "\".\n";
32         return -1;
33       }
34
35     QDomDocument doc( "pos" );
36     if( !doc.setContent( &file ) )
37      {
38        cerr <<  "Failed XML parse file.\n";
39        file.close();
40        return -1;
41      }
42     file.close();
43     QDomElement root = doc.documentElement();
44     if( root.tagName() != "description" )
45       {
46         cerr <<"Invalid file.\n";
47         return -1;
48       }
49     else
50       {
51         #ifdef DBUG_PARSE
52         cout << "description" <<endl;
53         #endif
54         //BaseP
55         if(!base){
56           base=new morpheo::tools::viewer::bdd::BaseV(); 
57           toplevel=info.baseName().toStdString();
58           if(pere==true)
59             {
60               string op="";
61               op.append(absolutePath);
62               op.append(toplevel);
63               open_file_param(op);
64             }
65         }
66         pos=new morpheo::tools::viewer::bdd::BaseP();
67         parser_pos(root.firstChild(),level);   
68       }
69     return 0;
70   }
71
72
73};//end parser
74};//end viewer
75};//end tools
76};//end morpheo
77
Note: See TracBrowser for help on using the repository browser.