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 UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Alphabetical List   Compound List   File List   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:     24th April 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       0
00066 # define RECLS_VER_H_RECLSTL_TRAITS_REVISION    3
00067 # define RECLS_VER_H_RECLSTL_TRAITS_EDIT        4
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:
00129     static hrecls_t         Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags);
00130 
00132     static recls_rc_t       GetDetails(hrecls_t hSrch, entry_type *pinfo);
00134     static recls_rc_t       GetNextDetails(hrecls_t hSrch, entry_type *pinfo);
00135 
00137     static void             CloseDetails(entry_type fileInfo);
00139     static entry_type       CopyDetails(entry_type fileInfo);
00140 
00142     static char_type        *str_copy(char_type *, char_type const *);
00143 };
00144 
00145 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00146 template <>
00147 struct reclstl_traits<recls_char_a_t>
00148 {
00149 public:
00150     typedef reclstl_traits<recls_char_a_t>      traits_type;
00151     typedef recls_char_a_t                      char_type;
00152     typedef recls_info_t                        entry_type;
00153     typedef recls_strptrs_t                     strptrs_type;
00154     typedef recls_strptrsptrs_t                 strptrsptrs_type;
00155 
00157     typedef stlsoft::proxy_sequence<    const strptrs_type
00158                                     ,   string_t
00159                                     ,   traits_type // Note, this type also serves as the traits type for the STLSoft proxy_sequence
00160                                     >           directory_parts_type;
00161 
00165     static string_t make_value(strptrs_type const &ptrs)
00166     {
00167         return string_t(ptrs.begin, ptrs.end);
00168     }
00169 
00170 public:
00171     static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00172     {
00173         hrecls_t    hSrch;
00174         recls_rc_t  rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00175 
00176         return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00177     }
00178 
00179     static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00180     {
00181         return Recls_GetDetails(hSrch, pinfo);
00182     }
00183 
00184     static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00185     {
00186         return Recls_GetNextDetails(hSrch, pinfo);
00187     }
00188 
00189     static void CloseDetails(entry_type fileInfo)
00190     {
00191         Recls_CloseDetails(fileInfo);
00192     }
00193     static entry_type CopyDetails(entry_type fileInfo)
00194     {
00195         entry_type  infoCopy;
00196 
00197         return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00198     }
00199 
00200     static char_type *str_copy(char_type *dest, char_type const *src)
00201     {
00202         return strcpy(dest, src);
00203     }
00204 };
00205 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00206 
00207 /* 
00208 
00209 #if !defined(RECLS_NO_NAMESPACE)
00210 } /* namespace stl */
00211 } /* namespace recls */
00212 #endif /* !RECLS_NO_NAMESPACE */
00213 
00214 /* 
00215 
00216 #endif /* RECLS_INCL_H_RECLSTL_TRAITS */
00217 
00218 /* 

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