/src/libpagemaker/src/lib/PMDExceptions.h
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* |
3 | | * This file is part of the libpagemaker project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #ifndef __PMDEXCEPTIONS_H__ |
11 | | #define __PMDEXCEPTIONS_H__ |
12 | | |
13 | | #include <stdint.h> |
14 | | |
15 | | #include <boost/format.hpp> |
16 | | |
17 | | #include <librevenge/librevenge.h> |
18 | | |
19 | | namespace libpagemaker |
20 | | { |
21 | | |
22 | | struct PMDParseException |
23 | | { |
24 | | std::string m_message; |
25 | | PMDParseException(const std::string &message) |
26 | 1 | : m_message(message) |
27 | 1 | { } |
28 | 1 | virtual ~PMDParseException() { } |
29 | | }; |
30 | | |
31 | | struct RecordNotFoundException : public PMDParseException |
32 | | { |
33 | | uint16_t m_recordType; |
34 | | |
35 | | RecordNotFoundException(uint16_t recordType) |
36 | 1 | : PMDParseException((boost::format("Record not found: %d") % recordType).str()), |
37 | 1 | m_recordType(recordType) |
38 | 1 | { } |
39 | | |
40 | | RecordNotFoundException(uint16_t recordType, uint16_t seqNum) |
41 | 0 | : PMDParseException((boost::format("Record of type %d not found at seqNum %d") % recordType % seqNum).str()), |
42 | 0 | m_recordType(recordType) |
43 | 0 | { } |
44 | | }; |
45 | | |
46 | | struct CorruptRecordException : public PMDParseException |
47 | | { |
48 | | uint16_t m_recordType; |
49 | | |
50 | | CorruptRecordException(uint16_t recordType, const std::string &message) |
51 | | : PMDParseException((boost::format("Corrupt record: %d\nError message: %s\n") % recordType % message).str()), |
52 | | m_recordType(recordType) |
53 | 0 | { } |
54 | | }; |
55 | | |
56 | | struct EmptyLineSetException |
57 | | { |
58 | | }; |
59 | | |
60 | | struct UnknownRecordSizeException : public PMDParseException |
61 | | { |
62 | | uint16_t m_recordType; |
63 | | |
64 | | UnknownRecordSizeException(uint16_t recordType) |
65 | 0 | : PMDParseException((boost::format("Tried to parse record %d of unknown size.\n") % recordType).str()), |
66 | 0 | m_recordType(recordType) |
67 | 0 | { } |
68 | | }; |
69 | | |
70 | | } |
71 | | |
72 | | #endif /* __PMDEXCEPTIONS_H__ */ |
73 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |