/*
 *
 * [desc.]
 */
#include "Tools/Viewer/Parser/include/parser.h"

namespace morpheo{
namespace tools{
namespace viewer{
namespace parser{

   int Parse::open_file(string name){
    QFile file(QString::fromStdString(name));
    QString tmppath=QString::fromStdString(name);

    QString path=tmppath.left(tmppath.lastIndexOf('/',-1,Qt::CaseSensitive)+1);

    absolutePath=path.toStdString();

     if( !file.open( QIODevice::ReadOnly ) )
       {
	 cout << "Failed to load file. 1\n";
	 return -1;
       }

     QDomDocument doc( "pos" );
     if( !doc.setContent( &file ) )
      {
	cout <<  "Failed to load file.2\n";
	file.close();
	return -1;
      }
     file.close();
     QDomElement root = doc.documentElement();
     if( root.tagName() != "description" )
       {
	 cout <<"Invalid file.\n";
	 return -1;
       }
     else
       {
         #ifdef DBUG_PARSE
	 cout << "description" <<endl;
         #endif
	 //BaseP
	 if(!base)
	   base=new morpheo::tools::viewer::bdd::BaseV();
	 pos=new morpheo::tools::viewer::bdd::BaseP();
	 //base->addBaseP(pos);
	 parser_pos(root.firstChild());    
	 
       }
     return 0;


   }


};//end parser
};//end viewer
};//end tools
};//end morpheo

