Remove dynamic exceptions
[anna.git] / source / html / DocumentFile.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #include <anna/core/tracing/Logger.hpp>
10 #include <anna/core/tracing/TraceMethod.hpp>
11 #include <anna/config/defines.hpp>
12 #include <anna/core/functions.hpp>
13
14 #include <anna/io/functions.hpp>
15
16 #include <libxml/HTMLparser.h>
17
18 #include <anna/html/DocumentFile.hpp>
19
20 using namespace std;
21 using namespace anna;
22
23 _xmlDoc* html::DocumentFile::do_initialize(const char* filename)
24 noexcept(false) {
25   LOGMETHOD(TraceMethod tf("anna::html::DocumentFile", "do_initialize", ANNA_FILE_LOCATION));
26   _xmlDoc* result = NULL;
27   a_filename = filename;
28   LOGDEBUG(
29     string msg("html::DocumentFile::do_initialize | Filename: ");
30     msg += filename;
31     Logger::debug(msg, ANNA_FILE_LOCATION);
32   );
33
34   if(io::functions::exists(filename) == false) {
35     string msg("html::DocumentFile::do_initialize | File: ");
36     msg += filename;
37     msg += " | Not found";
38     throw RuntimeException(msg, ANNA_FILE_LOCATION);
39   }
40
41   result = htmlParseFile(filename, NULL);
42
43   if(result == NULL)
44     throw RuntimeException(functions::asString("Error analyzing HTML document: %s", filename), ANNA_FILE_LOCATION);
45
46   return result;
47 }
48
49 _xmlDoc* html::DocumentFile::do_initialize(const anna::DataBlock&)
50 noexcept(false) {
51   throw RuntimeException("html::DocumentFile::do_initialize | Not implemented", ANNA_FILE_LOCATION);
52   return NULL;
53 }