Add CMessage::Clone()

Due to (intentional) lack of CFooMessage::operator=(CMessage), it was
a bit clumsy to do such copy-conversions:

    CMessage Copy = Message;
    CJoinMessage& JoinMsg = static_cast<CJoinMessage&>(Copy);
    // ...

vs.

    CJoinMessge JoinMsg;
    JoinMsg.Clone(Message);
    // ...

Alternatively, copy ctor(CMessage) and assignment operator=(CMessage)
could have been added to all CMessage subclasses. I've been trying to
avoid that, to make these operations very explicit. It has helped a
lot so far by preventing accidental copies.
This commit is contained in:
J-P Nurmi
2015-08-16 23:25:15 +02:00
parent de4ffb180c
commit 82375eed65
2 changed files with 9 additions and 0 deletions

View File

@@ -29,6 +29,13 @@ CMessage::CMessage(const CNick& Nick, const CString& sCommand, const VCString& v
InitTime();
}
void CMessage::Clone(const CMessage& Message)
{
if (&Message != this) {
*this = Message;
}
}
CString CMessage::GetParams(unsigned int uIdx, unsigned int uLen) const
{
VCString vsParams;