INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

libs/orcadef/exceptions.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef ORCA_DEF_EXCEPTIONS_H
00012 #define ORCA_DEF_EXCEPTIONS_H
00013 
00014 /*
00015  * STRINGIZE macro converts an expression into a string-literal.
00016  * ERROR_INFO macro permits file-name and line-number data to be added to an error message.
00017  *
00018  * Adapted by Alex Brooks from Tim Bailey's version 2005.
00019  */
00020 
00021 #ifndef ERROR_MACROS_HPP_
00022 #define ERROR_MACROS_HPP_
00023 
00024 #if defined(STRINGIZE_HELPER) || defined(STRINGIZE) || defined(ERROR_INFO)
00025 #   error OrcaIceUtil error macros have already been defined elsewhere 
00026 #endif
00027 
00028 #define STRINGIZE_HELPER(exp) #exp
00029 #define STRINGIZE(exp) STRINGIZE_HELPER(exp)
00030 
00031 #define ERROR_INFO __FILE__, STRINGIZE(__LINE__)
00032 
00033 #endif
00034 
00035 #include <exception>
00036 #include <string>
00037 
00038 namespace orcadef
00039 {
00040 
00044 /*
00045     For Developers:
00046     Generally, this exception should be thrown like so:
00047     
00048      - throw Exception( ERROR_INFO, "description of error" );
00049     
00050     where the ERROR_INFO macro inserts the offending file and line number.
00051 */
00052 class Exception : public std::exception
00053 {
00054 public:
00055 
00056     Exception(const char *file, const char *line, const char *message);
00057     Exception(const char *file, const char *line, const std::string &message);
00058 
00059     virtual ~Exception() throw();
00060 
00061     virtual const char* what() const throw() { return message_.c_str(); }
00062 
00063 protected:
00064 
00065     void setMsg( const char *file, const char *line, const char *message );
00066     const char *basename( const char *s );
00067 
00068     std::string  message_;
00069 };
00070 
00072 class FileException : public orcadef::Exception
00073 {
00074 public:
00075     FileException(const char *file, const char *line, const char *message)
00076         : Exception( file, line, message ) {};
00077     FileException(const char *file, const char *line, const std::string &message)
00078         : Exception( file, line, message ) {};
00079 };
00080 
00082 class ParseException : public orcadef::Exception
00083 {
00084 public:
00085     ParseException(const char *file, const char *line, const char *message)
00086         : Exception( file, line, message ) {};
00087     ParseException(const char *file, const char *line, const std::string &message)
00088         : Exception( file, line, message ) {};
00089 };
00090 
00091 } // namespace
00092 
00093 
00094 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5