diff options
author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2004-11-19 19:00:44 +0000 |
---|---|---|
committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2004-11-19 19:00:44 +0000 |
commit | 707400b4c6de94a22075b17d8d4ef08fa75813d9 (patch) | |
tree | 08bcc0e2b57394ba592b82fafa810c15f4114c29 /src/cppunit | |
parent | e321ba14ae0d69ee07bb90fdb6393b8173809644 (diff) | |
download | cppunit-707400b4c6de94a22075b17d8d4ef08fa75813d9.tar.gz |
added specific copy constructor implementatin to ensure string buffer are detached during copy (therefore providing thread-safe copy constructor for non thread-safe std::string copy constructor implementation).
Diffstat (limited to 'src/cppunit')
-rw-r--r-- | src/cppunit/Message.cpp | 21 | ||||
-rw-r--r-- | src/cppunit/SourceLine.cpp | 25 |
2 files changed, 43 insertions, 3 deletions
diff --git a/src/cppunit/Message.cpp b/src/cppunit/Message.cpp index 85f235e..9d6a0e9 100644 --- a/src/cppunit/Message.cpp +++ b/src/cppunit/Message.cpp @@ -9,6 +9,11 @@ Message::Message() { } +Message::Message( const Message &other ) +{ + *this = other; +} + Message::Message( const std::string &shortDescription ) : m_shortDescription( shortDescription ) @@ -42,6 +47,22 @@ Message::Message( const std::string &shortDescription, addDetail( detail1, detail2, detail3 ); } +Message & +Message::operator =( const Message &other ) +{ + if ( this != &other ) + { + m_shortDescription = other.m_shortDescription.c_str(); + m_details.clear(); + Details::const_iterator it = other.m_details.begin(); + Details::const_iterator itEnd = other.m_details.end(); + while ( it != itEnd ) + m_details.push_back( (*it++).c_str() ); + } + + return *this; +} + const std::string & Message::shortDescription() const diff --git a/src/cppunit/SourceLine.cpp b/src/cppunit/SourceLine.cpp index bd70709..dfadae3 100644 --- a/src/cppunit/SourceLine.cpp +++ b/src/cppunit/SourceLine.cpp @@ -10,11 +10,30 @@ SourceLine::SourceLine() : } +SourceLine::SourceLine( const SourceLine &other ) + : m_fileName( other.m_fileName.c_str() ) + , m_lineNumber( other.m_lineNumber ) +{ +} + + SourceLine::SourceLine( const std::string &fileName, - int lineNumber ) : - m_fileName( fileName ), - m_lineNumber( lineNumber ) + int lineNumber ) + : m_fileName( fileName.c_str() ) + , m_lineNumber( lineNumber ) +{ +} + + +SourceLine & +SourceLine::operator =( const SourceLine &other ) { + if ( this != &other ) + { + m_fileName = other.m_fileName.c_str(); + m_lineNumber = other.m_lineNumber; + } + return *this; } |