Commit e6a1a189 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED code cleaning and better error handling in testcomponent

Should improve nailing down bugs.
parent c612a2be
......@@ -25,10 +25,11 @@ QStringList @EXTENSIONCLASSNAME@::getFileExtensions() const {
// --------------- Open -------------------
Component * @EXTENSIONCLASSNAME@::open(const QString & fileName) throw (AbortException) {
@IF_NO_SUFFIX@
// Complete this function by creating a component responding to the fileName suffix.
return NULL;
// Complete this function by creating a component responding to the fileName suffix.
return NULL;
@ELSE_IF_ONLY_ONE_SUFFIX@
return new @TOPLEVELCOMPONENTCLASSNAME@(fileName);
@ELSE_IF_SEVERAL_SUFFIX@
Component * component;
QStringList ext;
......
......@@ -10,14 +10,36 @@
include <string>;
class options {
bool --help | -h {"Print usage information and exit."};
bool --version | -v {"Print CamiTK version message"};
std::string --input | -i {"<file>",
"Test file to open"};
std::string --odir | -o {"<path>",
"[Optional] Directory where the output file will be saved"};
std::string --component | -c {"<component>",
"The component extension to be tested (provide full path of the dynamic library)"};
std::string --level | -l {"<level>",
"The test level to proceed"};
};
\ No newline at end of file
bool --help | -h
{
"Print usage information and exit."
};
std::string --component | -c
{"<component>",
"The component extension to be tested (please provide the full path of the dynamic library)"
};
std::string --input | -i
{
"<file>",
"Test file to open"
};
std::string --level | -l
{
"<level>",
"The test level to proceed, either \c{1} or \c{2}.
\c{1} will open the application, load the extension and then open the provided component file
\c{2} will open the application, load the extension, open the provided component file,
save the component to a new file and then close the component"
};
std::string --odir | -o
{
"<path>",
"[Optional] Directory where the output file will be saved"
};
};
// This code was generated by CLI, a command line interface
// compiler for C++.
//
#ifndef COMMAND_LINE_OPTIONS_HXX
#define COMMAND_LINE_OPTIONS_HXX
#include <iosfwd>
#include <string>
#include <exception>
namespace cli
{
class unknown_mode
{
public:
enum value
{
skip,
stop,
fail
};
unknown_mode (value v);
operator value () const
{
return v_;
}
private:
value v_;
};
// Exceptions.
//
class exception: public std::exception
{
public:
virtual void
print (std::ostream&) const = 0;
};
std::ostream&
operator<< (std::ostream&, const exception&);
class unknown_option: public exception
{
public:
virtual
~unknown_option () throw ();
unknown_option (const std::string& option);
const std::string&
option () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string option_;
};
class unknown_argument: public exception
{
public:
virtual
~unknown_argument () throw ();
unknown_argument (const std::string& argument);
const std::string&
argument () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string argument_;
};
class missing_value: public exception
{
public:
virtual
~missing_value () throw ();
missing_value (const std::string& option);
const std::string&
option () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string option_;
};
class invalid_value: public exception
{
public:
virtual
~invalid_value () throw ();
invalid_value (const std::string& option,
const std::string& value);
const std::string&
option () const;
const std::string&
value () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string option_;
std::string value_;
};
class eos_reached: public exception
{
public:
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
};
class scanner
{
public:
virtual
~scanner ();
virtual bool
more () = 0;
virtual const char*
peek () = 0;
virtual const char*
next () = 0;
virtual void
skip () = 0;
};
class argv_scanner: public scanner
{
public:
argv_scanner (int& argc, char** argv, bool erase = false);
argv_scanner (int start, int& argc, char** argv, bool erase = false);
int
end () const;
virtual bool
more ();
virtual const char*
peek ();
virtual const char*
next ();
virtual void
skip ();
private:
int i_;
int& argc_;
char** argv_;
bool erase_;
};
}
#include <string>
class options
{
public:
options (int& argc,
char** argv,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (int start,
int& argc,
char** argv,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (int& argc,
char** argv,
int& end,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (int start,
int& argc,
char** argv,
int& end,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (::cli::scanner&,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
// Option accessors.
//
const bool&
help () const;
const bool&
version () const;
const std::string&
input () const;
const std::string&
odir () const;
const std::string&
component () const;
const std::string&
level () const;
// Print usage information.
//
static void
print_usage (::std::ostream&);
private:
void
_parse (::cli::scanner&,
::cli::unknown_mode option,
::cli::unknown_mode argument);
public:
bool help_;
bool version_;
std::string input_;
std::string odir_;
std::string component_;
std::string level_;
};
#include "CommandLineOptions.ixx"
#endif // COMMAND_LINE_OPTIONS_HXX
// This code was generated by CLI, a command line interface
// compiler for C++.
//
#ifndef COMMAND_LINE_OPTIONS_HXX
#define COMMAND_LINE_OPTIONS_HXX
#include <iosfwd>
#include <string>
#include <exception>
namespace cli
{
class unknown_mode
{
public:
enum value
{
skip,
stop,
fail
};
unknown_mode (value v);
operator value () const
{
return v_;
}
private:
value v_;
};
// Exceptions.
//
class exception: public std::exception
{
public:
virtual void
print (std::ostream&) const = 0;
};
std::ostream&
operator<< (std::ostream&, const exception&);
class unknown_option: public exception
{
public:
virtual
~unknown_option () throw ();
unknown_option (const std::string& option);
const std::string&
option () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string option_;
};
class unknown_argument: public exception
{
public:
virtual
~unknown_argument () throw ();
unknown_argument (const std::string& argument);
const std::string&
argument () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string argument_;
};
class missing_value: public exception
{
public:
virtual
~missing_value () throw ();
missing_value (const std::string& option);
const std::string&
option () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string option_;
};
class invalid_value: public exception
{
public:
virtual
~invalid_value () throw ();
invalid_value (const std::string& option,
const std::string& value);
const std::string&
option () const;
const std::string&
value () const;
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
private:
std::string option_;
std::string value_;
};
class eos_reached: public exception
{
public:
virtual void
print (std::ostream&) const;
virtual const char*
what () const throw ();
};
class scanner
{
public:
virtual
~scanner ();
virtual bool
more () = 0;
virtual const char*
peek () = 0;
virtual const char*
next () = 0;
virtual void
skip () = 0;
};
class argv_scanner: public scanner
{
public:
argv_scanner (int& argc, char** argv, bool erase = false);
argv_scanner (int start, int& argc, char** argv, bool erase = false);
int
end () const;
virtual bool
more ();
virtual const char*
peek ();
virtual const char*
next ();
virtual void
skip ();
private:
int i_;
int& argc_;
char** argv_;
bool erase_;
};
}
#include <string>
class options
{
public:
options (int& argc,
char** argv,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (int start,
int& argc,
char** argv,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (int& argc,
char** argv,
int& end,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (int start,
int& argc,
char** argv,
int& end,
bool erase = false,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
options (::cli::scanner&,
::cli::unknown_mode option = ::cli::unknown_mode::fail,
::cli::unknown_mode argument = ::cli::unknown_mode::stop);
// Option accessors.
//
const bool&
help () const;
const std::string&
component () const;
const std::string&
input () const;
const std::string&
level () const;
const std::string&
odir () const;
// Print usage information.
//
static void
print_usage (::std::ostream&);
private:
void
_parse (::cli::scanner&,
::cli::unknown_mode option,
::cli::unknown_mode argument);
public:
bool help_;
std::string component_;
std::string input_;