Skip to content

Commit

Permalink
Fixes sonarqube warnings in exception files
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Sep 21, 2023
1 parent 01ada35 commit e7c24ce
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 407 deletions.
37 changes: 23 additions & 14 deletions modules/ar/include/visp3/ar/vpSimulatorException.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,16 +29,15 @@
*
* Description:
* Exceptions that can be emitted by the simulator classes.
*
*****************************************************************************/
*/

#ifndef _vpSimulatorException_h_
#define _vpSimulatorException_h_

/* \file vpSimulatorException.h
\brief Error that can be emitted by the vpSimulator class and its derivatives
/*!
* \file vpSimulatorException.h
* \brief Error that can be emitted by the vpSimulator class and its derivatives
*/
/* Classes standards. */

#include <visp3/core/vpException.h>

Expand All @@ -48,18 +46,18 @@
#include <string> /* Classe string. */

/*!
\class vpSimulatorException
\brief Error that can be emitted by the vpSimulator class and its derivatives.
* \class vpSimulatorException
* \brief Error that can be emitted by the vpSimulator class and its derivatives.
*/
class VISP_EXPORT vpSimulatorException : public vpException
{
public:
/*!
\brief Lists the possible error than can be emitted while calling
vpSimulator member
*/
enum errorSimulatorCodeEnum {
* Lists the possible error than can be emitted while calling
* vpSimulator member
*/
enum errorSimulatorCodeEnum
{
ioError, //!< I/O error
noFileNameError, //!< Filename error
notInitializedError, //!< Initialization error
Expand All @@ -68,8 +66,19 @@ class VISP_EXPORT vpSimulatorException : public vpException
};

public:
/*!
* Constructor.
*/
vpSimulatorException(int id, const char *format, ...);

/*!
* Constructor.
*/
vpSimulatorException(int id, const std::string &msg);

/*!
* Constructor.
*/
explicit vpSimulatorException(int id);
};

Expand Down
65 changes: 31 additions & 34 deletions modules/core/include/visp3/core/vpDisplayException.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,52 +34,43 @@
#ifndef _vpDisplayException_h_
#define _vpDisplayException_h_

/* -------------------------------------------------------------------------
*/
/* --- INCLUDE -------------------------------------------------------------
*/
/* -------------------------------------------------------------------------
/*!
* \file vpDisplayException.h
* \brief error that can be emitted by the vpDisplay class and its derivatives
*/

/* \file vpDisplayException.h
\brief error that can be emitted by the vpDisplay class and its derivatives
*/
/* Classes standards. */
#include <iostream> /* Classe std::ostream. */
#include <string> /* Classe string. */
#include <iostream>
#include <string>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpException.h>

/* -------------------------------------------------------------------------
*/
/* --- CLASS ---------------------------------------------------------------
*/
/* -------------------------------------------------------------------------
*/

/*!
\class vpDisplayException
\ingroup group_core_debug
\brief Error that can be emitted by the vpDisplay class and its derivatives.
* \class vpDisplayException
* \ingroup group_core_debug
* \brief Error that can be emitted by the vpDisplay class and its derivatives.
*/
class VISP_EXPORT vpDisplayException : public vpException
{
public:
/*!
\brief Lists the possible error than can be emitted while calling
vpDisplay member
*/
enum errorDisplayCodeEnum {
notInitializedError,
cannotOpenWindowError,
connexionError,
XWindowsError,
GTKWindowsError,
colorAllocError,
depthNotSupportedError
* Lists the possible error than can be emitted while calling
* vpDisplay member
*/
enum errorDisplayCodeEnum
{
notInitializedError, //!< Display not initialized
cannotOpenWindowError, //!< Unable to open display window
connexionError, //!< Connection error
XWindowsError, //!< XWindow error
GTKWindowsError, //!< GTK error
colorAllocError, //!< Color allocation error
depthNotSupportedError //!< Color depth not supported
};

public:
/*!
* Constructor.
*/
vpDisplayException(int id, const char *format, ...)
{
this->code = id;
Expand All @@ -89,9 +80,15 @@ class VISP_EXPORT vpDisplayException : public vpException
va_end(args);
}

vpDisplayException(int id, const std::string &msg) : vpException(id, msg) {}
/*!
* Constructor.
*/
vpDisplayException(int id, const std::string &msg) : vpException(id, msg) { }

explicit vpDisplayException(int id) : vpException(id) {}
/*!
* Constructor.
*/
explicit vpDisplayException(int id) : vpException(id) { }
};

#endif
94 changes: 58 additions & 36 deletions modules/core/include/visp3/core/vpException.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,29 @@
* Exception handling.
*/

/* \file vpException.h
\brief error that can be emitted by the vp class and its derivatives
/*!
* \file vpException.h
* \brief error that can be emitted by the vp class and its derivatives
*/

#ifndef _vpException_h_
#define _vpException_h_

/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */

#include <visp3/core/vpConfig.h>

/* Classes standards. */
#include <iostream> /* Classe std::ostream. */
#include <iostream>
#include <stdarg.h>
#include <string> /* Classe string. */

/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <string>

/*!
\class vpException
\ingroup group_core_debug
\brief error that can be emitted by ViSP classes.
This class inherites from the standard std::exception contained in the C++
STL.
It is therefore possible to catch vpException with any other derivative of
std::exception in the same catch.
* \class vpException
* \ingroup group_core_debug
* \brief error that can be emitted by ViSP classes.
*
* This class inherits from the standard std::exception contained in the C++
* STL.
* It is therefore possible to catch vpException with any other derivative of
* std::exception in the same catch.
*/
class VISP_EXPORT vpException : public std::exception
{
Expand All @@ -76,10 +68,11 @@ class VISP_EXPORT vpException : public std::exception
void setMessage(const char *format, va_list args);

//! forbid the empty constructor (protected)
vpException() : code(notInitialized), message(""){};
vpException() : code(notInitialized), message("") { };

public:
enum generalExceptionEnum {
enum generalExceptionEnum
{
memoryAllocationError, //!< Memory allocation error
memoryFreeError, //!< Memory free error
functionNotImplementedError, //!< Function not implemented
Expand All @@ -93,37 +86,66 @@ class VISP_EXPORT vpException : public std::exception
notInitialized //!< Used to indicate that a parameter is not initialized.
};

/*!
* Constructor.
*/
vpException(int code, const char *format, va_list args);
/*!
* Constructor.
*/
vpException(int code, const char *format, ...);

/*!
* Constructor.
*/
vpException(int code, const std::string &msg);

/*!
* Constructor.
*/
explicit vpException(int code);

/*!
Basic destructor. Do nothing but implemented to fit the inheritance from
std::exception
*/
* Destructor. Do nothing but implemented to fit the inheritance from
* std::exception
*/
#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
virtual ~vpException() {}
virtual ~vpException() { }
#else
virtual ~vpException() throw() {}
virtual ~vpException() throw() { }
#endif

/** @name Inherited functionalities from vpException */
//@{
//! Send the object code.
/*!
* Send the object code.
*/
int getCode() const;

//! Send a reference (constant) related the error message (can be empty).
/*!
* Send a reference (constant) related the error message (can be empty).
*/
const std::string &getStringMessage() const;
//! send a pointer on the array of \e char related to the error string.
//! Cannot be \e NULL.

/*!
* Send a pointer on the array of \e char related to the error string.
* Cannot be \e NULL.
*/
const char *getMessage() const;

/*!
* Overloading of the what() method of std::exception to return the vpException
* message.
*
* \return pointer on the array of \e char related to the error string.
*/
const char *what() const throw();
//@}

//! Print the error structure.
/*!
* Print the error structure.
*/
friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpException &art);

const char *what() const throw();
};

#endif /* #ifndef _vpException_h_ */
#endif
55 changes: 29 additions & 26 deletions modules/core/include/visp3/core/vpFrameGrabberException.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,45 +35,40 @@
#ifndef _vpFrameGrabberException_h_
#define _vpFrameGrabberException_h_

/* -------------------------------------------------------------------------
*/
/* --- INCLUDE -------------------------------------------------------------
*/
/* -------------------------------------------------------------------------
*/

/* \file vpFrameGrabberException.h
\brief error that can be emitted by the vpFrameGrabber class and its
derivates
/*!
* \file vpFrameGrabberException.h
* \brief error that can be emitted by the vpFrameGrabber class and its
* derivates
*/
/* Classes standards. */

#include <iostream> /* Classe std::ostream. */
#include <string> /* Classe string. */
#include <iostream>
#include <string>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpException.h>

/* -------------------------------------------------------------------------
*/
/* --- CLASS ---------------------------------------------------------------
*/
/* -------------------------------------------------------------------------
*/

/*!
\brief Error that can be emitted by the vpFrameGrabber class and its
derivates
* \brief Error that can be emitted by the vpFrameGrabber class and its
* derivates.
*/
class VISP_EXPORT vpFrameGrabberException : public vpException
{
public:
/*!
\brief Lists the possible error than can be emitted while calling
vpFrameGrabber member
*/
enum errorFrameGrabberCodeEnum { settingError, initializationError, otherError };
* Lists the possible error than can be emitted while calling
* vpFrameGrabber member
*/
enum errorFrameGrabberCodeEnum
{
settingError, //!< Grabber settings error
initializationError, //!< Grabber initialization error
otherError //!< Grabber returned an other error
};

public:
/*!
* Constructor.
*/
vpFrameGrabberException(int id, const char *format, ...)
{
this->code = id;
Expand All @@ -82,8 +77,16 @@ class VISP_EXPORT vpFrameGrabberException : public vpException
setMessage(format, args);
va_end(args);
}

/*!
* Constructor.
*/
vpFrameGrabberException(int id, const std::string &msg) : vpException(id, msg) { }

/*!
* Constructor.
*/
explicit vpFrameGrabberException(int id) : vpException(id) { }
};

#endif /* #ifndef _vpFrameGrabberException_h_ */
#endif
Loading

0 comments on commit e7c24ce

Please sign in to comment.