📄 readdir_sequence.hpp
字号:
/// @{
private:
readdir_sequence(class_type const&);
class_type& operator =(class_type const&);
/// @}
};
/// \brief Iterator for readdir_sequence class
///
/// This class performs as a non-mutating iterator (aka const iterator) for the
/// readdir_sequence class.
class readdir_sequence::const_iterator
: public stlsoft_ns_qual(iterator_base)<platformstl_ns_qual_std(input_iterator_tag)
, readdir_sequence::value_type
, ss_ptrdiff_t
, void
, readdir_sequence::value_type
>
{
/// \name Members
/// @{
public:
/// The class type
typedef const_iterator class_type;
/// The value type
typedef readdir_sequence::value_type value_type;
/// The flags type
typedef readdir_sequence::flags_type flags_type;
/// @}
/// \name Construction
/// @{
private:
friend class readdir_sequence;
/// Construct an instance and begin a sequence iteration on the given dir.
const_iterator(underlying_sequence_const_iterator_type it, flags_type flags)
: m_it(it)
, m_flags(flags)
{}
public:
/// Default constructor
const_iterator()
: m_it()
, m_flags(0)
{}
/// Copy constructor
const_iterator(class_type const& rhs)
: m_it(rhs.m_it)
, m_flags(rhs.m_flags)
{}
/// Release the search handle
~const_iterator() stlsoft_throw_0()
{}
/// Copy assignment operator
class_type const& operator =(class_type const& rhs)
{
m_it = rhs.m_it;
m_flags = rhs.m_flags;
return *this;
}
/// @}
/// \name Input Iterator Methods
/// @{
public:
/// Returns the value representative
value_type operator *() const
{
remove_const(m_value) = *m_it;
return (fullPath & m_flags) ? m_value.get_path() : m_value.get_filename();
}
/// Moves the iteration on to the next point in the sequence, or end() if
/// the sequence is exhausted
class_type& operator ++()
{
++m_it;
return *this;
}
/// Post-increment form of operator ++().
///
/// \note Because this version uses a temporary on which to call the
/// pre-increment form it is thereby less efficient, and should not be used
/// except where post-increment semantics are required.
class_type operator ++(int)
{
class_type r(*this);
operator ++();
return r;
}
/// Compares \c this for equality with \c rhs
///
/// \param rhs The instance against which to test
/// \retval true if the iterators are equivalent
/// \retval false if the iterators are not equivalent
bool equal(class_type const& rhs) const
{
return m_it == rhs.m_it;
}
/// @}
/// \name Members
/// @{
private:
underlying_sequence_const_iterator_type m_it;
underlying_sequence_value_type m_value;
flags_type m_flags;
/// @}
};
inline /* static */ readdir_sequence::flags_type readdir_sequence::validate_flags_(readdir_sequence::flags_type flags)
{
const flags_type validFlags = 0
| includeDots
| directories
| files
| fullPath
| absolutePath
| 0;
WINSTL_MESSAGE_ASSERT("Specification of unrecognised/unsupported flags", flags == (flags & validFlags));
STLSOFT_SUPPRESS_UNUSED(validFlags);
if(0 == (flags & (directories | files)))
{
flags |= (directories | files);
}
return flags;
}
inline /* static */ readdir_sequence::flags_type readdir_sequence::translate_flags_(readdir_sequence::flags_type flags)
{
flags_type translatedFlags = 0;
if(underlying_sequence_type::includeDots & flags)
{
translatedFlags |= underlying_sequence_type::includeDots;
}
if(directories & flags)
{
translatedFlags |= underlying_sequence_type::directories;
}
if(files & flags)
{
translatedFlags |= underlying_sequence_type::files;
}
if(fullPath == ((fullPath | absolutePath) & flags))
{
translatedFlags |= underlying_sequence_type::relativePath;
}
return translatedFlags;
}
inline readdir_sequence::const_iterator readdir_sequence::begin() const
{
return const_iterator(m_ffs.begin(), m_flags);
}
inline readdir_sequence::const_iterator readdir_sequence::end() const
{
return const_iterator(m_ffs.end(), m_flags);
}
inline readdir_sequence::bool_type readdir_sequence::empty() const
{
return m_ffs.empty();
}
inline readdir_sequence::char_type const* readdir_sequence::get_directory() const
{
return m_ffs.get_directory();
}
inline readdir_sequence::flags_type readdir_sequence::get_flags() const
{
return m_flags;
}
inline ss_bool_t operator ==( readdir_sequence::const_iterator const& lhs
, readdir_sequence::const_iterator const& rhs)
{
return lhs.equal(rhs);
}
inline ss_bool_t operator !=( readdir_sequence::const_iterator const& lhs
, readdir_sequence::const_iterator const& rhs)
{
return !lhs.equal(rhs);
}
#else /* ? operating system */
# error Operating system not discriminated
#endif /* operating system */
/* ////////////////////////////////////////////////////////////////////// */
#if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace platformstl
#else
} // namespace platformstl_project
} // namespace stlsoft
#endif /* _STLSOFT_NO_NAMESPACE */
#if defined(PLATFORMSTL_OS_IS_WIN32) && \
( defined(STLSOFT_COMPILER_IS_BORLAND) || \
defined(STLSOFT_COMPILER_IS_DMC))
inline int operator ==( platformstl::readdir_sequence::const_iterator const& lhs
, platformstl::readdir_sequence::const_iterator const& rhs)
{
return lhs.equal(rhs);
}
inline int operator !=( platformstl::readdir_sequence::const_iterator const& lhs
, platformstl::readdir_sequence::const_iterator const& rhs)
{
return !lhs.equal(rhs);
}
#endif /* WIN32 && compiler */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !PLATFORMSTL_INCL_PLATFORMSTL_FILESYSTEM_HPP_READDIR_SEQUENCE */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -