diff --git a/include/boost/range/detail/mfc/carray.hpp b/include/boost/range/detail/mfc/carray.hpp new file mode 100755 index 0000000..546c010 --- /dev/null +++ b/include/boost/range/detail/mfc/carray.hpp @@ -0,0 +1,88 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2004. Use, modification and +// distribution is subject to 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#if !defined( BOOST_RANGE_DETAIL_MFC_CARRAY_HPP ) && defined( BOOST_RANGE_ENABLE_MCF_CARRAY ) +#define BOOST_RANGE_DETAIL_MFC_CARRAY_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include // for CArray +#include +#include + +namespace boost +{ + template< class T, class U > + struct iterator_of< CArray > + { + typedef T* type; + }; + + template< class T, class U > + struct const_iterator_of< CArray > + { + typedef const T* type; + }; + + template< class T, class U > + struct difference_type_of< CArray > + { + typedef std::ptrdiff_t type; + }; + + template< class T, class U > + struct size_type_of< CArray > + { + typedef int type; + }; + + template< class T, class U > + struct value_type_of< CArray > + { + typedef T type; + }; + + template< class T, class U > + T* begin( CArray& r ) + { + return r.GetData(); + } + + template< class T, class U > + const T* begin( const CArray& r ) + { + return r.GetData(); + } + + template< class T, class U > + int size( const CArray& r ) + { + return r.GetSize(); + } + + template< class T, class U > + T* end( CArray& r ) + { + return begin( r ) + size( r ); + } + + template< class T, class U > + const T* end( const CArray& r ) + { + return begin( r ) + size( r ); + } + + // default 'empty()' ok + +} // namespace 'boost' + +#endif diff --git a/include/boost/range/detail/mfc/cstring.hpp b/include/boost/range/detail/mfc/cstring.hpp new file mode 100755 index 0000000..a420168 --- /dev/null +++ b/include/boost/range/detail/mfc/cstring.hpp @@ -0,0 +1,78 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2004. Use, modification and +// distribution is subject to 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#if !defined(BOOST_RANGE_DETAIL_MFC_CSTRING_HPP) && defined(BOOST_RANGE_ENABLE_MFC) +#define BOOST_RANGE_DETAIL_MFC_CSTRING_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include // for CString +#include +#include + +namespace boost +{ + struct iterator_of< CString > + { + typedef TCHAR* type; + }; + + struct const_iterator_of< CString > + { + typedef const TCHAR* type; + }; + + struct difference_type_of< CString > + { + typedef std::ptrdiff_t type; + }; + + struct size_type_of< CString > + { + typedef int type; + }; + + struct value_type_of< CString > + { + typedef TCHAR type; + }; + + TCHAR* begin( CString& r ) + { + return &r[0]; + } + + const TCHAR* begin( const CString& r ) + { + return &r[0]; + } + + int size( const CString& r ) + { + return r.GetLength(); + } + + T* end( CString& r ) + { + return begin( r ) + size( r ); + } + + const T* end( const CString& r ) + { + return begin( r ) + size( r ); + } + + // default 'empty()' ok + +} // namespace 'boost' + +#endif diff --git a/test/Jamfile b/test/Jamfile index b4e6c85..7581ca8 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -16,6 +16,7 @@ rule range-test ( name ) { return [ run $(name).cpp +# $(VC71_ROOT)/atlmfc/include ../../test/build/boost_unit_test_framework : : : $(BOOST_ROOT) ] ; @@ -32,6 +33,6 @@ test-suite range : [ range-test algorithm_example ] [ range-test reversible_range ] [ range-test const_ranges ] - + [ range-test mfc ] ; diff --git a/test/mfc.cpp b/test/mfc.cpp new file mode 100755 index 0000000..748030d --- /dev/null +++ b/test/mfc.cpp @@ -0,0 +1,62 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2004. Use, modification and +// distribution is subject to 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#define _MSL_USING_NAMESPACE 1 + +#include + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +# pragma warn -8091 // supress warning in Boost.Test +# pragma warn -8057 // unused argument argc/argv in Boost.Test +#endif + +#define BOOST_RANGE_ENABLE_MFC + +#include +#include +#include + +#include +#include +#include +#include +#include + + +void check_mfc() +{ + CString s = "hello world"; + BOOST_CHECK( boost::begin( s ) + boost::size( s ) == boost::end( s ) ); + BOOST_CHECK( boost::size( s ) == boost::size( "hello world" ) ); + BOOST_CHECK( !empty( s ) ); + + +} + + + +#include +using boost::unit_test::test_suite; + + +test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + + test->add( BOOST_TEST_CASE( &check_mfc ) ); + + return test; +} + + + + + +