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

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/include/recls/stl/traits.hpp

Go to the documentation of this file.
00001 /* 
00002  * File:        recls/stl/traits.hpp
00003  *
00004  * Purpose:     Contains character-base traits for the recls::stl mapping.
00005  *
00006  * Created:     25th March 2004
00007  * Updated:     19th May 2005
00008  *
00009  * Home:        http://recls.org/
00010  *
00011  * Copyright 2004-2005, 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 
00041 #ifndef RECLS_INCL_RECLSTL_STL_HPP_TRAITS
00042 #define RECLS_INCL_RECLSTL_STL_HPP_TRAITS
00043 
00044 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00045 # define RECLS_VER_RECLSTL_STL_HPP_TRAITS_MAJOR     3
00046 # define RECLS_VER_RECLSTL_STL_HPP_TRAITS_MINOR     0
00047 # define RECLS_VER_RECLSTL_STL_HPP_TRAITS_REVISION  2
00048 # define RECLS_VER_RECLSTL_STL_HPP_TRAITS_EDIT      12
00049 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00050 
00057 /* 
00058  * Includes
00059  */
00060 
00061 #ifndef RECLS_INCL_RECLS_STL_HPP_RECLS
00062 # include <recls/stl/recls.hpp>
00063 #endif /* !RECLS_INCL_RECLS_STL_HPP_RECLS */
00064 #ifndef RECLS_INCL_H_RECLS_ASSERT
00065 # include <recls_assert.h>
00066 #endif /* !RECLS_INCL_H_RECLS_ASSERT */
00067 #include <stlsoft/proxy_sequence.hpp>
00068 
00069 /* 
00070  * Namespace
00071  */
00072 
00073 #if !defined(RECLS_NO_NAMESPACE)
00074 namespace recls
00075 {
00076 
00077 namespace stl
00078 {
00079 #endif /* !RECLS_NO_NAMESPACE */
00080 
00081 /* 
00082  * Classes
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 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);
00107 #endif /* RECLS_API_FTP */
00108 
00110     static hrecls_t         Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags);
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 // Note, this type also serves as the traits type for the STLSoft proxy_sequence
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 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)
00157     {
00158         hrecls_t    hSrch;
00159         recls_rc_t  rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00160 
00161         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00162     }
00163 #endif /* RECLS_API_FTP */
00164 
00165     static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00166     {
00167         hrecls_t    hSrch;
00168         recls_rc_t  rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00169 
00170         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00171     }
00172 
00173     static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00174     {
00175         return Recls_GetDetails(hSrch, pinfo);
00176     }
00177 
00178     static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00179     {
00180         return Recls_GetNextDetails(hSrch, pinfo);
00181     }
00182 
00183     static void CloseDetails(entry_type fileInfo)
00184     {
00185         Recls_CloseDetails(fileInfo);
00186     }
00187     static entry_type CopyDetails(entry_type fileInfo)
00188     {
00189         entry_type  infoCopy;
00190 
00191         return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00192     }
00193 
00194     static char_type *str_copy(char_type *dest, char_type const *src)
00195     {
00196         return strcpy(dest, src);
00197     }
00198 };
00199 
00200 # elif defined(RECLS_CHAR_TYPE_IS_WCHAR)
00201 
00202 template <>
00203 struct reclstl_traits<recls_char_w_t>
00204 {
00205 public:
00206     typedef reclstl_traits<recls_char_w_t>      traits_type;
00207     typedef recls_char_w_t                      char_type;
00208     typedef recls_info_t                        entry_type;
00209     typedef recls_strptrs_t                     strptrs_type;
00210     typedef recls_strptrsptrs_t                 strptrsptrs_type;
00211 
00213     typedef stlsoft::proxy_sequence<    const strptrs_type
00214                                     ,   string_t
00215                                     ,   traits_type // Note, this type also serves as the traits type for the STLSoft proxy_sequence
00216                                     >           directory_parts_type;
00217 
00221     static string_t make_value(strptrs_type const &ptrs)
00222     {
00223         return string_t(ptrs.begin, ptrs.end);
00224     }
00225 
00226 public:
00227 #if defined(RECLS_API_FTP)
00228     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)
00229     {
00230         hrecls_t    hSrch;
00231         recls_rc_t  rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00232 
00233         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00234     }
00235 #endif /* RECLS_API_FTP */
00236 
00237     static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00238     {
00239         hrecls_t    hSrch;
00240         recls_rc_t  rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00241 
00242         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00243     }
00244 
00245     static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00246     {
00247         return Recls_GetDetails(hSrch, pinfo);
00248     }
00249 
00250     static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00251     {
00252         return Recls_GetNextDetails(hSrch, pinfo);
00253     }
00254 
00255     static void CloseDetails(entry_type fileInfo)
00256     {
00257         Recls_CloseDetails(fileInfo);
00258     }
00259     static entry_type CopyDetails(entry_type fileInfo)
00260     {
00261         entry_type  infoCopy;
00262 
00263         return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00264     }
00265 
00266     static char_type *str_copy(char_type *dest, char_type const *src)
00267     {
00268         return wcscpy(dest, src);
00269     }
00270 };
00271 
00272 # else /* character type */
00273 
00274 #  error Neither RECLS_CHAR_TYPE_IS_WCHAR nor RECLS_CHAR_TYPE_IS_CHAR are defined
00275 
00276 # endif /* character type */
00277 
00278 
00279 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00280 
00281 /* 
00282 
00283 #if !defined(RECLS_NO_NAMESPACE)
00284 } /* namespace stl */
00285 } /* namespace recls */
00286 #endif /* !RECLS_NO_NAMESPACE */
00287 
00288 /* 
00289 
00290 #endif /* RECLS_INCL_RECLSTL_STL_HPP_TRAITS */
00291 
00292 /* 

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