diff --git a/src/addressList.cpp b/src/addressList.cpp
index 957be503..756156d1 100644
--- a/src/addressList.cpp
+++ b/src/addressList.cpp
@@ -151,7 +151,7 @@ void addressList::insertAddressBefore(shared_ptr
beforeAddress, shared
(m_list.begin(), m_list.end(), beforeAddress);
if (it == m_list.end())
- throw exceptions::no_such_address();
+ throw std::out_of_range();
m_list.insert(it, addr);
}
@@ -159,6 +159,9 @@ void addressList::insertAddressBefore(shared_ptr beforeAddress, shared
void addressList::insertAddressBefore(const size_t pos, shared_ptr addr)
{
+ if (pos >= m_list.size())
+ throw std::out_of_range();
+
m_list.insert(m_list.begin() + pos, addr);
}
@@ -169,7 +172,7 @@ void addressList::insertAddressAfter(shared_ptr afterAddress, shared_p
(m_list.begin(), m_list.end(), afterAddress);
if (it == m_list.end())
- throw exceptions::no_such_address();
+ throw std::out_of_range();
m_list.insert(it + 1, addr);
}
@@ -177,6 +180,9 @@ void addressList::insertAddressAfter(shared_ptr afterAddress, shared_p
void addressList::insertAddressAfter(const size_t pos, shared_ptr addr)
{
+ if (pos >= m_list.size())
+ throw std::out_of_range();
+
m_list.insert(m_list.begin() + pos + 1, addr);
}
@@ -187,7 +193,7 @@ void addressList::removeAddress(shared_ptr addr)
(m_list.begin(), m_list.end(), addr);
if (it == m_list.end())
- throw exceptions::no_such_address();
+ throw std::out_of_range();
m_list.erase(it);
}
@@ -195,6 +201,9 @@ void addressList::removeAddress(shared_ptr addr)
void addressList::removeAddress(const size_t pos)
{
+ if (pos >= m_list.size())
+ throw std::out_of_range();
+
const std::vector >::iterator it = m_list.begin() + pos;
m_list.erase(it);
diff --git a/src/exception.cpp b/src/exception.cpp
index e1f40ce4..45f672a3 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -178,18 +178,6 @@ exception* no_such_part::clone() const { return new no_such_part(*this); }
const char* no_such_part::name() const throw() { return "no_such_part"; }
-//
-// no_such_mailbox
-//
-
-no_such_mailbox::~no_such_mailbox() throw() {}
-no_such_mailbox::no_such_mailbox(const exception& other)
- : exception("Mailbox not found.", other) {}
-
-exception* no_such_mailbox::clone() const { return new no_such_mailbox(*this); }
-const char* no_such_mailbox::name() const throw() { return "no_such_mailbox"; }
-
-
//
// no_such_message_id
//
@@ -202,18 +190,6 @@ exception* no_such_message_id::clone() const { return new no_such_message_id(*th
const char* no_such_message_id::name() const throw() { return "no_such_message_id"; }
-//
-// no_such_address
-//
-
-no_such_address::~no_such_address() throw() {}
-no_such_address::no_such_address(const exception& other)
- : exception("Address not found.", other) {}
-
-exception* no_such_address::clone() const { return new no_such_address(*this); }
-const char* no_such_address::name() const throw() { return "no_such_address"; }
-
-
//
// open_file_error
//
diff --git a/src/mailboxGroup.cpp b/src/mailboxGroup.cpp
index 559d8778..d4bbb7db 100644
--- a/src/mailboxGroup.cpp
+++ b/src/mailboxGroup.cpp
@@ -258,7 +258,7 @@ void mailboxGroup::insertMailboxBefore(shared_ptr beforeMailbox, share
(m_list.begin(), m_list.end(), beforeMailbox);
if (it == m_list.end())
- throw exceptions::no_such_mailbox();
+ throw std::out_of_range();
m_list.insert(it, mbox);
}
@@ -266,6 +266,9 @@ void mailboxGroup::insertMailboxBefore(shared_ptr beforeMailbox, share
void mailboxGroup::insertMailboxBefore(const size_t pos, shared_ptr mbox)
{
+ if (pos >= m_list.size())
+ throw std::out_of_range();
+
m_list.insert(m_list.begin() + pos, mbox);
}
@@ -276,7 +279,7 @@ void mailboxGroup::insertMailboxAfter(shared_ptr afterMailbox, shared_
(m_list.begin(), m_list.end(), afterMailbox);
if (it == m_list.end())
- throw exceptions::no_such_mailbox();
+ throw std::out_of_range();
m_list.insert(it + 1, mbox);
}
@@ -284,6 +287,9 @@ void mailboxGroup::insertMailboxAfter(shared_ptr afterMailbox, shared_
void mailboxGroup::insertMailboxAfter(const size_t pos, shared_ptr mbox)
{
+ if (pos >= m_list.size())
+ throw std::out_of_range();
+
m_list.insert(m_list.begin() + pos + 1, mbox);
}
@@ -294,7 +300,7 @@ void mailboxGroup::removeMailbox(shared_ptr mbox)
(m_list.begin(), m_list.end(), mbox);
if (it == m_list.end())
- throw exceptions::no_such_mailbox();
+ throw std::out_of_range();
m_list.erase(it);
}
@@ -302,6 +308,9 @@ void mailboxGroup::removeMailbox(shared_ptr mbox)
void mailboxGroup::removeMailbox(const size_t pos)
{
+ if (pos >= m_list.size())
+ throw std::out_of_range();
+
const std::vector >::iterator it = m_list.begin() + pos;
m_list.erase(it);
diff --git a/src/mailboxList.cpp b/src/mailboxList.cpp
index 0a76c52a..7d6674fc 100644
--- a/src/mailboxList.cpp
+++ b/src/mailboxList.cpp
@@ -49,14 +49,7 @@ void mailboxList::appendMailbox(shared_ptr mbox)
void mailboxList::insertMailboxBefore(shared_ptr beforeMailbox, shared_ptr mbox)
{
- try
- {
- m_list.insertAddressBefore(beforeMailbox, mbox);
- }
- catch (exceptions::no_such_address&)
- {
- throw exceptions::no_such_mailbox();
- }
+ m_list.insertAddressBefore(beforeMailbox, mbox);
}
@@ -68,14 +61,7 @@ void mailboxList::insertMailboxBefore(const size_t pos, shared_ptr mbo
void mailboxList::insertMailboxAfter(shared_ptr afterMailbox, shared_ptr mbox)
{
- try
- {
- m_list.insertAddressAfter(afterMailbox, mbox);
- }
- catch (exceptions::no_such_address&)
- {
- throw exceptions::no_such_mailbox();
- }
+ m_list.insertAddressAfter(afterMailbox, mbox);
}
@@ -87,14 +73,7 @@ void mailboxList::insertMailboxAfter(const size_t pos, shared_ptr mbox
void mailboxList::removeMailbox(shared_ptr mbox)
{
- try
- {
- m_list.removeAddress(mbox);
- }
- catch (exceptions::no_such_address&)
- {
- throw exceptions::no_such_mailbox();
- }
+ m_list.removeAddress(mbox);
}
diff --git a/vmime/addressList.hpp b/vmime/addressList.hpp
index 2958000b..2987b1ac 100644
--- a/vmime/addressList.hpp
+++ b/vmime/addressList.hpp
@@ -69,7 +69,7 @@ public:
*
* @param beforeAddress address before which the new address will be inserted
* @param addr address to insert
- * @throw exceptions::no_such_address if the address is not in the list
+ * @throw std::out_of_range if the address is not in the list
*/
void insertAddressBefore(shared_ptr beforeAddress, shared_ptr addr);
@@ -78,6 +78,7 @@ public:
* @param pos position at which to insert the new address (0 to insert at
* the beginning of the list)
* @param addr address to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertAddressBefore(const size_t pos, shared_ptr addr);
@@ -85,7 +86,7 @@ public:
*
* @param afterAddress address after which the new address will be inserted
* @param addr address to insert
- * @throw exceptions::no_such_address if the address is not in the list
+ * @throw std::out_of_range if the address is not in the list
*/
void insertAddressAfter(shared_ptr afterAddress, shared_ptr addr);
@@ -93,19 +94,21 @@ public:
*
* @param pos position of the address before the new address
* @param addr address to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertAddressAfter(const size_t pos, shared_ptr addr);
/** Remove the specified address from the list.
*
* @param addr address to remove
- * @throw exceptions::no_such_address if the address is not in the list
+ * @throw std::out_of_range if the address is not in the list
*/
void removeAddress(shared_ptr addr);
/** Remove the address at the specified position.
*
* @param pos position of the address to remove
+ * @throw std::out_of_range if the position is out of range
*/
void removeAddress(const size_t pos);
@@ -129,6 +132,7 @@ public:
*
* @param pos position
* @return address at position 'pos'
+ * @throw std::out_of_range if the position is out of range
*/
shared_ptr getAddressAt(const size_t pos);
@@ -136,6 +140,7 @@ public:
*
* @param pos position
* @return address at position 'pos'
+ * @throw std::out_of_range if the position is out of range
*/
const shared_ptr getAddressAt(const size_t pos) const;
diff --git a/vmime/exception.hpp b/vmime/exception.hpp
index 386f9ce0..bb59fe8f 100644
--- a/vmime/exception.hpp
+++ b/vmime/exception.hpp
@@ -188,18 +188,6 @@ public:
};
-class VMIME_EXPORT no_such_mailbox : public vmime::exception
-{
-public:
-
- no_such_mailbox(const exception& other = NO_EXCEPTION);
- ~no_such_mailbox() throw();
-
- exception* clone() const;
- const char* name() const throw();
-};
-
-
class VMIME_EXPORT no_such_message_id : public vmime::exception
{
public:
@@ -212,18 +200,6 @@ public:
};
-class VMIME_EXPORT no_such_address : public vmime::exception
-{
-public:
-
- no_such_address(const exception& other = NO_EXCEPTION);
- ~no_such_address() throw();
-
- exception* clone() const;
- const char* name() const throw();
-};
-
-
class VMIME_EXPORT open_file_error : public vmime::exception
{
public:
diff --git a/vmime/mailboxGroup.hpp b/vmime/mailboxGroup.hpp
index ac6b9741..a85c0232 100644
--- a/vmime/mailboxGroup.hpp
+++ b/vmime/mailboxGroup.hpp
@@ -76,7 +76,7 @@ public:
*
* @param beforeMailbox mailbox before which the new mailbox will be inserted
* @param mbox mailbox to insert
- * @throw exceptions::no_such_mailbox if the mailbox is not in the list
+ * @throw std::out_of_range if the mailbox is not in the list
*/
void insertMailboxBefore(shared_ptr beforeMailbox, shared_ptr mbox);
@@ -85,6 +85,7 @@ public:
* @param pos position at which to insert the new mailbox (0 to insert at
* the beginning of the list)
* @param mbox mailbox to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertMailboxBefore(const size_t pos, shared_ptr mbox);
@@ -92,7 +93,7 @@ public:
*
* @param afterMailbox mailbox after which the new mailbox will be inserted
* @param mbox mailbox to insert
- * @throw exceptions::no_such_mailbox if the mailbox is not in the list
+ * @throw std::out_of_range if the mailbox is not in the list
*/
void insertMailboxAfter(shared_ptr afterMailbox, shared_ptr mbox);
@@ -100,19 +101,21 @@ public:
*
* @param pos position of the mailbox before the new mailbox
* @param mbox mailbox to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertMailboxAfter(const size_t pos, shared_ptr mbox);
/** Remove the specified mailbox from the list.
*
* @param mbox mailbox to remove
- * @throw exceptions::no_such_mailbox if the mailbox is not in the list
+ * @throw std::out_of_range if the mailbox is not in the list
*/
void removeMailbox(shared_ptr mbox);
/** Remove the mailbox at the specified position.
*
* @param pos position of the mailbox to remove
+ * @throw std::out_of_range if the position is out of range
*/
void removeMailbox(const size_t pos);
@@ -136,6 +139,7 @@ public:
*
* @param pos position
* @return mailbox at position 'pos'
+ * @throw std::out_of_range if the position is out of range
*/
shared_ptr getMailboxAt(const size_t pos);
@@ -143,6 +147,7 @@ public:
*
* @param pos position
* @return mailbox at position 'pos'
+ * @throw std::out_of_range if the position is out of range
*/
const shared_ptr getMailboxAt(const size_t pos) const;
diff --git a/vmime/mailboxList.hpp b/vmime/mailboxList.hpp
index 25daefec..4003b680 100644
--- a/vmime/mailboxList.hpp
+++ b/vmime/mailboxList.hpp
@@ -63,7 +63,7 @@ public:
*
* @param beforeMailbox mailbox before which the new mailbox will be inserted
* @param mbox mailbox to insert
- * @throw exceptions::no_such_mailbox if the mailbox is not in the list
+ * @throw std::out_of_range if the mailbox is not in the list
*/
void insertMailboxBefore(shared_ptr beforeMailbox, shared_ptr mbox);
@@ -72,6 +72,7 @@ public:
* @param pos position at which to insert the new mailbox (0 to insert at
* the beginning of the list)
* @param mbox mailbox to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertMailboxBefore(const size_t pos, shared_ptr mbox);
@@ -79,7 +80,7 @@ public:
*
* @param afterMailbox mailbox after which the new mailbox will be inserted
* @param mbox mailbox to insert
- * @throw exceptions::no_such_mailbox if the mailbox is not in the list
+ * @throw std::out_of_range if the mailbox is not in the list
*/
void insertMailboxAfter(shared_ptr afterMailbox, shared_ptr mbox);
@@ -87,19 +88,21 @@ public:
*
* @param pos position of the mailbox before the new mailbox
* @param mbox mailbox to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertMailboxAfter(const size_t pos, shared_ptr mbox);
/** Remove the specified mailbox from the list.
*
* @param mbox mailbox to remove
- * @throw exceptions::no_such_mailbox if the mailbox is not in the list
+ * @throw std::out_of_range if the mailbox is not in the list
*/
void removeMailbox(shared_ptr mbox);
/** Remove the mailbox at the specified position.
*
* @param pos position of the mailbox to remove
+ * @throw std::out_of_range if the position is out of range
*/
void removeMailbox(const size_t pos);
@@ -123,6 +126,7 @@ public:
*
* @param pos position
* @return mailbox at position 'pos'
+ * @throw std::out_of_range if the position is out of range
*/
shared_ptr getMailboxAt(const size_t pos);
@@ -130,6 +134,7 @@ public:
*
* @param pos position
* @return mailbox at position 'pos'
+ * @throw std::out_of_range if the position is out of range
*/
const shared_ptr getMailboxAt(const size_t pos) const;
diff --git a/vmime/types.hpp b/vmime/types.hpp
index 1a36ea7a..b647d6f5 100644
--- a/vmime/types.hpp
+++ b/vmime/types.hpp
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
#include "vmime/config.hpp"