📄 listview_sequence.hpp
字号:
bool operator ==(class_type const& rhs) const
{
WINSTL_MESSAGE_ASSERT("Comparing iterators from different listview_sequence instances!", m_hwndListView == rhs.m_hwndListView);
return m_index == rhs.m_index;
}
bool operator !=(class_type const& rhs) const
{
WINSTL_MESSAGE_ASSERT("Comparing iterators from different listview_sequence instances!", m_hwndListView == rhs.m_hwndListView);
return m_index != rhs.m_index;
}
class_type& operator ++()
{
WINSTL_MESSAGE_ASSERT("Attempting to increment an off-the-end iterator", m_index < ListView_GetItemCount(m_hwndListView));
++m_index;
return *this;
}
/// Post-increment operator
class_type operator ++(int)
{
class_type ret(*this);
operator ++();
return ret;
}
class_type& operator --()
{
WINSTL_MESSAGE_ASSERT("Attempting to decrement an iterator at the start of the sequence", 0 < m_index);
--m_index;
return *this;
}
/// Post-decrement operator
class_type operator --(int)
{
class_type ret(*this);
operator --();
return ret;
}
// Random access operations
/// Offset
class_type& operator +=(difference_type index)
{
m_index += index;
return *this;
}
/// Offset
class_type& operator -=(difference_type index)
{
m_index -= index;
return *this;
}
/// Indexing operator
value_type operator [](difference_type index) const
{
return value_type(m_hwndListView, m_index + index);
}
/// Calculate the distance between \c this and \c rhs
difference_type distance(class_type const& rhs) const
{
return m_index - rhs.m_index;
}
/// Pointer subtraction
class_type operator -(difference_type n) const
{
return class_type(*this) -= n;
}
/// Pointer addition
class_type operator +(difference_type n) const
{
return class_type(*this) += n;
}
/// Pointer difference
difference_type operator -(class_type const& rhs) const
{
return distance(rhs);
}
// Members
private:
HWND m_hwndListView;
int m_index;
};
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
/// The non-mutating (const) reverse iterator type
typedef stlsoft_ns_qual(const_reverse_iterator_base)< const_iterator
, value_type
, value_type // By-Value Temporary reference category
, void // By-Value Temporary reference category
, difference_type
> const_reverse_iterator;
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
// State
public:
/// Returns the number of elements in the list-box
size_type size() const
{
return static_cast<size_type>(ListView_GetItemCount(m_hwndListView));
}
/// Indicates whether the list-box is empty
ws_bool_t empty() const
{
return 0 == size();
}
/// Returns the maximum number of items that the list-box can contain
static size_type max_size()
{
return static_cast<size_type>(-1) / sizeof(LPCTSTR);
}
// Iteration
public:
const_iterator begin() const
{
return const_iterator(m_hwndListView, 0);
}
const_iterator end() const
{
return const_iterator(m_hwndListView, static_cast<int>(size()));
}
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
/// Begins the reverse iteration
///
/// \return An iterator representing the start of the reverse sequence
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(end());
}
/// Ends the reverse iteration
///
/// \return An iterator representing the end of the reverse sequence
const_reverse_iterator rend() const
{
return const_reverse_iterator(begin());
}
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
// Accessors
public:
value_type operator [](size_type index) const
{
return value_type(m_hwndListView, static_cast<int>(index));
}
private:
HWND m_hwndListView;
};
/* /////////////////////////////////////////////////////////////////////////
* Shims
*/
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, true, processheap_allocator<TCHAR> > c_str_ptr_null(listview_sequence_item const& lvi)
{
return stlsoft_ns_qual(c_str_ptr_null)(lvi.text());
}
#ifdef UNICODE
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, true, processheap_allocator<TCHAR> > c_str_ptr_null_w(listview_sequence_item const& lvi)
#else /* ? UNICODE */
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, true, processheap_allocator<TCHAR> > c_str_ptr_null_a(listview_sequence_item const& lvi)
#endif /* UNICODE */
{
return stlsoft_ns_qual(c_str_ptr_null)(lvi.text());
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, false, processheap_allocator<TCHAR> > c_str_ptr(listview_sequence_item const& lvi)
{
return stlsoft_ns_qual(c_str_ptr)(lvi.text());
}
#ifdef UNICODE
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, true, processheap_allocator<TCHAR> > c_str_ptr_w(listview_sequence_item const& lvi)
#else /* ? UNICODE */
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, true, processheap_allocator<TCHAR> > c_str_ptr_a(listview_sequence_item const& lvi)
#endif /* UNICODE */
{
return stlsoft_ns_qual(c_str_ptr)(lvi.text());
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, false, processheap_allocator<TCHAR> > c_str_data(listview_sequence_item const& lvi)
{
return stlsoft_ns_qual(c_str_data)(lvi.text());
}
#ifdef UNICODE
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, true, processheap_allocator<TCHAR> > c_str_data_w(listview_sequence_item const& lvi)
#else /* ? UNICODE */
inline stlsoft_ns_qual(basic_shim_string)<TCHAR, 64, true, processheap_allocator<TCHAR> > c_str_data_a(listview_sequence_item const& lvi)
#endif /* UNICODE */
{
return stlsoft_ns_qual(c_str_data)(lvi.text());
}
inline ws_size_t c_str_len(listview_sequence_item const& lvi)
{
return stlsoft_ns_qual(c_str_len)(lvi.text());
}
template< ss_typename_param_k S
>
inline S& operator <<(S& s, listview_sequence_item const& lvi)
{
s << lvi.text();
return s;
}
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _WINSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace winstl
# else
} // namespace winstl_project
} // namespace stlsoft
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*
* The string access shims exist either in the stlsoft namespace, or in the
* global namespace. This is required by the lookup rules.
*
*/
#ifndef _WINSTL_NO_NAMESPACE
# if !defined(_STLSOFT_NO_NAMESPACE) && \
!defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
namespace stlsoft
{
# else /* ? _STLSOFT_NO_NAMESPACE */
/* There is no stlsoft namespace, so must define in the global namespace */
# endif /* !_STLSOFT_NO_NAMESPACE */
using ::winstl::c_str_ptr_null;
using ::winstl::c_str_ptr_null_a;
using ::winstl::c_str_ptr_null_w;
using ::winstl::c_str_ptr;
using ::winstl::c_str_ptr_a;
using ::winstl::c_str_ptr_w;
using ::winstl::c_str_data;
using ::winstl::c_str_data_a;
using ::winstl::c_str_data_w;
using ::winstl::c_str_len;
# if !defined(_STLSOFT_NO_NAMESPACE) && \
!defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace stlsoft
# else /* ? _STLSOFT_NO_NAMESPACE */
/* There is no stlsoft namespace, so must define in the global namespace */
# endif /* !_STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* WINSTL_INCL_WINSTL_CONTROLS_HPP_LISTVIEW_SEQUENCE */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -