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 
40 #if defined(_MSC_VER)
41 #pragma warning(push)
42 #pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
43 #endif
~ScopedMessage()44     ScopedMessage::~ScopedMessage() {
45         if ( !std::uncaught_exception() ){
46             getResultCapture().popScopedMessage(m_info);
47         }
48     }
49 #if defined(_MSC_VER)
50 #pragma warning(pop)
51 #endif
52 
53 
54 } // end namespace Catch
55 
56 #endif // TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED
57