PMDExceptions.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libpagemaker project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef __PMDEXCEPTIONS_H__
00011 #define __PMDEXCEPTIONS_H__
00012 
00013 #include <stdint.h>
00014 #include <librevenge/librevenge.h>
00015 #include <boost/format.hpp>
00016 namespace libpagemaker
00017 {
00018 
00019 struct PMDParseException
00020 {
00021   std::string m_message;
00022   PMDParseException(const std::string &message)
00023     : m_message(message)
00024   { }
00025   virtual ~PMDParseException() { }
00026 };
00027 
00028 struct RecordNotFoundException : public PMDParseException
00029 {
00030   uint16_t m_recordType;
00031 
00032   RecordNotFoundException(uint16_t recordType)
00033     : PMDParseException((boost::format("Record not found: %d") % recordType).str()),
00034       m_recordType(recordType)
00035   { }
00036 
00037   RecordNotFoundException(uint16_t recordType, uint16_t seqNum)
00038     : PMDParseException((boost::format("Record of type %d not found at seqNum %d") % recordType % seqNum).str()),
00039       m_recordType(recordType)
00040   { }
00041 };
00042 
00043 struct CorruptRecordException : public PMDParseException
00044 {
00045   uint16_t m_recordType;
00046 
00047   CorruptRecordException(uint16_t recordType, const std::string &message)
00048     : PMDParseException((boost::format("Corrupt record: %d\nError message: %s\n") % recordType % message).str()),
00049       m_recordType(recordType)
00050   { }
00051 };
00052 
00053 struct EmptyLineSetException
00054 {
00055 };
00056 
00057 struct UnknownRecordSizeException : public PMDParseException
00058 {
00059   uint16_t m_recordType;
00060 
00061   UnknownRecordSizeException(uint16_t recordType)
00062     : PMDParseException((boost::format("Tried to parse record %d of unknown size.\n") % recordType).str()),
00063       m_recordType(recordType)
00064   { }
00065 };
00066 
00067 }
00068 
00069 #endif /* __PMDEXCEPTIONS_H__ */
00070 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */