• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/pascal/depot/filedata/src/tools_exceptions.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Nicolas PASCAL   *
00003  *   pascal@icare-pc12   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef TOOLS_EXCEPTIONS_H
00022 #define TOOLS_EXCEPTIONS_H
00023 
00024 #include <exception>
00025 #include <string>
00026 #include <sstream>
00027 #include "tools.h"
00028 using namespace std;
00036 class InterpolationError : public exception {
00037 public:
00044     InterpolationError(const string &src_file, const int src_line, const string &msg): src_file(src_file),src_line(src_line),msg(msg){};
00045     ~InterpolationError() throw() {}
00046     ;
00047     virtual const char* what() const throw() {
00048       std::ostringstream oss;
00049       oss<<src_file<<"("<<src_line<<")"<<" InterpolationError : "<<msg<<endl;
00050       return oss.str().c_str();
00051     };
00052 private:
00053     string src_file;
00054     int src_line;
00055     string msg;
00056 };
00057 
00061 class out_of_bound : public std::exception {
00062 public:
00063     out_of_bound(const int index, const int size):index(index),size(size) {};
00064     ~out_of_bound() throw() {}
00065     ;
00066     virtual const char* what() const throw() {
00067       std::ostringstream oss;
00068       oss<<"out_of_bound : the index "<<index<<" is out of bound. It must be in the range [0,"<<size<<"["<<std::endl;
00069       return oss.str().c_str();
00070     };
00071 private:
00072     int index;
00073     int size;
00074 };
00075 
00076 #endif

Generated on Thu Feb 14 2013 17:59:03 for filedata.kdevelop by  doxygen 1.7.1