/usr/include/GDF/Exceptions.h is in libgdf-dev 0.1.2-2build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | //
// This file is part of libGDF.
//
// libGDF is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// libGDF is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libGDF. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright 2010 Martin Billinger
#ifndef __EXCEPTIONS_H_INCLUDED__
#define __EXCEPTIONS_H_INCLUDED__
#include <exception>
#include <stdexcept>
#include <list>
#include <string>
#include <sstream>
namespace gdf {
namespace exception
{
/// A general exception
class general : public std::exception
{
public:
general( const std::string str ) { msg = str; }
virtual ~general( ) throw() { }
const char *what( ) const throw() { return msg.c_str(); }
private:
std::string msg;
};
/// An index exceeds it's valid range.
class index_out_of_range : public std::range_error
{
public:
index_out_of_range( std::string str ) : range_error("Index out of range: "+str) { }
};
/// Preconditions for operation are not met.
class invalid_operation : public std::runtime_error
{
public:
invalid_operation( std::string str ) : runtime_error("Invalid operation: "+str) { }
};
/// A container of some sort (list, vector, array, ... ) is empty
class empty_container : public std::runtime_error
{
public:
empty_container( std::string str ) : runtime_error("Empty container: "+str) { }
};
/// A member function from ChannelDataBase was called. This should not happen and is usually caused by providing an argument with the wrong datatype to a data access function.
class bad_type_assigned_to_channel : public std::domain_error
{
public:
bad_type_assigned_to_channel( std::string str = "" ) : domain_error("Bad datatype access to channel: "+str) { }
};
/// Type ID used is not defined in Types.h
class invalid_type_id : public std::domain_error
{
public:
invalid_type_id( std::string str ) : domain_error("Invalid type ID: "+str) { }
};
/// Channels of different types were used where it's not allowed
class mixed_types_not_allowed : public std::domain_error
{
public:
mixed_types_not_allowed( std::string str ) : domain_error("Invalid type mix: "+str) { }
};
/// Channel does not exist
class signal_exists_not : public std::domain_error
{
public:
signal_exists_not( std::string str ) : domain_error("Signal does not exist: "+str) { }
};
/// Channel does exist
class signal_exists : public std::domain_error
{
public:
signal_exists( std::string str ) : domain_error("Signal does exist: "+str) { }
};
/// Channel does not exist
class nonexistent_channel_access : public std::out_of_range
{
public:
nonexistent_channel_access( std::string str ) : out_of_range("Channel does not exist: "+str) { }
};
/// Number of channels does not match.
class mismatch_channel_number : public std::domain_error
{
public:
mismatch_channel_number( std::string str ) : domain_error("Number of channels mismatch: "+str) { }
};
/// Record Buffer is corrupt. This likely indicates an internal programming error.
class corrupt_recordbuffer : public std::runtime_error
{
public:
corrupt_recordbuffer( std::string str ) : runtime_error("Record buffer corrupted: "+str) { }
};
/// Feature is not implemented yet.
class feature_not_implemented : public std::logic_error
{
public:
feature_not_implemented( std::string str ) : logic_error("Feature not implemented: "+str) { }
};
/// File is not open
class file_not_open : public std::invalid_argument
{
public:
file_not_open( std::string str ) : invalid_argument("File is not open: "+str) { }
};
/// File is not open
class file_open : public std::invalid_argument
{
public:
file_open( std::string str ) : invalid_argument("File is open: "+str) { }
};
/// File exists
class file_exists : public std::invalid_argument
{
public:
file_exists( std::string str ) : invalid_argument("File exists: "+str) { }
};
/// File dos not exist
class file_exists_not : public std::invalid_argument
{
public:
file_exists_not( std::string str ) : invalid_argument("File does not exists: "+str) { }
};
/// File exists
class serialization_error : public std::logic_error
{
public:
serialization_error( std::string str ) : logic_error("Serialization error: "+str) { }
};
/// Illegal attempt to change event mode
class illegal_eventmode_change : public std::domain_error
{
public:
illegal_eventmode_change( std::string str ) : domain_error("Illegal attempt to change event mode: "+str) { }
};
/// Invalid event mode
class invalid_eventmode : public std::domain_error
{
public:
invalid_eventmode( std::string str ) : domain_error("Invalid event mode: "+str) { }
};
/// Operation on wrong event mode
class wrong_eventmode : public std::domain_error
{
public:
wrong_eventmode( std::string str ) : domain_error("Wrong event mode: "+str) { }
};
///
class incompatible_gdf_version : public general
{
public:
incompatible_gdf_version (std::string version_of_file) :
general ("Version \""+version_of_file+"\" not supported!"),
version_of_file_ (version_of_file) {}
virtual ~incompatible_gdf_version () throw () {}
std::string getVersionOfFile () {return version_of_file_;}
private:
std::string version_of_file_;
};
/// Header Issues
class header_issues : public std::exception
{
public:
header_issues( std::list< std::string > w, std::list< std::string > e )
: warnings(w), errors(e)
{ }
header_issues( std::list< std::string > w )
: warnings(w), errors()
{ }
std::list< std::string > warnings, errors;
virtual ~header_issues( ) throw() { }
void generate_message( )
{
std::stringstream ss;
std::list< std::string >::const_iterator it;
if( warnings.size( ) > 0 )
ss << std::string("Warnings: ") << std::endl;
for( it=warnings.begin(); it!=warnings.end(); it++ )
ss << " -> " << *it << std::endl;
if( errors.size( ) > 0 )
{
ss << "Errors: " << std::endl;
for( it=errors.begin(); it!=errors.end(); it++ )
ss << " -> " << *it << std::endl;
}
std::string str = ss.str( );
}
const char *what( ) const throw()
{
return str.c_str( );
}
size_t num_warnings( ) { return warnings.size(); }
size_t num_errors( ) { return errors.size(); }
private:
std::string str;
};
}
}
#endif
|