VS integration part 1 - allow catch_message.hpp to be included by more than 1 source file

This commit is contained in:
Malcolm Noyes
2013-11-10 15:11:21 +00:00
parent 8e411d27f6
commit e9a2230ad8
8 changed files with 165 additions and 18 deletions

View File

@@ -31,8 +31,6 @@ namespace Catch {
bool operator < ( MessageInfo const& other ) const {
return sequence < other.sequence;
}
private:
static unsigned int globalCount;
};
struct MessageBuilder {

View File

@@ -12,28 +12,32 @@
namespace Catch {
MessageInfo::MessageInfo( std::string const& _macroName,
template <typename T>
struct MessageInfoCounter {
// This may need protecting if threading support is added
static T globalCount;
};
template <typename T>
T MessageInfoCounter<T>::globalCount = T();
INTERNAL_CATCH_INLINE MessageInfo::MessageInfo( std::string const& _macroName,
SourceLineInfo const& _lineInfo,
ResultWas::OfType _type )
: macroName( _macroName ),
lineInfo( _lineInfo ),
type( _type ),
sequence( ++globalCount )
sequence( ++MessageInfoCounter<unsigned int>::globalCount )
{}
// This may need protecting if threading support is added
unsigned int MessageInfo::globalCount = 0;
////////////////////////////////////////////////////////////////////////////
ScopedMessage::ScopedMessage( MessageBuilder const& builder )
INTERNAL_CATCH_INLINE ScopedMessage::ScopedMessage( MessageBuilder const& builder )
: m_info( builder.m_info )
{
m_info.message = builder.m_stream.str();
getResultCapture().pushScopedMessage( m_info );
}
ScopedMessage::~ScopedMessage() {
INTERNAL_CATCH_INLINE ScopedMessage::~ScopedMessage() {
getResultCapture().popScopedMessage( m_info );
}