1 | // Boost.Range library |
---|
2 | // |
---|
3 | // Copyright Thorsten Ottosen 2003-2004. Use, modification and |
---|
4 | // distribution is subject to the Boost Software License, Version |
---|
5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | // |
---|
8 | // For more information, see http://www.boost.org/libs/range/ |
---|
9 | // |
---|
10 | |
---|
11 | #if !defined(BOOST_RANGE_DETAIL_MFC_CSTRING_HPP) && defined(BOOST_RANGE_ENABLE_MFC) |
---|
12 | #define BOOST_RANGE_DETAIL_MFC_CSTRING_HPP |
---|
13 | |
---|
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) |
---|
15 | # pragma once |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <afx.h> // for CString |
---|
19 | #include <boost/range/config.hpp> |
---|
20 | #include <boost/range/metafunctions.hpp> |
---|
21 | |
---|
22 | namespace boost |
---|
23 | { |
---|
24 | template<> |
---|
25 | struct range_iterator< CString > |
---|
26 | { |
---|
27 | typedef TCHAR* type; |
---|
28 | }; |
---|
29 | |
---|
30 | // |
---|
31 | // Why is this needed?!? |
---|
32 | // |
---|
33 | template<> |
---|
34 | struct range_iterator< const CString > |
---|
35 | { |
---|
36 | typedef TCHAR* type; |
---|
37 | }; |
---|
38 | |
---|
39 | template<> |
---|
40 | struct range_const_iterator< CString > |
---|
41 | { |
---|
42 | typedef const TCHAR* type; |
---|
43 | }; |
---|
44 | |
---|
45 | template<> |
---|
46 | struct range_difference< CString > |
---|
47 | { |
---|
48 | typedef std::ptrdiff_t type; |
---|
49 | }; |
---|
50 | |
---|
51 | template<> |
---|
52 | struct range_size< CString > |
---|
53 | { |
---|
54 | typedef int type; |
---|
55 | }; |
---|
56 | |
---|
57 | template<> |
---|
58 | struct range_value< CString > |
---|
59 | { |
---|
60 | typedef TCHAR type; |
---|
61 | }; |
---|
62 | |
---|
63 | TCHAR* boost_range_begin( CString& r ) |
---|
64 | { |
---|
65 | return r.GetBuffer(0); |
---|
66 | } |
---|
67 | |
---|
68 | const TCHAR* boost_range_begin( const CString& r ) |
---|
69 | { |
---|
70 | return (LPCTSTR)r; |
---|
71 | } |
---|
72 | |
---|
73 | int boost_range_size( const CString& r ) |
---|
74 | { |
---|
75 | return r.GetLength(); |
---|
76 | } |
---|
77 | |
---|
78 | TCHAR* boost_range_end( CString& r ) |
---|
79 | { |
---|
80 | return boost_range_begin( r ) + boost_range_size( r ); |
---|
81 | } |
---|
82 | |
---|
83 | const TCHAR* range_adl_end( const CString& r ) |
---|
84 | { |
---|
85 | return boost_range_begin( r ) + boost_range_size( r ); |
---|
86 | } |
---|
87 | |
---|
88 | // default 'empty()' ok |
---|
89 | |
---|
90 | } // namespace 'boost' |
---|
91 | |
---|
92 | #endif |
---|