diff --git a/build/vc100/turtle.sln b/build/vc100/turtle.sln
index 6d21843..5e18ba2 100644
--- a/build/vc100/turtle.sln
+++ b/build/vc100/turtle.sln
@@ -4,8 +4,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "turtle", "turtle.vcxproj",
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "turtle_test", "turtle_test.vcxproj", "{74810A2A-33D8-47D6-9A50-71261F1683F5}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "turtle_bench", "turtle_bench.vcxproj", "{2D607783-30B9-46DE-81E2-28513B31D5D2}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug|Win32 = debug|Win32
@@ -30,14 +28,6 @@ Global
{74810A2A-33D8-47D6-9A50-71261F1683F5}.release|Win32.Build.0 = release|Win32
{74810A2A-33D8-47D6-9A50-71261F1683F5}.release|x64.ActiveCfg = release|x64
{74810A2A-33D8-47D6-9A50-71261F1683F5}.release|x64.Build.0 = release|x64
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.debug|Win32.ActiveCfg = debug|Win32
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.debug|Win32.Build.0 = debug|Win32
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.debug|x64.ActiveCfg = debug|x64
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.debug|x64.Build.0 = debug|x64
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.release|Win32.ActiveCfg = release|Win32
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.release|Win32.Build.0 = release|Win32
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.release|x64.ActiveCfg = release|x64
- {2D607783-30B9-46DE-81E2-28513B31D5D2}.release|x64.Build.0 = release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/build/vc100/turtle.vcxproj b/build/vc100/turtle.vcxproj
index d13dd23..23e6a1c 100644
--- a/build/vc100/turtle.vcxproj
+++ b/build/vc100/turtle.vcxproj
@@ -49,10 +49,12 @@
+
+
{831F2DEE-1E35-4533-A3B2-12C01BA8DA1D}
diff --git a/build/vc100/turtle.vcxproj.filters b/build/vc100/turtle.vcxproj.filters
index c9dbd41..ecf86ac 100644
--- a/build/vc100/turtle.vcxproj.filters
+++ b/build/vc100/turtle.vcxproj.filters
@@ -112,5 +112,11 @@
Source Files\detail
+
+ Source Files
+
+
+ Source Files
+
\ No newline at end of file
diff --git a/turtle/format.hpp b/turtle/format.hpp
new file mode 100644
index 0000000..777f3ff
--- /dev/null
+++ b/turtle/format.hpp
@@ -0,0 +1,56 @@
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2011
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef MOCK_FORMAT_HPP_INCLUDED
+#define MOCK_FORMAT_HPP_INCLUDED
+
+#include "stream.hpp"
+#include
+
+namespace mock
+{
+namespace detail
+{
+ template< typename T >
+ struct formatter
+ {
+ explicit formatter( const T& t )
+ : t_( boost::addressof( t ) )
+ {}
+ void serialize( stream& s ) const
+ {
+ mock::detail::serialize( s, *t_ );
+ }
+ const T* t_;
+ };
+
+ template< typename T >
+ stream& operator<<( stream& s, const formatter< T >& f )
+ {
+ f.serialize( s );
+ return s;
+ }
+
+ template< typename T >
+ std::ostream& operator<<( std::ostream& s, const formatter< T >& f )
+ {
+ stream ss( s );
+ f.serialize( ss );
+ return s;
+ }
+}
+
+ template< typename T >
+ detail::formatter< T > format( const T& t )
+ {
+ return detail::formatter< T >( t );
+ }
+
+} // mock
+
+#endif // MOCK_FORMAT_HPP_INCLUDED
diff --git a/turtle/log.hpp b/turtle/log.hpp
index 9ab8c0a..4c153c5 100644
--- a/turtle/log.hpp
+++ b/turtle/log.hpp
@@ -9,11 +9,11 @@
#ifndef MOCK_LOG_HPP_INCLUDED
#define MOCK_LOG_HPP_INCLUDED
+#include "stream.hpp"
+#include "format.hpp"
#include
#include
#include
-#include
-#include
#include
namespace boost
@@ -38,157 +38,18 @@ namespace assign_detail
namespace mock
{
- struct stream
- {
- explicit stream( std::ostream& s )
- : s_( &s )
- {}
- std::ostream* s_;
- };
-
-#ifdef MOCK_USE_CONVERSIONS
-
-namespace detail3
-{
- struct sink
- {
- template< typename T >
- sink( const T& )
- {}
- };
-
- inline std::ostream& operator<<( std::ostream& s, const sink& )
- {
- return s << '?';
- }
-
- struct holder
- {
- virtual ~holder()
- {}
- virtual void serialize( std::ostream& s ) const = 0;
- };
-
- template< typename T >
- struct holder_imp : holder
- {
- explicit holder_imp( const T& t )
- : t_( boost::addressof( t ) )
- {}
- virtual void serialize( std::ostream& s ) const
- {
- // if an error about an ambiguous conversion is generated by the
- // line below the solution is to add a serialization operator to a
- // mock::stream for T
- s << *t_;
- }
- const T* t_;
- };
-
- struct data
- {
- template< typename T >
- data( const T& t )
- : h_( new holder_imp< T >( t ) )
- {}
- ~data()
- {
- delete h_;
- }
- holder* h_;
- };
-}
-
- inline stream& operator<<( stream& s, const detail3::data& d )
- {
- d.h_->serialize( *s.s_ );
- return s;
- }
-
-#else // MOCK_USE_CONVERSIONS
-
-namespace detail3
-{
- template< typename S, typename T >
- S& operator<<( S &s, const T& )
- {
- return s << '?';
- }
-}
-
- template< typename T >
- stream& operator<<( stream& s, const T& t )
- {
- using namespace detail3;
- *s.s_ << t;
- return s;
- }
-
-#endif // MOCK_USE_CONVERSIONS
-
-namespace detail2
+namespace detail
{
template< typename T >
- void serialize( stream& s, const T& t )
+ void serialize( stream& s, const T& begin, const T& end )
{
- // if an error about an ambiguous conversion is generated by the
- // line below the solution is to add a serialization operator to a
- // mock::stream for T
- s << t;
- }
- inline void serialize( stream& s, bool b )
- {
- s << (b ? "true" : "false");
- }
- template< typename C, typename T, typename A >
- void serialize( stream& s, const std::basic_string< C, T, A >& str )
- {
- s << '"' << str << '"';
- }
- inline void serialize( stream& s, const char* const str )
- {
- s << '"' << str << '"';
- }
- inline void serialize( stream& s, unsigned char c )
- {
- s << static_cast< int >( c );
- }
-
- template< typename T >
- struct formatter
- {
- explicit formatter( const T& t )
- : t_( boost::addressof( t ) )
- {}
- void serialize( stream& s ) const
- {
- mock::detail2::serialize( s, *t_ );
- }
- const T* t_;
- };
-
- template< typename T >
- stream& operator<<( stream& s, const formatter< T >& ser )
- {
- ser.serialize( s );
- return s;
- }
-
- template< typename T >
- std::ostream& operator<<( std::ostream& s, const formatter< T >& ser )
- {
- stream ss( s );
- ser.serialize( ss );
- return s;
+ s << '(';
+ for( T it = begin; it != end; ++it )
+ s << (it == begin ? "" : ",") << mock::format( *it );
+ s << ')';
}
}
- template< typename T >
- detail2::formatter< T > format( const T& t )
- {
- return detail2::formatter< T >( t );
- }
-
template< typename T >
stream& operator<<( stream& s, const std::auto_ptr< T >& t )
{
@@ -201,18 +62,6 @@ namespace detail2
<< ',' << mock::format( p.second ) << ')';
}
-namespace detail
-{
- template< typename T >
- void serialize( stream& s, const T& begin, const T& end )
- {
- s << '(';
- for( T it = begin; it != end; ++it )
- s << (it == begin ? "" : ",") << mock::format( *it );
- s << ')';
- }
-}
-
template< typename T, typename A >
stream& operator<<( stream& s, const std::deque< T, A >& t )
{
diff --git a/turtle/stream.hpp b/turtle/stream.hpp
new file mode 100644
index 0000000..59b2b30
--- /dev/null
+++ b/turtle/stream.hpp
@@ -0,0 +1,141 @@
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2011
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef MOCK_STREAM_HPP_INCLUDED
+#define MOCK_STREAM_HPP_INCLUDED
+
+#include
+#include
+
+namespace mock
+{
+ struct stream
+ {
+ explicit stream( std::ostream& s )
+ : s_( &s )
+ {}
+ std::ostream* s_;
+ };
+
+#ifdef MOCK_USE_CONVERSIONS
+
+namespace detail
+{
+namespace conversion
+{
+ struct sink
+ {
+ template< typename T >
+ sink( const T& )
+ {}
+ };
+
+ inline std::ostream& operator<<( std::ostream& s, const sink& )
+ {
+ return s << '?';
+ }
+
+ struct holder
+ {
+ virtual ~holder()
+ {}
+ virtual void serialize( std::ostream& s ) const = 0;
+ };
+
+ template< typename T >
+ struct holder_imp : holder
+ {
+ explicit holder_imp( const T& t )
+ : t_( boost::addressof( t ) )
+ {}
+ virtual void serialize( std::ostream& s ) const
+ {
+ // if an error about an ambiguous conversion is generated by the
+ // line below the solution is to add a serialization operator to a
+ // mock::stream for T
+ s << *t_;
+ }
+ const T* t_;
+ };
+
+ struct data
+ {
+ template< typename T >
+ data( const T& t )
+ : h_( new holder_imp< T >( t ) )
+ {}
+ ~data()
+ {
+ delete h_;
+ }
+ holder* h_;
+ };
+}
+}
+
+ inline stream& operator<<( stream& s, const detail::conversion::data& d )
+ {
+ d.h_->serialize( *s.s_ );
+ return s;
+ }
+
+#else // MOCK_USE_CONVERSIONS
+
+namespace detail
+{
+namespace conversion
+{
+ template< typename S, typename T >
+ S& operator<<( S &s, const T& )
+ {
+ return s << '?';
+ }
+}
+}
+
+ template< typename T >
+ stream& operator<<( stream& s, const T& t )
+ {
+ using namespace detail::conversion;
+ *s.s_ << t;
+ return s;
+ }
+
+#endif // MOCK_USE_CONVERSIONS
+
+namespace detail
+{
+ template< typename T >
+ void serialize( stream& s, const T& t )
+ {
+ // if an error about an ambiguous conversion is generated by the
+ // line below the solution is to add a serialization operator to a
+ // mock::stream for T
+ s << t;
+ }
+ inline void serialize( stream& s, bool b )
+ {
+ s << (b ? "true" : "false");
+ }
+ template< typename C, typename T, typename A >
+ void serialize( stream& s, const std::basic_string< C, T, A >& str )
+ {
+ s << '"' << str << '"';
+ }
+ inline void serialize( stream& s, const char* const str )
+ {
+ s << '"' << str << '"';
+ }
+ inline void serialize( stream& s, unsigned char c )
+ {
+ s << static_cast< int >( c );
+ }
+}
+} // mock
+
+#endif // MOCK_STREAM_HPP_INCLUDED