Remove warnings
[anna.git] / example / xml / xmlBinary / main.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 <iostream>
10
11 #include <functional>
12
13 #include <anna/core/core.hpp>
14 #include <anna/xml/xml.hpp>
15
16 #include <anna/app/Application.hpp>
17
18 class Test : public app::Application {
19 public:
20    Test ();
21    
22 private:
23    void run () throw (anna::RuntimeException);      
24 };
25
26 using namespace std;
27
28 int main (int argc, const char** argv)
29 {
30    CommandLine& commandLine (CommandLine::instantiate ());
31    Test test;
32
33    xml::functions::initialize ();
34    
35    try {
36       commandLine.initialize (argv, argc);
37       commandLine.verify ();
38
39       Logger::setLevel (Logger::Debug);
40       Logger::initialize ("XML", new TraceWriter ("file.trace", 2048000));
41
42       test.start ();
43    }
44    catch (Exception& ex) {
45       cout << ex.asString () << endl;
46    }
47    
48    return 0;
49 }
50
51 Test::Test () : 
52    app::Application ("testfunctions", "Checking xml binary", "1.0") 
53 {
54    CommandLine& commandLine (CommandLine::instantiate ());
55       
56    commandLine.add ("xml", CommandLine::Argument::Mandatory, "XML document");
57 }
58
59 void Test::run () 
60    throw (RuntimeException)
61 {
62    CommandLine& commandLine (CommandLine::instantiate ());
63
64    xml::DocumentFile xmlDoc;
65
66    xmlDoc.initialize (commandLine.getValue ("xml"));
67
68    xml::Compressor compressor;
69    const DataBlock& dataBlock = compressor.apply (xmlDoc);
70
71    Logger::debug (anna::functions::asString (dataBlock, 24), ANNA_FILE_LOCATION);
72    cout << "Compression: " << anna::functions::asString (dataBlock, 24) << endl;
73    cout << dataBlock.getSize () << " bytes" << endl << endl;
74
75    xml::Decompressor decompressor;
76    const xml::Document& xmlDoc2 = decompressor.apply (dataBlock);
77    cout << "DeCompression: " << anna::functions::asString (xmlDoc2.getContent (), 24) << endl;
78
79 }
80