1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
11 #include <anna/core/core.hpp>
12 #include <anna/io/io.hpp>
14 #include <anna/app/Application.hpp>
16 class Test : public anna::app::Application {
20 void initialize () throw (anna::RuntimeException);
23 void run () throw (anna::RuntimeException);
28 int main (int argc, const char** argv)
30 CommandLine& commandLine (CommandLine::instantiate ());
34 commandLine.initialize (argv, argc);
35 commandLine.verify ();
37 Logger::setLevel (Logger::Debug);
38 Logger::initialize ("testfunctions", new TraceWriter ("file.trace", 2048000));
42 catch (Exception& ex) {
43 cout << ex.asString () << endl;
50 app::Application ("testfunctions", "Comprobacion del sistema io", "1.0")
52 CommandLine& commandLine (CommandLine::instantiate ());
54 commandLine.add ("file", CommandLine::Argument::Mandatory, "Nombre del fichero a procesar");
55 commandLine.add ("mode", CommandLine::Argument::Mandatory, "Modo (binary|text)");
56 commandLine.add ("size", CommandLine::Argument::Mandatory, "Tamano del buffer de entrada");
59 void Test::initialize ()
60 throw (RuntimeException)
65 throw (RuntimeException)
67 CommandLine& commandLine (CommandLine::instantiate ());
69 const char* mode = commandLine.getValue ("mode");
70 int size = commandLine.getIntegerValue ("size");
71 const char* file = commandLine.getValue ("file");
73 if (anna_strcmp (mode, "binary") == 0) {
74 BinaryReader reader (file, size);
75 const DataBlock* dataBlock;
77 while ((dataBlock = reader.fetch ()) != NULL)
78 cout << anna::functions::asString (*dataBlock, 24) << endl << endl;
80 else if (anna_strcmp (mode, "text") == 0) {
81 TextReader reader (file, size);
83 while ((line = reader.fetch ()) != NULL)
84 cout << line << endl << endl;