/*
 * $Id: XML_generate_file.cpp 81 2008-04-15 18:40:01Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/include/XML.h"
#include <fstream>

namespace morpheo              {
namespace behavioural          {

#undef  FUNCTION
#define FUNCTION "XML::generate_file"
  void XML::generate_file (std::string encoding)
  {
    log_printf(FUNC,Behavioural,FUNCTION,"Begin");

    header (encoding);

    std::string filename =  _name + "." + _filename_extension;

    std::cout << "Generate file \""<< filename << "\"" << std::endl;

    std::ofstream file;
    file.open(filename.c_str(),std::ios::out | std::ios::trunc);

    file << get_body();

    file.close();

    log_printf(FUNC,Behavioural,FUNCTION,"End");
  };

  void XML::generate_file (void)
  {
    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
    generate_file("UTF-8");
    log_printf(FUNC,Behavioural,FUNCTION,"End");
  };

}; // end namespace behavioural          
}; // end namespace morpheo              
