📄 findfile_sequence.hpp
字号:
private:
basic_findfile_sequence(class_type const &);
class_type &operator =(class_type const &);
/// @}
};
/* /////////////////////////////////////////////////////////////////////////
* Typedefs for commonly encountered types
*/
/// Instantiation of the basic_findfile_sequence template for the ANSI character type \c char
typedef basic_findfile_sequence<is_char_a_t
, filesystem_traits<is_char_a_t>
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
, throw_internet_exception_policy
#else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
, stlsoft_ns_qual(null_exception_policy)
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
> findfile_sequence_a;
/// Instantiation of the basic_findfile_sequence template for the Unicode character type \c wchar_t
typedef basic_findfile_sequence<is_char_w_t
, filesystem_traits<is_char_w_t>
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
, throw_internet_exception_policy
#else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
, stlsoft_ns_qual(null_exception_policy)
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
> findfile_sequence_w;
/// Instantiation of the basic_findfile_sequence template for the Win32 character type \c TCHAR
typedef basic_findfile_sequence<TCHAR
, filesystem_traits<TCHAR>
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
, throw_internet_exception_policy
#else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
, stlsoft_ns_qual(null_exception_policy)
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
> findfile_sequence;
/* ////////////////////////////////////////////////////////////////////// */
// class basic_findfile_sequence_value_type
/// Value type for the basic_findfile_sequence
template< ss_typename_param_k C
, ss_typename_param_k T
, ss_typename_param_k X
>
class basic_findfile_sequence_value_type
{
/// \name Member Types
/// @{
private:
typedef basic_findfile_sequence<C, T, X> sequence_type;
public:
/// The character type
typedef C char_type;
/// The exception policy type
typedef X exception_policy_type;
/// The type thrown
typedef ss_typename_param_k exception_policy_type::thrown_type thrown_type;
/// The traits type
typedef T traits_type;
/// The current parameterisation of the type
typedef basic_findfile_sequence_value_type<C, T, X> class_type;
/// The find-data type
typedef ss_typename_type_k traits_type::find_data_type find_data_type;
/// The size type
typedef ss_typename_type_k sequence_type::size_type size_type;
private:
typedef ss_typename_type_k sequence_type::bool_type bool_type;
typedef ss_typename_type_k sequence_type::flags_type flags_type;
typedef stlsoft_ns_qual(basic_simple_string)<char_type> string_type;
/// @}
/// \name Construction
// @{
public:
/// Default constructor
basic_findfile_sequence_value_type();
private:
basic_findfile_sequence_value_type(find_data_type const &data, char_type const *path)
: m_data(data)
{
if('/' != data.cFileName[0])
{
traits_type::str_copy(m_path, path);
traits_type::ensure_dir_end(m_path);
}
else
{
m_path[0] = '\0';
}
traits_type::str_cat(m_path, data.cFileName);
}
// @}
/// Accessors
// @{
public:
/// Returns a non-mutating reference to find-data
find_data_type const &get_find_data() const;
#ifdef STLSOFT_OBSOLETE
/// Returns a non-mutating reference to find-data
///
/// \deprecated This method may be removed in a future release. get_find_data() should be used instead
find_data_type const &GetFindData() const; // Deprecated
#endif /* STLSOFT_OBSOLETE */
/// Returns the filename part of the item
char_type const *get_filename() const;
/// Returns the short form of the filename part of the item
char_type const *get_short_filename() const;
/// Returns the full path of the item
char_type const *get_path() const;
/// Returns the full path of the item
char_type const *c_str() const;
/// Implicit conversion to a pointer-to-const of the full path
operator char_type const * () const;
/// Indicates whether the entry is a directory
bool_type is_directory() const;
/// Indicates whether the entry is a file
bool_type is_file() const;
/// Indicates whether the entry is read-only
bool_type is_read_only() const;
bool_type equal(char_type const *rhs) const;
bool_type equal(class_type const &rhs) const;
// @}
/// \name Members
/// @{
private:
friend class basic_findfile_sequence_const_input_iterator<C, T, X, class_type>;
find_data_type m_data;
char_type m_path[1 + _MAX_PATH];
/// @}
};
// class basic_findfile_sequence_const_input_iterator
/// Iterator type for the basic_findfile_sequence supporting the Input Iterator concept
template< ss_typename_param_k C
, ss_typename_param_k T
, ss_typename_param_k X
, ss_typename_param_k V
>
class basic_findfile_sequence_const_input_iterator
#ifndef STLSOFT_COMPILER_IS_WATCOM
: public stlsoft_ns_qual(iterator_base)<inetstl_ns_qual_std(input_iterator_tag)
, V
, is_ptrdiff_t
, void // By-Value Temporary reference
, V // By-Value Temporary reference
>
#endif /* compiler */
{
/// \name Member Types
/// @{
private:
typedef basic_findfile_sequence<C, T, X> sequence_type;
public:
/// The character type
typedef C char_type;
/// The exception policy type
typedef X exception_policy_type;
/// The type thrown
typedef ss_typename_param_k exception_policy_type::thrown_type thrown_type;
/// The traits type
typedef T traits_type;
/// The value type
typedef V value_type;
/// The current parameterisation of the type
typedef basic_findfile_sequence_const_input_iterator<C, T, X, V> class_type;
/// The find-data type
typedef ss_typename_type_k traits_type::find_data_type find_data_type;
/// The size type
typedef ss_typename_type_k sequence_type::size_type size_type;
private:
typedef ss_typename_type_k sequence_type::bool_type bool_type;
typedef ss_typename_type_k sequence_type::flags_type flags_type;
typedef ss_typename_type_k sequence_type::string_type string_type;
/// @}
/// \name Utility classes
/// @{
private:
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
struct shared_handle
{
/// \name Member Types
/// @{
public:
typedef shared_handle class_type;
typedef HINTERNET handle_type;
/// @}
/// \name Members
/// @{
public:
handle_type hSrch;
private:
ss_sint32_t m_refCount;
/// @}
/// \name Construction
/// @{
public:
ss_explicit_k shared_handle(handle_type h)
: hSrch(h)
, m_refCount(1)
{}
# if defined(STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR)
protected:
# else /* ? STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR */
private:
# endif /* STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR */
~shared_handle() stlsoft_throw_0()
{
INETSTL_MESSAGE_ASSERT("Shared search handle being destroyed with outstanding references!", 0 == m_refCount);
if(NULL != hSrch)
{
traits_type::find_close(hSrch);
}
}
/// @}
/// \name Operations
/// @{
public:
ss_sint32_t AddRef()
{
return ++m_refCount;
}
ss_sint32_t Release()
{
ss_sint32_t rc = --m_refCount;
if(0 == rc)
{
delete this;
}
return rc;
}
/// @}
/// \name Not to be implemented
/// @{
private:
shared_handle(class_type const &);
class_type &operator =(class_type const &);
/// @}
};
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/// @}
/// \name Construction
/// @{
private:
basic_findfile_sequence_const_input_iterator( sequence_type const &l
, char_type const *rootDir
, char_type const *patterns
, char_type delim
, flags_type flags);
basic_findfile_sequence_const_input_iterator( sequence_type const &l);
public:
/// Default constructor
basic_findfile_sequence_const_input_iterator();
/// <a href = "http://synesis.com.au/resources/articles/cpp/movectors.pdf">Move constructor</a>
basic_findfile_sequence_const_input_iterator(class_type const &rhs);
/// Destructor
~basic_findfile_sequence_const_input_iterator() stlsoft_throw_0();
// Copy assignment operator
basic_findfile_sequence_const_input_iterator &operator =(class_type const &rhs);
/// @}
/// \name Input Iterator methods
/// @{
public:
/// Pre-increment operator
class_type &operator ++();
/// Post-increment operator
class_type operator ++(int);
/// Dereference to return the value at the current position
const value_type operator *() const;
/// Evaluates whether \c this and \c rhs are equivalent
bool_type equal(class_type const &rhs) const;
/// @}
/// \name Implementation
/// @{
private:
static int find_next_pattern_(char_type const *&p0, char_type const *&p1, char_type delim);
static HINTERNET find_first_file_(HINTERNET hconn, char_type const *spec, flags_type flags, find_data_type *findData);
/// @}
/// \name Members
/// @{
private:
friend class basic_findfile_sequence<C, T, X>;
sequence_type const * const m_list;
shared_handle *m_handle;
ss_typename_type_k traits_type::find_data_type m_data;
char_type const * m_rootDir;
char_type const *m_pattern0;
char_type const *m_pattern1;
char_type m_delim;
flags_type m_flags;
/// @}
};
////////////////////////////////////////////////////////////////////////////
// Operators
// basic_findfile_sequence_const_input_iterator
template< ss_typename_param_k C
, ss_typename_param_k T
, ss_typename_param_k X
, ss_typename_param_k V
>
inline is_bool_t operator ==( basic_findfile_sequence_const_input_iterator<C, T, X, V> const &lhs
, basic_findfile_sequence_const_input_iterator<C, T, X, V> const &rhs)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -