Blame include/internal/catch_message.cpp

rpm-build a7f80b
/*
rpm-build a7f80b
 *  Created by Phil Nash on 1/2/2013.
rpm-build a7f80b
 *  Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
rpm-build a7f80b
 *
rpm-build a7f80b
 *  Distributed under the Boost Software License, Version 1.0. (See accompanying
rpm-build a7f80b
 *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
rpm-build a7f80b
 */
rpm-build a7f80b
rpm-build a7f80b
#include "catch_message.h"
rpm-build a7f80b
#include "catch_interfaces_capture.h"
rpm-build a7f80b
#include "catch_uncaught_exceptions.h"
rpm-build a7f80b
rpm-build a7f80b
namespace Catch {
rpm-build a7f80b
rpm-build a7f80b
    MessageInfo::MessageInfo(   std::string const& _macroName,
rpm-build a7f80b
                                SourceLineInfo const& _lineInfo,
rpm-build a7f80b
                                ResultWas::OfType _type )
rpm-build a7f80b
    :   macroName( _macroName ),
rpm-build a7f80b
        lineInfo( _lineInfo ),
rpm-build a7f80b
        type( _type ),
rpm-build a7f80b
        sequence( ++globalCount )
rpm-build a7f80b
    {}
rpm-build a7f80b
rpm-build a7f80b
    bool MessageInfo::operator==( MessageInfo const& other ) const {
rpm-build a7f80b
        return sequence == other.sequence;
rpm-build a7f80b
    }
rpm-build a7f80b
rpm-build a7f80b
    bool MessageInfo::operator<( MessageInfo const& other ) const {
rpm-build a7f80b
        return sequence < other.sequence;
rpm-build a7f80b
    }
rpm-build a7f80b
rpm-build a7f80b
    // This may need protecting if threading support is added
rpm-build a7f80b
    unsigned int MessageInfo::globalCount = 0;
rpm-build a7f80b
rpm-build a7f80b
rpm-build a7f80b
    ////////////////////////////////////////////////////////////////////////////
rpm-build a7f80b
rpm-build a7f80b
    Catch::MessageBuilder::MessageBuilder( std::string const& macroName,
rpm-build a7f80b
                                           SourceLineInfo const& lineInfo,
rpm-build a7f80b
                                           ResultWas::OfType type )
rpm-build a7f80b
        :m_info(macroName, lineInfo, type) {}
rpm-build a7f80b
rpm-build a7f80b
    ////////////////////////////////////////////////////////////////////////////
rpm-build a7f80b
rpm-build a7f80b
rpm-build a7f80b
    ScopedMessage::ScopedMessage( MessageBuilder const& builder )
rpm-build a7f80b
    : m_info( builder.m_info )
rpm-build a7f80b
    {
rpm-build a7f80b
        m_info.message = builder.m_stream.str();
rpm-build a7f80b
        getResultCapture().pushScopedMessage( m_info );
rpm-build a7f80b
    }
rpm-build a7f80b
rpm-build a7f80b
    ScopedMessage::~ScopedMessage() {
rpm-build a7f80b
        if ( !uncaught_exceptions() ){
rpm-build a7f80b
            getResultCapture().popScopedMessage(m_info);
rpm-build a7f80b
        }
rpm-build a7f80b
    }
rpm-build a7f80b
} // end namespace Catch