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

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

Release 3 du viewer:
Etape 1 et 2 du projet complet et à jour.

File size: 1.6 KB
Line 
1/*
2 *
3 * [desc.]
4 */
5#include "Tools/Viewer/Parser/include/parser.h"
6
7namespace morpheo{
8namespace tools{
9namespace viewer{
10namespace parser{
11
12   int Parse::open_file(string name,int level){
13
14    QFile file(QString::fromStdString(name));
15    QString testname,testname2;
16    QString tmppath=QString::fromStdString(name);
17    QString path=tmppath.left(tmppath.lastIndexOf('/',-1,Qt::CaseSensitive)+1);
18    absolutePath=path.toStdString();
19    testname=tmppath.right(tmppath.lastIndexOf('.',-1,Qt::CaseSensitive)-1);
20    testname2=testname.left(testname.lastIndexOf('.',-1,Qt::CaseSensitive));
21   
22    if(tmppath.contains('-') && level==0) //file not top level (first open file)
23      {
24        testname2=testname2.left(testname2.lastIndexOf('-',-1,Qt::CaseSensitive));
25      }
26   
27   
28     if( !file.open( QIODevice::ReadOnly ) )
29       {
30         cout << "Failed to load file. 1\n";
31         return -1;
32       }
33
34     QDomDocument doc( "pos" );
35     if( !doc.setContent( &file ) )
36      {
37        cout <<  "Failed to load file.2\n";
38        file.close();
39        return -1;
40      }
41     file.close();
42     QDomElement root = doc.documentElement();
43     if( root.tagName() != "description" )
44       {
45         cout <<"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=testname2.toStdString();
57         }
58         pos=new morpheo::tools::viewer::bdd::BaseP();
59         //base->addBaseP(pos);
60         parser_pos(root.firstChild(),level);   
61         
62       }
63
64     //     delete pos;
65     //delete ctemp;
66     return 0;
67   }
68
69
70};//end parser
71};//end viewer
72};//end tools
73};//end morpheo
74
Note: See TracBrowser for help on using the repository browser.