1 | /* |
---|
2 | * |
---|
3 | * [desc.] |
---|
4 | */ |
---|
5 | #include "Tools/Viewer/Parser/include/parser.h" |
---|
6 | |
---|
7 | namespace morpheo{ |
---|
8 | namespace tools{ |
---|
9 | namespace viewer{ |
---|
10 | namespace 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 | |
---|