📄 drophandle_sequence.hpp
字号:
/// \brief Release any resources aquired
~basic_drophandle_sequence() stlsoft_throw_0();
// Attributes
public:
/// \brief The number of elements in the sequence
ws_size_t size() const;
/// \brief Indicates whether the sequence is empty
ws_bool_t empty() const;
// Iteration
public:
/// \brief Begins the iteration
///
/// \return An iterator representing the start of the sequence
const_iterator begin() const;
/// \brief Ends the iteration
///
/// \return An iterator representing the end of the sequence
const_iterator end() const;
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT) && \
!defined(STLSOFT_COMPILER_IS_BORLAND)
/// \brief Begins the reverse iteration
///
/// \return An iterator representing the start of the reverse sequence
const_reverse_iterator rbegin() const;
/// \brief Ends the reverse iteration
///
/// \return An iterator representing the end of the reverse sequence
const_reverse_iterator rend() const;
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
// Members
private:
HDROP m_hdrop;
const ws_bool_t m_bOwnHandle;
// Implementation
private:
// Not to be implemented
private:
basic_drophandle_sequence(class_type const&);
class_type& operator =(class_type const&);
};
/* Typedefs to commonly encountered types. */
/** \brief Specialisation of the basic_drophandle_sequence template for the ANSI character type \c char
*
* \ingroup group__library__shell
*/
typedef basic_drophandle_sequence<ws_char_a_t, drophandle_sequence_traits<ws_char_a_t> > drophandle_sequence_a;
/** \brief Specialisation of the basic_drophandle_sequence template for the Unicode character type \c wchar_t
*
* \ingroup group__library__shell
*/
typedef basic_drophandle_sequence<ws_char_w_t, drophandle_sequence_traits<ws_char_w_t> > drophandle_sequence_w;
/** \brief Specialisation of the basic_drophandle_sequence template for the ANSI character type \c char
*
* \ingroup group__library__shell
*/
typedef basic_drophandle_sequence<TCHAR, drophandle_sequence_traits<TCHAR> > drophandle_sequence;
////////////////////////////////////////////////////////////////////////////
// Operators
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ws_bool_t operator ==( basic_drophandle_sequence_const_iterator<C, T> const& lhs
, basic_drophandle_sequence_const_iterator<C, T> const& rhs)
{
return lhs.equal(rhs);
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ws_bool_t operator !=( basic_drophandle_sequence_const_iterator<C, T> const& lhs
, basic_drophandle_sequence_const_iterator<C, T> const& rhs)
{
return !lhs.equal(rhs);
}
////////////////////////////////////////////////////////////////////////////
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
// basic_drophandle_sequence_const_iterator
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline /* static */ ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::index_type basic_drophandle_sequence_const_iterator<C, T>::sentinel_()
{
return 0x7fffffff;
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline /* ss_explicit_k */ basic_drophandle_sequence_const_iterator<C, T>::basic_drophandle_sequence_const_iterator(HDROP hdrop, ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::index_type index)
: m_hdrop(hdrop)
, m_index(index)
{}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline basic_drophandle_sequence_const_iterator<C, T>::basic_drophandle_sequence_const_iterator()
: m_hdrop(0)
, m_index(sentinel_())
{}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline basic_drophandle_sequence_const_iterator<C, T>::basic_drophandle_sequence_const_iterator(ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type const& rhs)
: m_hdrop(rhs.m_hdrop)
, m_index(rhs.m_index)
{}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type &basic_drophandle_sequence_const_iterator<C, T>::operator =(ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type const& rhs)
{
m_hdrop = rhs.m_hdrop;
m_index = rhs.m_index;
return *this;
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type &basic_drophandle_sequence_const_iterator<C, T>::operator ++()
{
WINSTL_MESSAGE_ASSERT("Incrementing the end iterator", m_index != sentinel_());
char_type ch;
ws_uint_t res = traits_type::drag_query_file(m_hdrop, static_cast<ws_uint_t>(m_index + 1), &ch, 1);
if(res == 0)
{
// Failed, so become 'end'
m_index = sentinel_();
}
else
{
// Fine, so increment to next
++m_index;
}
return *this;
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type &basic_drophandle_sequence_const_iterator<C, T>::operator --()
{
// If currently at 'end' ....
if(m_index == sentinel_())
{
// ... then determine the new end ...
m_index = static_cast<index_type>(traits_type::drag_query_file(m_hdrop, 0xFFFFFFFF, NULL, 0));
if(m_index == 0xFFFFFFFF)
{
// ... failed. Must set to end again!
m_index = sentinel_();
}
else
{
// ... decrement from end
--m_index;
}
}
else
{
// ... decrement from current position
--m_index;
}
return *this;
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type basic_drophandle_sequence_const_iterator<C, T>::operator ++(int)
{
class_type ret(*this);
operator ++();
return ret;
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type basic_drophandle_sequence_const_iterator<C, T>::operator --(int)
{
class_type ret(*this);
operator --();
return ret;
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline const ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::value_type basic_drophandle_sequence_const_iterator<C, T>::operator *() const
{
WINSTL_MESSAGE_ASSERT("Dereferencing the end iterator", m_index != sentinel_());
ws_uint_t cch = traits_type::drag_query_file(m_hdrop, static_cast<ws_uint_t>(m_index), NULL, 0);
stlsoft_ns_qual(auto_buffer)<char_type> sz(1 + cch);
if( 0 == sz.size() ||
0 == (cch = traits_type::drag_query_file(m_hdrop, static_cast<ws_uint_t>(m_index), &sz[0], sz.size())))
{
sz[0] = '\0';
}
return value_type(sz.data());
}
template< ss_typename_param_k C
, ss_typename_param_k T
>
inline ws_bool_t basic_drophandle_sequence_const_iterator<C, T>::equal(ss_typename_type_k basic_drophandle_sequence_const_iterator<C, T>::class_type const& rhs) const
{
WINSTL_MESSAGE_ASSERT("Comparing iterators from different sequences", m_hdrop == NULL || rhs.m_hdrop == NULL || rhs.m_hdrop);
return m_index == rhs.m_index;
}
// basic_drophandle_sequence
template <ss_typename_param_k C, ss_typename_param_k T>
inline basic_drophandle_sequence<C, T>::basic_drophandle_sequence(HDROP hdrop, ws_bool_t bOwnHandle /* = true */)
: m_hdrop(hdrop)
, m_bOwnHandle(bOwnHandle)
{}
template <ss_typename_param_k C, ss_typename_param_k T>
inline basic_drophandle_sequence<C, T>::~basic_drophandle_sequence() stlsoft_throw_0()
{
if(m_bOwnHandle)
{
::DragFinish(m_hdrop);
}
}
template <ss_typename_param_k C, ss_typename_param_k T>
inline ws_size_t basic_drophandle_sequence<C, T>::size() const
{
return traits_type::drag_query_file(m_hdrop, static_cast<ws_uint_t>(-1), 0, 0);
}
template <ss_typename_param_k C, ss_typename_param_k T>
inline ws_bool_t basic_drophandle_sequence<C, T>::empty() const
{
return size() == 0;
}
template <ss_typename_param_k C, ss_typename_param_k T>
inline ss_typename_type_k basic_drophandle_sequence<C, T>::const_iterator basic_drophandle_sequence<C, T>::begin() const
{
char_type ch;
ws_uint_t res = traits_type::drag_query_file(m_hdrop, 0, &ch, 1);
return const_iterator(m_hdrop, (res == 0) ? const_iterator::sentinel_() : 0);
}
template <ss_typename_param_k C, ss_typename_param_k T>
inline ss_typename_type_k basic_drophandle_sequence<C, T>::const_iterator basic_drophandle_sequence<C, T>::end() const
{
return const_iterator(m_hdrop, const_iterator::sentinel_());
}
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT) && \
!defined(STLSOFT_COMPILER_IS_BORLAND)
template <ss_typename_param_k C, ss_typename_param_k T>
inline ss_typename_type_k basic_drophandle_sequence<C, T>::const_reverse_iterator basic_drophandle_sequence<C, T>::rbegin() const
{
return const_reverse_iterator(end());
}
template <ss_typename_param_k C, ss_typename_param_k T>
inline ss_typename_type_k basic_drophandle_sequence<C, T>::const_reverse_iterator basic_drophandle_sequence<C, T>::rend() const
{
return const_reverse_iterator(begin());
}
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
////////////////////////////////////////////////////////////////////////////
// Unit-testing
#ifdef STLSOFT_UNITTEST
# include "./unittest/drophandle_sequence_unittest_.h"
#endif /* STLSOFT_UNITTEST */
/* ////////////////////////////////////////////////////////////////////// */
#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 */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* WINSTL_INCL_WINSTL_SHELL_HPP_DROPHANDLE_SEQUENCE */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -