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
00046
00047
00048
00049
00050
00057
00058
00059
00060
00061 #ifndef RECLS_INCL_RECLS_STL_HPP_RECLS
00062 # include <recls/stl/recls.hpp>
00063 #endif
00064 #ifndef RECLS_INCL_H_RECLS_ASSERT
00065 # include <recls_assert.h>
00066 #endif
00067 #ifndef _STLSOFT_INCL_H_STLSOFT_ITERATOR
00068 # include <stlsoft_iterator.h>
00069 #endif
00070 #ifndef _STLSOFT_INCL_H_STLSOFT_PROXY_SEQUENCE
00071 # include <stlsoft_proxy_sequence.h>
00072 #endif
00073
00074
00075
00076
00077
00078 #if !defined(RECLS_NO_NAMESPACE)
00079 namespace recls
00080 {
00081
00082 namespace stl
00083 {
00084 #endif
00085
00086
00087
00088
00089
00093 template <typename C>
00094 struct reclstl_traits
00095 {
00096 public:
00101 typedef void char_type;
00106 typedef void *entry_type;
00107
00108 public:
00109 #if defined(RECLS_API_FTP)
00110
00111 static hrecls_t SearchFtp(char_type const *host, char_type const *username, char_type const *password, char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags);
00112 #endif
00113
00115 static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags);
00116
00118 static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo);
00120 static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo);
00121
00123 static void CloseDetails(entry_type fileInfo);
00125 static entry_type CopyDetails(entry_type fileInfo);
00126
00128 static char_type *str_copy(char_type *, char_type const *);
00129 };
00130
00131 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00132
00133 # ifdef RECLS_CHAR_TYPE_IS_CHAR
00134
00135 template <>
00136 struct reclstl_traits<recls_char_a_t>
00137 {
00138 public:
00139 typedef reclstl_traits<recls_char_a_t> traits_type;
00140 typedef recls_char_a_t char_type;
00141 typedef recls_info_t entry_type;
00142 typedef recls_strptrs_t strptrs_type;
00143 typedef recls_strptrsptrs_t strptrsptrs_type;
00144
00146 typedef stlsoft::proxy_sequence< const strptrs_type
00147 , string_t
00148 , traits_type
00149 > directory_parts_type;
00150
00154 static string_t make_value(strptrs_type const &ptrs)
00155 {
00156 return string_t(ptrs.begin, ptrs.end);
00157 }
00158
00159 public:
00160 #if defined(RECLS_API_FTP)
00161 static hrecls_t SearchFtp(char_type const *host, char_type const *username, char_type const *password, char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00162 {
00163 hrecls_t hSrch;
00164 recls_rc_t rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00165
00166 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00167 }
00168 #endif
00169
00170 static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00171 {
00172 hrecls_t hSrch;
00173 recls_rc_t rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00174
00175 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00176 }
00177
00178 static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00179 {
00180 return Recls_GetDetails(hSrch, pinfo);
00181 }
00182
00183 static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00184 {
00185 return Recls_GetNextDetails(hSrch, pinfo);
00186 }
00187
00188 static void CloseDetails(entry_type fileInfo)
00189 {
00190 Recls_CloseDetails(fileInfo);
00191 }
00192 static entry_type CopyDetails(entry_type fileInfo)
00193 {
00194 entry_type infoCopy;
00195
00196 return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00197 }
00198
00199 static char_type *str_copy(char_type *dest, char_type const *src)
00200 {
00201 return strcpy(dest, src);
00202 }
00203 };
00204
00205 # elif defined(RECLS_CHAR_TYPE_IS_WCHAR)
00206
00207 template <>
00208 struct reclstl_traits<recls_char_w_t>
00209 {
00210 public:
00211 typedef reclstl_traits<recls_char_w_t> traits_type;
00212 typedef recls_char_w_t char_type;
00213 typedef recls_info_t entry_type;
00214 typedef recls_strptrs_t strptrs_type;
00215 typedef recls_strptrsptrs_t strptrsptrs_type;
00216
00218 typedef stlsoft::proxy_sequence< const strptrs_type
00219 , string_t
00220 , traits_type
00221 > directory_parts_type;
00222
00226 static string_t make_value(strptrs_type const &ptrs)
00227 {
00228 return string_t(ptrs.begin, ptrs.end);
00229 }
00230
00231 public:
00232 #if defined(RECLS_API_FTP)
00233 static hrecls_t SearchFtp(char_type const *host, char_type const *username, char_type const *password, char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00234 {
00235 hrecls_t hSrch;
00236 recls_rc_t rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00237
00238 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00239 }
00240 #endif
00241
00242 static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00243 {
00244 hrecls_t hSrch;
00245 recls_rc_t rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00246
00247 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00248 }
00249
00250 static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00251 {
00252 return Recls_GetDetails(hSrch, pinfo);
00253 }
00254
00255 static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00256 {
00257 return Recls_GetNextDetails(hSrch, pinfo);
00258 }
00259
00260 static void CloseDetails(entry_type fileInfo)
00261 {
00262 Recls_CloseDetails(fileInfo);
00263 }
00264 static entry_type CopyDetails(entry_type fileInfo)
00265 {
00266 entry_type infoCopy;
00267
00268 return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00269 }
00270
00271 static char_type *str_copy(char_type *dest, char_type const *src)
00272 {
00273 return wcscpy(dest, src);
00274 }
00275 };
00276
00277 # else
00278
00279 # error Neither RECLS_CHAR_TYPE_IS_WCHAR nor RECLS_CHAR_TYPE_IS_CHAR are defined
00280
00281 # endif
00282
00283
00284 #endif
00285
00286
00287
00288
00289
00290 }
00291 #endif
00292
00293
00294
00295
00296
00297