00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the bit library. * 00006 * * 00007 * The bit library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The bit library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef BITEXCEPTION_H 00020 #define BITEXCEPTION_H 00021 00026 #include <stdexcept> 00027 00028 namespace bit 00029 { 00030 00036 struct bit_exception: public std::runtime_error 00037 { 00038 bit_exception(const std::string s="bit: Unknown exception."): 00039 std::runtime_error(s), 00040 m_exception_string(s) 00041 {} 00042 00043 ~bit_exception() throw () { } 00044 00045 virtual const char * what () const throw () { return m_exception_string.c_str(); } 00046 00047 protected: 00048 std::string m_exception_string; 00049 }; 00050 00051 namespace exception 00052 { 00053 00058 struct invalid_iterator: public bit_exception 00059 { 00060 invalid_iterator(): bit_exception("bit: Attempted to use invalid iterator"){ } 00061 }; 00062 00067 struct invalid_container_op: public bit_exception 00068 { 00069 invalid_container_op(): bit_exception("bit: Using container methods on a FieldBase descendant that is not valid for that descendant.") { } 00070 }; 00071 00076 struct name: public bit_exception 00077 { 00078 name(): bit_exception("bit: Name identifiers may not contain the following characters: .[]") { } 00079 name(const std::string s): bit_exception(s) 00080 { m_exception_string = "bit: The name \"" + s + "\" is invalid. Name identifiers may not contain the following characters: .[]"; } 00081 }; 00082 00087 struct no_record: public bit_exception 00088 { 00089 no_record(): bit_exception("bit:RecordBuffer: Attempted an operation that requires a Record to be associated with this RecordBuffer.") { } 00090 }; 00091 00096 struct no_recordbuffer: public bit_exception 00097 { 00098 no_recordbuffer(): bit_exception("bit:FieldBuffer: Attempted an operation that requires a RecordBuffer to be associated with this FieldBuffer.") { } 00099 }; 00100 00105 struct invalid_index: public bit_exception 00106 { 00107 invalid_index(): bit_exception("bit: Invalid index.") { } 00108 }; 00109 00110 } 00111 00112 } 00113 00114 #include <bit/except_field.h> 00115 #include <bit/except_record.h> 00116 #include <bit/except_indices.h> 00117 #include <bit/except_type.h> 00118 00119 #endif 00120