Files
boost_range/include/boost/range/detail/mfc/cstring.hpp

93 lines
1.7 KiB
C++
Raw Normal View History

2005-02-05 20:47:39 +00:00
// 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>
2005-03-15 16:00:19 +00:00
#include <boost/range/metafunctions.hpp>
2005-02-05 20:47:39 +00:00
namespace boost
{
2005-03-15 16:00:19 +00:00
template<>
struct range_iterator< CString >
2005-02-05 20:47:39 +00:00
{
typedef TCHAR* type;
};
2005-03-15 16:00:19 +00:00
//
// Why is this needed?!?
//
template<>
struct range_iterator< const CString >
{
typedef TCHAR* type;
};
template<>
struct range_const_iterator< CString >
2005-02-05 20:47:39 +00:00
{
typedef const TCHAR* type;
};
2005-03-15 16:00:19 +00:00
template<>
struct range_difference< CString >
2005-02-05 20:47:39 +00:00
{
typedef std::ptrdiff_t type;
};
2005-03-15 16:00:19 +00:00
template<>
struct range_size< CString >
2005-02-05 20:47:39 +00:00
{
typedef int type;
};
2005-03-15 16:00:19 +00:00
template<>
struct range_value< CString >
2005-02-05 20:47:39 +00:00
{
typedef TCHAR type;
};
TCHAR* begin( CString& r )
{
2005-03-15 16:00:19 +00:00
return r.GetBuffer(0);
2005-02-05 20:47:39 +00:00
}
const TCHAR* begin( const CString& r )
{
2005-03-15 16:00:19 +00:00
return (LPCTSTR)r;
2005-02-05 20:47:39 +00:00
}
int size( const CString& r )
{
return r.GetLength();
}
2005-03-15 16:00:19 +00:00
TCHAR* end( CString& r )
2005-02-05 20:47:39 +00:00
{
return begin( r ) + size( r );
}
2005-03-15 16:00:19 +00:00
const TCHAR* end( const CString& r )
2005-02-05 20:47:39 +00:00
{
return begin( r ) + size( r );
}
// default 'empty()' ok
} // namespace 'boost'
#endif