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
|
Rev | Line | |
---|
[20] | 1 | /* |
---|
| 2 | * |
---|
| 3 | * [desc.] |
---|
| 4 | */ |
---|
| 5 | #include "Tools/Viewer/Parser/include/parser.h" |
---|
[32] | 6 | #include "qfileinfo.h" |
---|
[20] | 7 | namespace morpheo{ |
---|
| 8 | namespace tools{ |
---|
| 9 | namespace viewer{ |
---|
| 10 | namespace parser{ |
---|
| 11 | |
---|
[26] | 12 | int Parse::open_file(string name,int level){ |
---|
[32] | 13 | bool pere=false; |
---|
[20] | 14 | QFile file(QString::fromStdString(name)); |
---|
[32] | 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) |
---|
[26] | 21 | { |
---|
[32] | 22 | testname=testname.left(testname.lastIndexOf('-',-1,Qt::CaseSensitive)); |
---|
[26] | 23 | } |
---|
[32] | 24 | else |
---|
| 25 | pere=true; |
---|
[26] | 26 | |
---|
| 27 | |
---|
[20] | 28 | if( !file.open( QIODevice::ReadOnly ) ) |
---|
| 29 | { |
---|
[32] | 30 | cerr << "Position File :: Failed to load file. \n"; |
---|
[20] | 31 | return -1; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | QDomDocument doc( "pos" ); |
---|
| 35 | if( !doc.setContent( &file ) ) |
---|
| 36 | { |
---|
[32] | 37 | cerr << "Failed XML parse file.\n"; |
---|
[20] | 38 | file.close(); |
---|
| 39 | return -1; |
---|
| 40 | } |
---|
| 41 | file.close(); |
---|
| 42 | QDomElement root = doc.documentElement(); |
---|
| 43 | if( root.tagName() != "description" ) |
---|
| 44 | { |
---|
[32] | 45 | cerr <<"Invalid file.\n"; |
---|
[20] | 46 | return -1; |
---|
| 47 | } |
---|
| 48 | else |
---|
| 49 | { |
---|
| 50 | #ifdef DBUG_PARSE |
---|
| 51 | cout << "description" <<endl; |
---|
| 52 | #endif |
---|
| 53 | //BaseP |
---|
[26] | 54 | if(!base){ |
---|
| 55 | base=new morpheo::tools::viewer::bdd::BaseV(); |
---|
[32] | 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 | } |
---|
[26] | 64 | } |
---|
[20] | 65 | pos=new morpheo::tools::viewer::bdd::BaseP(); |
---|
[26] | 66 | parser_pos(root.firstChild(),level); |
---|
[32] | 67 | |
---|
[20] | 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.