source: XIOS/dev/XIOS_DEV_CMIP6/src/exception.hpp @ 1291

Last change on this file since 1291 was 792, checked in by rlacroix, 8 years ago

Make sure that the ERROR macro can work everywhere.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 1.4 KB
Line 
1#ifndef __XIOS_CException__
2#define __XIOS_CException__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "object.hpp"
7
8namespace xios
9{
10   /// ////////////////////// Déclarations ////////////////////// ///
11   class CException
12      : private CObject, public StdOStringStream
13   {
14         typedef CObject SuperClass;
15
16      public :
17
18         /// Constructeurs ///
19         CException(void);
20         explicit CException(const StdString & id);
21         CException(const CException & exception);
22         CException(const CException * const exception); // Not implemented.
23
24         /// Accesseurs ///
25         StdString getMessage(void) const;
26         StdOStringStream & getStream(void);
27
28         /// Destructeur ///
29         virtual ~CException(void);
30
31         /// Autre ///
32         virtual StdString toString(void) const;
33         virtual void fromString(const StdString & str);
34
35      private :
36
37         /// Propriétés ///
38         bool desc_rethrow; // throw destructor
39
40   }; // CException
41} // namespace xios
42
43/// //////////////////////////// Macros //////////////////////////// ///
44
45#define INFO(x) \
46   "In file \'" __FILE__ "\', line " << __LINE__ << " -> " x << std::endl;
47
48#ifdef __XIOS_DEBUG
49#  define DEBUG(x) std::clog << "> Debug " << INFO(x)
50#else
51#  define DEBUG(x)
52#endif
53
54#define ERROR(id, x) xios::CException(id).getStream() << INFO(x)
55
56#endif // __XIOS_CException__
Note: See TracBrowser for help on using the repository browser.