C/C++ User's Journal Synesis Software 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 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  

/Mappings/STL/reclstl_traits.h

Go to the documentation of this file.
00001 /* 
00002  * File:        reclstl_traits.h
00003  *
00004  * Purpose:     Contains character-base traits for the recls::stl mapping.
00005  *
00006  * Created:     25th March 2004
00007  * Updated:     2nd June 2004
00008  *
00009  * Author:      Matthew Wilson, Synesis Software Pty Ltd.
00010  *
00011  * License:     (Licensed under the Synesis Software Standard Source License)
00012  *
00013  *              Copyright (C) 2002-2004, Synesis Software Pty Ltd.
00014  *
00015  *              All rights reserved.
00016  *
00017  *              www:        http://www.synesis.com.au/software
00018  *                          http://www.recls.org/
00019  *
00020  *              email:      submissions@recls.org  for submissions
00021  *                          admin@recls.org        for other enquiries
00022  *
00023  *              Redistribution and use in source and binary forms, with or
00024  *              without modification, are permitted provided that the following
00025  *              conditions are met:
00026  *
00027  *              (i) Redistributions of source code must retain the above
00028  *              copyright notice and contact information, this list of
00029  *              conditions and the following disclaimer.
00030  *
00031  *              (ii) Any derived versions of this software (howsoever modified)
00032  *              remain the sole property of Synesis Software.
00033  *
00034  *              (iii) Any derived versions of this software (howsoever modified)
00035  *              remain subject to all these conditions.
00036  *
00037  *              (iv) Neither the name of Synesis Software nor the names of any
00038  *              subdivisions, employees or agents of Synesis Software, nor the
00039  *              names of any other contributors to this software may be used to
00040  *              endorse or promote products derived from this software without
00041  *              specific prior written permission.
00042  *
00043  *              This source code is provided by Synesis Software "as is" and any
00044  *              warranties, whether expressed or implied, including, but not
00045  *              limited to, the implied warranties of merchantability and
00046  *              fitness for a particular purpose are disclaimed. In no event
00047  *              shall the Synesis Software be liable for any direct, indirect,
00048  *              incidental, special, exemplary, or consequential damages
00049  *              (including, but not limited to, procurement of substitute goods
00050  *              or services; loss of use, data, or profits; or business
00051  *              interruption) however caused and on any theory of liability,
00052  *              whether in contract, strict liability, or tort (including
00053  *              negligence or otherwise) arising in any way out of the use of
00054  *              this software, even if advised of the possibility of such
00055  *              damage.
00056  *
00057  * 
00058 
00059 
00060 #ifndef RECLS_INCL_H_RECLSTL_TRAITS
00061 #define RECLS_INCL_H_RECLSTL_TRAITS
00062 
00063 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00064 # define RECLS_VER_H_RECLSTL_TRAITS_MAJOR       1
00065 # define RECLS_VER_H_RECLSTL_TRAITS_MINOR       2
00066 # define RECLS_VER_H_RECLSTL_TRAITS_REVISION    1
00067 # define RECLS_VER_H_RECLSTL_TRAITS_EDIT        7
00068 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00069 
00076 /* 
00077  * Includes
00078  */
00079 
00080 #ifndef RECLS_INCL_H_RECLSTL
00081 # include "reclstl.h"
00082 #endif /* !RECLS_INCL_H_RECLSTL */
00083 #ifndef RECLS_INCL_H_RECLS_ASSERT
00084 # include <recls_assert.h>
00085 #endif /* !RECLS_INCL_H_RECLS_ASSERT */
00086 #ifndef _STLSOFT_INCL_H_STLSOFT_ITERATOR
00087 # include <stlsoft_iterator.h>
00088 #endif /* !_STLSOFT_INCL_H_STLSOFT_ITERATOR */
00089 #ifndef _STLSOFT_INCL_H_STLSOFT_PROXY_SEQUENCE
00090 # include <stlsoft_proxy_sequence.h>
00091 #endif /* !_STLSOFT_INCL_H_STLSOFT_PROXY_SEQUENCE */
00092 
00093 /* 
00094  * Namespace
00095  */
00096 
00097 #if !defined(RECLS_NO_NAMESPACE)
00098 namespace recls
00099 {
00100 
00101 namespace stl
00102 {
00103 #endif /* !RECLS_NO_NAMESPACE */
00104 
00105 /* 
00106  * Classes
00107  */
00108 
00112 template <typename C>
00113 struct reclstl_traits
00114 {
00115 public:
00120     typedef void            char_type;
00125     typedef void            *entry_type;
00126 
00127 public:
00128 #if defined(RECLS_API_FTP)
00129 
00130     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);
00131 #endif /* RECLS_API_FTP */
00132 
00134     static hrecls_t         Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags);
00135 
00137     static recls_rc_t       GetDetails(hrecls_t hSrch, entry_type *pinfo);
00139     static recls_rc_t       GetNextDetails(hrecls_t hSrch, entry_type *pinfo);
00140 
00142     static void             CloseDetails(entry_type fileInfo);
00144     static entry_type       CopyDetails(entry_type fileInfo);
00145 
00147     static char_type        *str_copy(char_type *, char_type const *);
00148 };
00149 
00150 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00151 
00152 # ifdef RECLS_CHAR_TYPE_IS_CHAR
00153 
00154 template <>
00155 struct reclstl_traits<recls_char_a_t>
00156 {
00157 public:
00158     typedef reclstl_traits<recls_char_a_t>      traits_type;
00159     typedef recls_char_a_t                      char_type;
00160     typedef recls_info_t                        entry_type;
00161     typedef recls_strptrs_t                     strptrs_type;
00162     typedef recls_strptrsptrs_t                 strptrsptrs_type;
00163 
00165     typedef stlsoft::proxy_sequence<    const strptrs_type
00166                                     ,   string_t
00167                                     ,   traits_type // Note, this type also serves as the traits type for the STLSoft proxy_sequence
00168                                     >           directory_parts_type;
00169 
00173     static string_t make_value(strptrs_type const &ptrs)
00174     {
00175         return string_t(ptrs.begin, ptrs.end);
00176     }
00177 
00178 public:
00179 #if defined(RECLS_API_FTP)
00180     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)
00181     {
00182         hrecls_t    hSrch;
00183         recls_rc_t  rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00184 
00185         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00186     }
00187 #endif /* RECLS_API_FTP */
00188 
00189     static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00190     {
00191         hrecls_t    hSrch;
00192         recls_rc_t  rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00193 
00194         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00195     }
00196 
00197     static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00198     {
00199         return Recls_GetDetails(hSrch, pinfo);
00200     }
00201 
00202     static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00203     {
00204         return Recls_GetNextDetails(hSrch, pinfo);
00205     }
00206 
00207     static void CloseDetails(entry_type fileInfo)
00208     {
00209         Recls_CloseDetails(fileInfo);
00210     }
00211     static entry_type CopyDetails(entry_type fileInfo)
00212     {
00213         entry_type  infoCopy;
00214 
00215         return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00216     }
00217 
00218     static char_type *str_copy(char_type *dest, char_type const *src)
00219     {
00220         return strcpy(dest, src);
00221     }
00222 };
00223 
00224 # elif defined(RECLS_CHAR_TYPE_IS_WCHAR)
00225 
00226 template <>
00227 struct reclstl_traits<recls_char_w_t>
00228 {
00229 public:
00230     typedef reclstl_traits<recls_char_w_t>      traits_type;
00231     typedef recls_char_w_t                      char_type;
00232     typedef recls_info_t                        entry_type;
00233     typedef recls_strptrs_t                     strptrs_type;
00234     typedef recls_strptrsptrs_t                 strptrsptrs_type;
00235 
00237     typedef stlsoft::proxy_sequence<    const strptrs_type
00238                                     ,   string_t
00239                                     ,   traits_type // Note, this type also serves as the traits type for the STLSoft proxy_sequence
00240                                     >           directory_parts_type;
00241 
00245     static string_t make_value(strptrs_type const &ptrs)
00246     {
00247         return string_t(ptrs.begin, ptrs.end);
00248     }
00249 
00250 public:
00251 #if defined(RECLS_API_FTP)
00252     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)
00253     {
00254         hrecls_t    hSrch;
00255         recls_rc_t  rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00256 
00257         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00258     }
00259 #endif /* RECLS_API_FTP */
00260 
00261     static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00262     {
00263         hrecls_t    hSrch;
00264         recls_rc_t  rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00265 
00266         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00267     }
00268 
00269     static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00270     {
00271         return Recls_GetDetails(hSrch, pinfo);
00272     }
00273 
00274     static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00275     {
00276         return Recls_GetNextDetails(hSrch, pinfo);
00277     }
00278 
00279     static void CloseDetails(entry_type fileInfo)
00280     {
00281         Recls_CloseDetails(fileInfo);
00282     }
00283     static entry_type CopyDetails(entry_type fileInfo)
00284     {
00285         entry_type  infoCopy;
00286 
00287         return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00288     }
00289 
00290     static char_type *str_copy(char_type *dest, char_type const *src)
00291     {
00292         return wcscpy(dest, src);
00293     }
00294 };
00295 
00296 # else /* character type */
00297 
00298 #  error Neither RECLS_CHAR_TYPE_IS_WCHAR nor RECLS_CHAR_TYPE_IS_CHAR are defined
00299 
00300 # endif /* character type */
00301 
00302 
00303 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00304 
00305 /* 
00306 
00307 #if !defined(RECLS_NO_NAMESPACE)
00308 } /* namespace stl */
00309 } /* namespace recls */
00310 #endif /* !RECLS_NO_NAMESPACE */
00311 
00312 /* 
00313 
00314 #endif /* RECLS_INCL_H_RECLSTL_TRAITS */
00315 
00316 /* 

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