00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00046 # define RECLS_VER_RECLS_CPP_HPP_SEARCH_MAJOR 3
00047 # define RECLS_VER_RECLS_CPP_HPP_SEARCH_MINOR 0
00048 # define RECLS_VER_RECLS_CPP_HPP_SEARCH_REVISION 2
00049 # define RECLS_VER_RECLS_CPP_HPP_SEARCH_EDIT 10
00050 #endif
00051
00056
00057
00058
00059
00060 #include <recls/cpp/recls.hpp>
00061 #include <recls/cpp/fileentry.hpp>
00062 #include <recls/assert.h>
00063 #include <utility>
00064
00065
00066
00067
00068
00069 #if !defined(RECLS_NO_NAMESPACE)
00070 namespace recls
00071 {
00072
00073 namespace cpp
00074 {
00075 #endif
00076
00077
00078
00079
00080
00084 class Search
00085 {
00087 public:
00089 typedef Search class_type;
00091
00094 protected:
00095 typedef std::pair<hrecls_t, recls_rc_t> ctor_args_type;
00096
00100 Search(ctor_args_type args);
00101 public:
00107 virtual ~Search() = 0;
00109
00112 public:
00114 recls_rc_t GetNext();
00116
00119 public:
00121 recls_bool_t HasMoreElements() const;
00125 FileEntry GetCurrentEntry() const;
00126
00128 recls_rc_t GetLastError() const;
00129
00131 recls_uint32_t GetNumOutstandingDetails() const;
00133
00134
00135 protected:
00136
00137
00138 recls_rc_t &GetLastError_();
00139
00140 static FileEntry make_entry_(recls_info_t info);
00141
00142
00143 private:
00144 hrecls_t m_hSrch;
00145 mutable recls_rc_t m_lastError;
00146
00147
00148 private:
00149 Search(class_type const &);
00150 class_type &operator =(class_type const &);
00151 };
00152
00153
00154
00155
00156
00157 inline FileEntry Search::make_entry_(recls_info_t info)
00158 {
00159 return FileEntry(info);
00160 }
00161
00162
00163 inline Search::Search(Search::ctor_args_type args)
00164 : m_hSrch(args.first)
00165 , m_lastError(args.second)
00166 {
00167 RECLS_ASSERT(NULL != m_hSrch || RECLS_FAILED(m_lastError));
00168 RECLS_ASSERT(NULL == m_hSrch || RECLS_SUCCEEDED(m_lastError));
00169 }
00170
00171 inline Search::~Search()
00172 {
00173 if(NULL != m_hSrch)
00174 {
00175 Recls_SearchClose(m_hSrch);
00176 }
00177 }
00178
00179 inline recls_rc_t Search::GetNext()
00180 {
00181 RECLS_ASSERT(NULL != m_hSrch);
00182
00183 recls_rc_t rc = Recls_GetNext(m_hSrch);
00184
00185 if(RECLS_FAILED(rc))
00186 {
00187 Recls_SearchClose(m_hSrch);
00188 m_hSrch = NULL;
00189 }
00190
00191 m_lastError = rc;
00192
00193 return rc;
00194 }
00195
00196 inline recls_bool_t Search::HasMoreElements() const
00197 {
00198 return RECLS_SUCCEEDED(m_lastError);
00199 }
00200
00201 inline FileEntry Search::GetCurrentEntry() const
00202 {
00203 recls_info_t info;
00204 recls_rc_t rc = Recls_GetDetails(m_hSrch, &info);
00205
00206 return RECLS_SUCCEEDED(m_lastError = rc) ? make_entry_(info) : FileEntry();
00207 }
00208
00209 inline recls_rc_t Search::GetLastError() const
00210 {
00211 return m_lastError;
00212 }
00213
00214 inline recls_uint32_t Search::GetNumOutstandingDetails() const
00215 {
00216 recls_uint32_t cDetails;
00217 recls_rc_t rc = Recls_OutstandingDetails(m_hSrch, &cDetails);
00218
00219 if(RECLS_FAILED(m_lastError = rc))
00220 {
00221 cDetails = 0;
00222 }
00223
00224 return cDetails;
00225 }
00226
00227 inline recls_rc_t &Search::GetLastError_()
00228 {
00229 return m_lastError;
00230 }
00231
00232
00233
00234
00235
00236 #if !defined(RECLS_NO_NAMESPACE)
00237 }
00238 }
00239 #endif
00240
00241
00242
00243
00244
00245