1 | /* |
---|
2 | * $Id: XML_generate_file.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/include/XML.h" |
---|
9 | #include "Common/include/ErrorMorpheo.h" |
---|
10 | #include <fstream> |
---|
11 | |
---|
12 | namespace morpheo { |
---|
13 | namespace behavioural { |
---|
14 | |
---|
15 | #undef FUNCTION |
---|
16 | #define FUNCTION "XML::generate_file" |
---|
17 | void XML::generate_file (std::string dirname, std::string encoding) |
---|
18 | { |
---|
19 | log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
20 | |
---|
21 | header (encoding); |
---|
22 | |
---|
23 | std::string filename = dirname + "/" + _name + _filename_extension; |
---|
24 | |
---|
25 | msg_printf(INFORMATION,_("Generate file \"%s\"."),filename.c_str()); |
---|
26 | |
---|
27 | std::ofstream file; |
---|
28 | file.open(filename.c_str() ,std::ios::out | std::ios::trunc); |
---|
29 | |
---|
30 | if (!file) |
---|
31 | throw ERRORMORPHEO(FUNCTION,toString(_("Error opening \"%s\" file.\n"),filename.c_str())); |
---|
32 | |
---|
33 | file << get_body(); |
---|
34 | |
---|
35 | file.close(); |
---|
36 | |
---|
37 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
38 | }; |
---|
39 | |
---|
40 | void XML::generate_file (std::string dirname) |
---|
41 | { |
---|
42 | log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
43 | generate_file(dirname,"UTF-8"); |
---|
44 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
45 | }; |
---|
46 | |
---|
47 | }; // end namespace behavioural |
---|
48 | }; // end namespace morpheo |
---|