Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright (C) 2020 YADRO |
Artem Senichev | afc7373 | 2020-05-09 19:04:51 +0300 | [diff] [blame] | 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <zlib.h> |
| 7 | |
| 8 | #include <exception> |
| 9 | #include <string> |
| 10 | |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 11 | /** |
| 12 | * @class ZlibException |
| 13 | * @brief zLib exception. |
Artem Senichev | afc7373 | 2020-05-09 19:04:51 +0300 | [diff] [blame] | 14 | */ |
| 15 | class ZlibException : public std::exception |
| 16 | { |
| 17 | public: |
| 18 | /** @brief File operation types. */ |
| 19 | enum Operation |
| 20 | { |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 21 | create, |
| 22 | write, |
| 23 | close |
Artem Senichev | afc7373 | 2020-05-09 19:04:51 +0300 | [diff] [blame] | 24 | }; |
| 25 | |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 26 | /** |
| 27 | * @brief Constructor. |
Artem Senichev | afc7373 | 2020-05-09 19:04:51 +0300 | [diff] [blame] | 28 | * |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 29 | * @param[in] op type of operation |
| 30 | * @param[in] code zLib status code |
| 31 | * @param[in] fd zLib file descriptor |
| 32 | * @param[in] fileName file name |
Artem Senichev | afc7373 | 2020-05-09 19:04:51 +0300 | [diff] [blame] | 33 | */ |
| 34 | ZlibException(Operation op, int code, gzFile fd, |
| 35 | const std::string& fileName); |
| 36 | |
| 37 | // From std::exception |
| 38 | const char* what() const noexcept override; |
| 39 | |
| 40 | private: |
| 41 | /** @brief Error description buffer. */ |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 42 | std::string errDesc; |
Artem Senichev | afc7373 | 2020-05-09 19:04:51 +0300 | [diff] [blame] | 43 | }; |