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

Last change on this file since 32 was 32, checked in by chou, 17 years ago

Morpheo Viewer Release 5.0
Réalisation des étapes 3 (fin) et 4.

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