C/C++ User's Journal STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - where the Standard Template Library meets the Active Template Library COMSTL - where the Standard Template Library meets the Component Object Model
Synesis Software InetSTL - where the Standard Template Library meets the Internet UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

H:/freelibs/recls/current/src/ReclsFtpSearchDirectoryNode_win32.hpp

00001 /* /////////////////////////////////////////////////////////////////////////////
00002  * File:        ReclsFtpSearchDirectoryNode_win32.h
00003  *
00004  * Purpose:     ReclsFtpSearchDirectoryNode class, for Win32.
00005  *
00006  * Created:     31st May 2004
00007  * Updated:     22nd April 2007
00008  *
00009  * Home:        http://recls.org/
00010  *
00011  * Copyright (c) 2004-2007, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without 
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer. 
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * ////////////////////////////////////////////////////////////////////////// */
00039 
00040 
00044 /* /////////////////////////////////////////////////////////////////////////////
00045  * Includes
00046  */
00047 
00048 // recls includes
00049 #include <recls/recls.h>
00050 #include "recls_string.h"
00051 #include "recls_util.h"
00052 
00053 // STLSoft includes
00054 #include <stlsoft/stlsoft.h>    /* If the compiler cannot find this, you are not using STLSoft 1.9.1 or later, as required. */
00055 #if !defined(_STLSOFT_VER_1_9_1) || \
00056     _STLSOFT_VER < _STLSOFT_VER_1_9_1
00057 # error Requires STLSoft 1.9.1, or later. (www.stlsoft.org/downloads.html)
00058 #endif /* STLSoft version */
00059 
00060 // Platform-specific includes
00061 #include <inetstl/inetstl.h>
00062 #include <inetstl/filesystem/filesystem_traits.hpp>
00063 #include <inetstl/filesystem/findfile_sequence.hpp>
00064 
00065 // The Dinkumware list implementation causes Visual C++ 7.1 to give C4702 warning, so we don't use it
00066 #if defined(RECLS_COMPILER_IS_MSVC) && \
00067     _MSC_VER >= 1310
00068 # include <vector>
00069 #else /* ? compiler */
00070 # include <list>
00071 #endif /* compiler */
00072 
00073 /* /////////////////////////////////////////////////////////////////////////////
00074  * Namespace
00075  */
00076 
00077 #if !defined(RECLS_NO_NAMESPACE)
00078 namespace recls
00079 {
00080 #endif /* !RECLS_NO_NAMESPACE */
00081 
00082 inetstl_ns_using(basic_findfile_sequence)
00083 
00084 /* /////////////////////////////////////////////////////////////////////////////
00085  * Classes
00086  */
00087 
00088 class ReclsFtpSearchDirectoryNode
00089     : public ReclsSearchDirectoryNode
00090 {
00091 public:
00092     typedef ReclsFtpSearchDirectoryNode                                     class_type;
00093     typedef inetstl_ns_qual(filesystem_traits)<recls_char_t>                traits_type;
00094 private:
00095     typedef RECLS_STRING_TEMPLATE_1(recls_char_t)                           string_type;
00096     typedef basic_findfile_sequence<recls_char_t, traits_type>              file_find_sequence_type;
00097 #if defined(RECLS_COMPILER_IS_MSVC) && \
00098     _MSC_VER >= 1310
00099     typedef stlsoft_ns_qual_std(vector)<string_type>                        directory_sequence_type;
00100 #else /* ? compiler */
00101     typedef stlsoft_ns_qual_std(list)<string_type>                          directory_sequence_type;
00102 #endif /* compiler */
00103 #ifdef _RECLS_USING_INETSTL_SEARCHSPEC_SEQUENCE
00104     typedef inetstl_ns_qual(searchspec_sequence)<file_find_sequence_type>   entry_sequence_type;
00105 #else /* ? _RECLS_USING_INETSTL_SEARCHSPEC_SEQUENCE */
00106     typedef file_find_sequence_type                                         entry_sequence_type;
00107 #endif /* _RECLS_USING_INETSTL_SEARCHSPEC_SEQUENCE */
00108 
00109 // Construction
00110 protected: // Not private, or GCC whines
00111     ReclsFtpSearchDirectoryNode(HINTERNET connection, recls_uint32_t flags, recls_char_t const *rootDir, recls_char_t const *pattern);
00112 public:
00113     virtual ~ReclsFtpSearchDirectoryNode();
00114 
00115     static class_type *FindAndCreate(HINTERNET connection, recls_uint32_t flags, recls_char_t const *rootDir, recls_char_t const *pattern);
00116 
00117 // ReclsSearchDirectoryNode methods
00118 public:
00119     /* virtual */ recls_rc_t GetNext();
00120     /* virtual */ recls_rc_t GetDetails(recls_info_t *pinfo);
00121     /* virtual */ recls_rc_t GetNextDetails(recls_info_t *pinfo);
00122 
00123 // Implementation
00124 private:
00125     recls_rc_t      Initialise();
00126 
00127 #ifdef RECLS_ENFORCING_CONTRACTS
00128     recls_bool_t    is_valid() const;
00129 #endif /* RECLS_ENFORCING_CONTRACTS */
00130 
00131     static directory_sequence_type::const_iterator select_iter_if_( unsigned long                           b
00132                                                                 ,   directory_sequence_type::const_iterator trueVal
00133                                                                 ,   directory_sequence_type::const_iterator falseVal);
00134     static int essFlags_from_reclsFlags_(recls_uint32_t flags);
00135 
00136 // Implementation
00137 private:
00138     static directory_sequence_type init_directories_(HINTERNET connection, recls_char_t const *rootDir, recls_uint32_t flags);
00139 
00140 // Members
00141 private:
00142     HINTERNET                               m_connection;
00143     recls_info_t                            m_current;
00144     class_type                              *m_dnode;
00145     recls_uint32_t const                    m_flags;
00146     string_type                             m_rootDir;
00147     string_type                             m_pattern;
00148     directory_sequence_type                 m_directories;
00149     directory_sequence_type::const_iterator m_directoriesBegin;
00150     entry_sequence_type                     m_entries;
00151     entry_sequence_type::const_iterator     m_entriesBegin;
00152 
00153 // Not to be implemented
00154 private:
00155     ReclsFtpSearchDirectoryNode(class_type const &);
00156     class_type &operator =(class_type const &);
00157 };
00158 
00159 /* /////////////////////////////////////////////////////////////////////////////
00160  * Namespace
00161  */
00162 
00163 #if !defined(RECLS_NO_NAMESPACE)
00164 } /* namespace recls */
00165 #endif /* !RECLS_NO_NAMESPACE */
00166 
00167 /* ////////////////////////////////////////////////////////////////////////// */

recls Library documentation © Synesis Software Pty Ltd, 2001-2006