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