1 /* 2 * Created by Phil Nash on 1/2/2013. 3 * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #ifndef TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED 9 #define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED 10 11 #include "catch_message.h" 12 13 namespace Catch { 14 MessageInfo(std::string const & _macroName,SourceLineInfo const & _lineInfo,ResultWas::OfType _type)15 MessageInfo::MessageInfo( std::string const& _macroName, 16 SourceLineInfo const& _lineInfo, 17 ResultWas::OfType _type ) 18 : macroName( _macroName ), 19 lineInfo( _lineInfo ), 20 type( _type ), 21 sequence( ++globalCount ) 22 {} 23 24 // This may need protecting if threading support is added 25 unsigned int MessageInfo::globalCount = 0; 26 27 28 //////////////////////////////////////////////////////////////////////////// 29 ScopedMessage(MessageBuilder const & builder)30 ScopedMessage::ScopedMessage( MessageBuilder const& builder ) 31 : m_info( builder.m_info ) 32 { 33 m_info.message = builder.m_stream.str(); 34 getResultCapture().pushScopedMessage( m_info ); 35 } ScopedMessage(ScopedMessage const & other)36 ScopedMessage::ScopedMessage( ScopedMessage const& other ) 37 : m_info( other.m_info ) 38 {} 39 ~ScopedMessage()40 ScopedMessage::~ScopedMessage() { 41 if ( !std::uncaught_exception() ){ 42 getResultCapture().popScopedMessage(m_info); 43 } 44 } 45 46 47 } // end namespace Catch 48 49 #endif // TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED 50