mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / extra / yassl / taocrypt / mySTL / stdexcept.hpp
blob79ae6de3380c3fe3f8dbcf2e8f977eb7e34dc361
1 /*
2 Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to the
15 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16 MA 02110-1301 USA.
20 /* mySTL memory implements exception, runtime_error
24 #ifndef mySTL_STDEXCEPT_HPP
25 #define mySTL_STDEXCEPT_HPP
28 #include <string.h> // strncpy
29 #include <stdlib.h> // size_t
32 namespace mySTL {
35 class exception {
36 public:
37 exception() {}
38 virtual ~exception() {} // to shut up compiler warnings
40 virtual const char* what() const { return ""; }
42 // for compiler generated call, never used
43 static void operator delete(void*) { }
44 private:
45 // don't allow dynamic creation of exceptions
46 static void* operator new(size_t);
50 class named_exception : public exception {
51 public:
52 enum { NAME_SIZE = 80 };
54 explicit named_exception(const char* str)
56 strncpy(name_, str, NAME_SIZE);
57 name_[NAME_SIZE - 1] = 0;
60 virtual const char* what() const { return name_; }
61 private:
62 char name_[NAME_SIZE];
66 class runtime_error : public named_exception {
67 public:
68 explicit runtime_error(const char* str) : named_exception(str) {}
74 } // namespace mySTL
76 #endif // mySTL_STDEXCEPT_HPP