[0d221d2] | 1 | /*
|
---|
| 2 | * Copyright (c) 2018 Jaroslav Jindrak
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | #include <cstdlib>
|
---|
| 30 | #include <cstring>
|
---|
| 31 | #include <stdexcept>
|
---|
| 32 | #include <string>
|
---|
[bc56f30] | 33 | #include <str.h>
|
---|
[0d221d2] | 34 |
|
---|
| 35 | namespace std
|
---|
| 36 | {
|
---|
| 37 | logic_error::logic_error(const string& what)
|
---|
[bc56f30] | 38 | : what_{::helenos::str_dup(what.c_str())}
|
---|
[0d221d2] | 39 | { /* DUMMY BODY */ }
|
---|
| 40 |
|
---|
| 41 | logic_error::logic_error(const char* what)
|
---|
[bc56f30] | 42 | : what_{::helenos::str_dup(what)}
|
---|
[0d221d2] | 43 | { /* DUMMY BODY */ }
|
---|
| 44 |
|
---|
| 45 | logic_error::logic_error(const logic_error& other) noexcept
|
---|
[bc56f30] | 46 | : exception{other}, what_{::helenos::str_dup(other.what_)}
|
---|
[0d221d2] | 47 | { /* DUMMY BODY */ }
|
---|
| 48 |
|
---|
| 49 | logic_error& logic_error::operator=(const logic_error& other)
|
---|
| 50 | {
|
---|
| 51 | if (what_)
|
---|
| 52 | free(what_);
|
---|
[bc56f30] | 53 | what_ = ::helenos::str_dup(other.what_);
|
---|
[0d221d2] | 54 |
|
---|
| 55 | return *this;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | logic_error::~logic_error()
|
---|
| 59 | {
|
---|
| 60 | free(what_);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | const char* logic_error::what() const noexcept
|
---|
| 64 | {
|
---|
| 65 | return what_;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | domain_error::domain_error(const string& what)
|
---|
| 69 | : logic_error{what}
|
---|
| 70 | { /* DUMMY BODY */ }
|
---|
| 71 |
|
---|
| 72 | domain_error::domain_error(const char* what)
|
---|
| 73 | : logic_error{what}
|
---|
| 74 | { /* DUMMY BODY */ }
|
---|
| 75 |
|
---|
| 76 | domain_error::domain_error(const domain_error& other) noexcept
|
---|
| 77 | : logic_error{other}
|
---|
| 78 | { /* DUMMY BODY */ }
|
---|
| 79 |
|
---|
| 80 | invalid_argument::invalid_argument(const string& what)
|
---|
| 81 | : logic_error{what}
|
---|
| 82 | { /* DUMMY BODY */ }
|
---|
| 83 |
|
---|
| 84 | invalid_argument::invalid_argument(const char* what)
|
---|
| 85 | : logic_error{what}
|
---|
| 86 | { /* DUMMY BODY */ }
|
---|
| 87 |
|
---|
| 88 | invalid_argument::invalid_argument(const invalid_argument& other) noexcept
|
---|
| 89 | : logic_error{other}
|
---|
| 90 | { /* DUMMY BODY */ }
|
---|
| 91 |
|
---|
| 92 | length_error::length_error(const string& what)
|
---|
| 93 | : logic_error{what}
|
---|
| 94 | { /* DUMMY BODY */ }
|
---|
| 95 |
|
---|
| 96 | length_error::length_error(const char* what)
|
---|
| 97 | : logic_error{what}
|
---|
| 98 | { /* DUMMY BODY */ }
|
---|
| 99 |
|
---|
| 100 | length_error::length_error(const length_error& other) noexcept
|
---|
| 101 | : logic_error{other}
|
---|
| 102 | { /* DUMMY BODY */ }
|
---|
| 103 |
|
---|
| 104 | out_of_range::out_of_range(const string& what)
|
---|
| 105 | : logic_error{what}
|
---|
| 106 | { /* DUMMY BODY */ }
|
---|
| 107 |
|
---|
| 108 | out_of_range::out_of_range(const char* what)
|
---|
| 109 | : logic_error{what}
|
---|
| 110 | { /* DUMMY BODY */ }
|
---|
| 111 |
|
---|
| 112 | out_of_range::out_of_range(const out_of_range& other) noexcept
|
---|
| 113 | : logic_error{other}
|
---|
| 114 | { /* DUMMY BODY */ }
|
---|
| 115 |
|
---|
| 116 | runtime_error::runtime_error(const string& what)
|
---|
[bc56f30] | 117 | : what_{::helenos::str_dup(what.c_str())}
|
---|
[0d221d2] | 118 | { /* DUMMY BODY */ }
|
---|
| 119 |
|
---|
| 120 | runtime_error::runtime_error(const char* what)
|
---|
[bc56f30] | 121 | : what_{::helenos::str_dup(what)}
|
---|
[0d221d2] | 122 | { /* DUMMY BODY */ }
|
---|
| 123 |
|
---|
| 124 | runtime_error::runtime_error(const runtime_error& other) noexcept
|
---|
[bc56f30] | 125 | : exception{other}, what_{::helenos::str_dup(other.what_)}
|
---|
[0d221d2] | 126 | { /* DUMMY BODY */ }
|
---|
| 127 |
|
---|
| 128 | runtime_error& runtime_error::operator=(const runtime_error& other)
|
---|
| 129 | {
|
---|
| 130 | if (what_)
|
---|
| 131 | free(what_);
|
---|
[bc56f30] | 132 | what_ = ::helenos::str_dup(other.what_);
|
---|
[0d221d2] | 133 |
|
---|
| 134 | return *this;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | runtime_error::~runtime_error()
|
---|
| 138 | {
|
---|
| 139 | free(what_);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | const char* runtime_error::what() const noexcept
|
---|
| 143 | {
|
---|
| 144 | return what_;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | range_error::range_error(const string& what)
|
---|
| 148 | : runtime_error{what}
|
---|
| 149 | { /* DUMMY BODY */ }
|
---|
| 150 |
|
---|
| 151 | range_error::range_error(const char* what)
|
---|
| 152 | : runtime_error{what}
|
---|
| 153 | { /* DUMMY BODY */ }
|
---|
| 154 |
|
---|
| 155 | range_error::range_error(const range_error& other) noexcept
|
---|
| 156 | : runtime_error{other}
|
---|
| 157 | { /* DUMMY BODY */ }
|
---|
| 158 |
|
---|
| 159 | overflow_error::overflow_error(const string& what)
|
---|
| 160 | : runtime_error{what}
|
---|
| 161 | { /* DUMMY BODY */ }
|
---|
| 162 |
|
---|
| 163 | overflow_error::overflow_error(const char* what)
|
---|
| 164 | : runtime_error{what}
|
---|
| 165 | { /* DUMMY BODY */ }
|
---|
| 166 |
|
---|
| 167 | overflow_error::overflow_error(const overflow_error& other) noexcept
|
---|
| 168 | : runtime_error{other}
|
---|
| 169 | { /* DUMMY BODY */ }
|
---|
| 170 |
|
---|
| 171 | underflow_error::underflow_error(const string& what)
|
---|
| 172 | : runtime_error{what}
|
---|
| 173 | { /* DUMMY BODY */ }
|
---|
| 174 |
|
---|
| 175 | underflow_error::underflow_error(const char* what)
|
---|
| 176 | : runtime_error{what}
|
---|
| 177 | { /* DUMMY BODY */ }
|
---|
| 178 |
|
---|
| 179 | underflow_error::underflow_error(const underflow_error& other) noexcept
|
---|
| 180 | : runtime_error{other}
|
---|
| 181 | { /* DUMMY BODY */ }
|
---|
| 182 | }
|
---|