INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

gbxutilacfr/exceptions.h

00001 /*
00002  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
00003  *               http://gearbox.sf.net/
00004  * Copyright (c) 2004-2010 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This distribution is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef GBXUTILACFR_EXCEPTIONS_H
00012 #define GBXUTILACFR_EXCEPTIONS_H
00013 
00014 #if defined (WIN32)
00015     #if defined (GBXUTILACFR_STATIC)
00016         #define GBXUTILACFR_EXPORT
00017     #elif defined (GBXUTILACFR_EXPORTS)
00018         #define GBXUTILACFR_EXPORT       __declspec (dllexport)
00019     #else
00020         #define GBXUTILACFR_EXPORT       __declspec (dllimport)
00021     #endif
00022 #else
00023     #define GBXUTILACFR_EXPORT
00024 #endif
00025 
00026 /*
00027  * STRINGIZE macro converts an expression into a string-literal.
00028  * ERROR_INFO macro permits file-name and line-number data to be added to an error message.
00029  *
00030  * Adapted by Alex Brooks from Tim Bailey's version 2005.
00031  */
00032 
00033 #ifndef ERROR_MACROS_HPP_
00034 #define ERROR_MACROS_HPP_
00035 
00036 #if defined(STRINGIZE_HELPER) || defined(STRINGIZE) || defined(ERROR_INFO)
00037 #   error GbxUtilAcfr error macros have already been defined elsewhere 
00038 #endif
00039 
00040 #define STRINGIZE_HELPER(exp) #exp
00041 #define STRINGIZE(exp) STRINGIZE_HELPER(exp)
00042 
00043 #define ERROR_INFO __FILE__, STRINGIZE(__LINE__)
00044 
00045 #endif
00046 
00047 #include <exception>
00048 #include <string>
00049 
00050 namespace gbxutilacfr {
00051 
00065 class GBXUTILACFR_EXPORT Exception : public std::exception
00066 {
00067 public:
00068     Exception(const char *file, const char *line, const std::string &message);
00069 
00070     virtual ~Exception() throw();
00071 
00072     virtual const char* what() const throw() { return message_.c_str(); }
00073 
00074 protected:
00075     std::string toMessageString( const char *file, const char *line, const std::string &message ) const;
00076 
00077     std::string  message_;
00078 };
00079 std::string basename( const std::string &s );
00080 std::string dirname( const std::string &s );
00081 
00083 class GBXUTILACFR_EXPORT HardwareException : public gbxutilacfr::Exception
00084 {
00085 public:
00086     HardwareException(const char *file, const char *line, const std::string &message)
00087             : Exception( file, line, message ) {};
00088 };
00089 
00090 } // namespace
00091 
00092 
00093 #endif
 

Generated for GearBox by  doxygen 1.4.5