mirror of
https://github.com/boostorg/range.git
synced 2025-07-22 00:52:10 +02:00
*** empty log message ***
[SVN r27149]
This commit is contained in:
88
include/boost/range/detail/mfc/carray.hpp
Executable file
88
include/boost/range/detail/mfc/carray.hpp
Executable file
@ -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 <mfc/include/afxtempl.h> // for CArray
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T, class U >
|
||||
struct iterator_of< CArray<T,U> >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct const_iterator_of< CArray<T,U> >
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct difference_type_of< CArray<T,U> >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct size_type_of< CArray<T,U> >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct value_type_of< CArray<T,U> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
T* begin( CArray<T,U>& r )
|
||||
{
|
||||
return r.GetData();
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
const T* begin( const CArray<T,U>& r )
|
||||
{
|
||||
return r.GetData();
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
int size( const CArray<T,U>& r )
|
||||
{
|
||||
return r.GetSize();
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
T* end( CArray<T,U>& r )
|
||||
{
|
||||
return begin( r ) + size( r );
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
const T* end( const CArray<T,U>& r )
|
||||
{
|
||||
return begin( r ) + size( r );
|
||||
}
|
||||
|
||||
// default 'empty()' ok
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
78
include/boost/range/detail/mfc/cstring.hpp
Executable file
78
include/boost/range/detail/mfc/cstring.hpp
Executable file
@ -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 <afx.h> // for CString
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
|
||||
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
|
@ -16,6 +16,7 @@ rule range-test ( name )
|
||||
{
|
||||
return [
|
||||
run $(name).cpp
|
||||
# <include>$(VC71_ROOT)/atlmfc/include
|
||||
<lib>../../test/build/boost_unit_test_framework
|
||||
: : : <include>$(BOOST_ROOT)
|
||||
] ;
|
||||
@ -32,6 +33,6 @@ test-suite range :
|
||||
[ range-test algorithm_example ]
|
||||
[ range-test reversible_range ]
|
||||
[ range-test const_ranges ]
|
||||
|
||||
[ range-test mfc ]
|
||||
;
|
||||
|
||||
|
62
test/mfc.cpp
Executable file
62
test/mfc.cpp
Executable file
@ -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 <boost/detail/workaround.hpp>
|
||||
|
||||
#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 <boost/range.hpp>
|
||||
#include <boost/range/detail/mfc/carray.hpp>
|
||||
#include <boost/range/detail/mfc/cstring.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
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 <boost/test/unit_test.hpp>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user