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_search_sequence.h

Go to the documentation of this file.
00001 /* 
00002  * File:        reclstl_search_sequence.h
00003  *
00004  * Purpose:     Contains the basic_search_sequence template class, and ANSI
00005  *              and Unicode specialisations thereof.
00006  *
00007  * Created:     10th September 2003
00008  * Updated:     8th June 2004
00009  *
00010  * Author:      Matthew Wilson, Synesis Software Pty Ltd.
00011  *
00012  * License:     (Licensed under the Synesis Software Standard Source License)
00013  *
00014  *              Copyright (C) 2002-2004, Synesis Software Pty Ltd.
00015  *
00016  *              All rights reserved.
00017  *
00018  *              www:        http://www.synesis.com.au/software
00019  *                          http://www.recls.org/
00020  *
00021  *              email:      submissions@recls.org  for submissions
00022  *                          admin@recls.org        for other enquiries
00023  *
00024  *              Redistribution and use in source and binary forms, with or
00025  *              without modification, are permitted provided that the following
00026  *              conditions are met:
00027  *
00028  *              (i) Redistributions of source code must retain the above
00029  *              copyright notice and contact information, this list of
00030  *              conditions and the following disclaimer.
00031  *
00032  *              (ii) Any derived versions of this software (howsoever modified)
00033  *              remain the sole property of Synesis Software.
00034  *
00035  *              (iii) Any derived versions of this software (howsoever modified)
00036  *              remain subject to all these conditions.
00037  *
00038  *              (iv) Neither the name of Synesis Software nor the names of any
00039  *              subdivisions, employees or agents of Synesis Software, nor the
00040  *              names of any other contributors to this software may be used to
00041  *              endorse or promote products derived from this software without
00042  *              specific prior written permission.
00043  *
00044  *              This source code is provided by Synesis Software "as is" and any
00045  *              warranties, whether expressed or implied, including, but not
00046  *              limited to, the implied warranties of merchantability and
00047  *              fitness for a particular purpose are disclaimed. In no event
00048  *              shall the Synesis Software be liable for any direct, indirect,
00049  *              incidental, special, exemplary, or consequential damages
00050  *              (including, but not limited to, procurement of substitute goods
00051  *              or services; loss of use, data, or profits; or business
00052  *              interruption) however caused and on any theory of liability,
00053  *              whether in contract, strict liability, or tort (including
00054  *              negligence or otherwise) arising in any way out of the use of
00055  *              this software, even if advised of the possibility of such
00056  *              damage.
00057  *
00058  * 
00059 
00060 
00061 #ifndef RECLS_INCL_H_RECLSTL_SEARCH_SEQUENCE
00062 #define RECLS_INCL_H_RECLSTL_SEARCH_SEQUENCE
00063 
00064 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00065 # define RECLS_VER_H_RECLSTL_SEARCH_SEQUENCE_MAJOR      1
00066 # define RECLS_VER_H_RECLSTL_SEARCH_SEQUENCE_MINOR      8
00067 # define RECLS_VER_H_RECLSTL_SEARCH_SEQUENCE_REVISION   2
00068 # define RECLS_VER_H_RECLSTL_SEARCH_SEQUENCE_EDIT       30
00069 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00070 
00077 /* 
00078  * Includes
00079  */
00080 
00081 #ifndef RECLS_INCL_H_RECLSTL
00082 # include "reclstl.h"
00083 #endif /* !RECLS_INCL_H_RECLSTL */
00084 #ifndef RECLS_INCL_H_RECLSTL_TRAITS
00085 # include "reclstl_traits.h"
00086 #endif /* !RECLS_INCL_H_RECLSTL_TRAITS */
00087 #if defined(RECLS_PLATFORM_IS_WIN32)
00088 # include <winstl_file_path_buffer.h>
00089 #elif defined(RECLS_PLATFORM_IS_UNIX)
00090 # include <unixstl_file_path_buffer.h>
00091 #else
00092 # error Platform not (yet) recognised
00093 #endif /* platform */
00094 #if !defined(STLSOFT_INCL_H_STLSOFT_SIMPLE_STRING)
00095 # include "stlsoft_simple_string.h"
00096 #endif /* !STLSOFT_INCL_H_STLSOFT_SIMPLE_STRING */
00097 
00098 /* 
00099  * Namespace
00100  */
00101 
00102 #if !defined(RECLS_NO_NAMESPACE)
00103 namespace recls
00104 {
00105 
00106 namespace stl
00107 {
00108 #endif /* !RECLS_NO_NAMESPACE */
00109 
00110 #if defined(RECLS_PLATFORM_IS_WIN32)
00111 typedef winstl::basic_file_path_buffer<recls_char_t>    file_path_buffer;
00112 #elif defined(RECLS_PLATFORM_IS_UNIX)
00113 typedef unixstl::basic_file_path_buffer<recls_char_t>   file_path_buffer;
00114 #else
00115 # error Platform not (yet) recognised
00116 #endif /* platform */
00117 
00118 /* 
00119  * Forward declarations
00120  */
00121 
00122 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00123 
00124 template<   typename C
00125         ,   typename T
00126         >
00127 class basic_search_sequence_value_type;
00128 
00129 template<   typename C
00130         ,   typename T
00131         ,   typename V
00132         >
00133 class basic_search_sequence_const_iterator;
00134 
00135 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00136 
00137 /* 
00138  * Utility classes
00139  */
00140 
00141 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00142 struct rss_shared_handle
00143 {
00144     hrecls_t        hSrch;
00145     recls_sint32_t  cRefs;
00146 
00147 public:
00148     explicit rss_shared_handle(hrecls_t h)
00149         : hSrch(h)
00150         , cRefs(1)
00151     {}
00152     void Release()
00153     {
00154         if(--cRefs == 0)
00155         {
00156             delete this;
00157         }
00158     }
00159 #if defined(__STLSOFT_COMPILER_IS_GCC)
00160 protected:
00161 #else /* ? __STLSOFT_COMPILER_IS_GCC */
00162 private:
00163 #endif /* __STLSOFT_COMPILER_IS_GCC */
00164     ~rss_shared_handle()
00165     {
00166         recls_message_assert("Shared search handle being destroyed with outstanding references!", 0 == cRefs);
00167 
00168         if(NULL != hSrch)
00169         {
00170             Recls_SearchClose(hSrch);
00171         }
00172     }
00173 };
00174 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00175 
00176 /* 
00177  * Classes
00178  */
00179 
00180 // class basic_search_sequence
00187 template<   typename C
00188 #ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00189         ,   typename T = reclstl_traits<C>
00190 #else
00191         ,   typename T /* = reclstl_traits<C> */
00192 #endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
00193         >
00194 class basic_search_sequence
00195 {
00198 public:
00200     typedef C                                                       char_type;
00202     typedef T                                                       traits_type;
00204     typedef basic_search_sequence<C, T>                             class_type;
00206     typedef basic_search_sequence_value_type<C, T>                  value_type;
00208     typedef basic_search_sequence_const_iterator<C, T, value_type>  const_iterator;
00210     typedef value_type                                              &reference;
00212     typedef value_type const                                        &const_reference;
00214     typedef ss_typename_type_k traits_type::entry_type              entry_type;
00216     typedef size_t                                                  size_type;
00218     typedef stlsoft::basic_simple_string<C>                                                     string_type;
00220 
00223 public:
00225     basic_search_sequence(char_type const *pattern, recls_uint32_t flags);
00227     basic_search_sequence(char_type const *directory, char_type const *pattern, recls_uint32_t flags);
00228 #if defined(RECLS_API_FTP)
00229 
00230     basic_search_sequence(char_type const *host, char_type const *username, char_type const *password, char_type const *directory, char_type const *pattern, recls_uint32_t flags);
00231 #endif /* RECLS_API_FTP */
00232 
00233     ~basic_search_sequence()
00234         {
00235         stlsoft_static_assert(stlsoft_raw_offsetof(class_type, m_directory_) < stlsoft_raw_offsetof(class_type, m_directory));
00236         stlsoft_static_assert(stlsoft_raw_offsetof(class_type, m_pattern_) < stlsoft_raw_offsetof(class_type, m_pattern));
00237         }
00239 
00242 public:
00246     const_iterator  begin() const;
00250     const_iterator  end() const;
00252 
00255 public:
00257     size_type           size() const;
00259     recls_bool_t        empty() const;
00261     static size_type    max_size();
00263 
00266 private:
00267     friend class basic_search_sequence_value_type<C, T>;
00268     friend class basic_search_sequence_const_iterator<C, T, value_type>;
00269 
00270     // This one is implemented in-class as it allows sequence to be used by VC++ 5
00271     static char_type const  *copy_or_null_(file_path_buffer &dest, char_type const *src)
00272     {
00273         return (NULL == src) ? static_cast<char_type const*>(NULL) : traits_type::str_copy(&dest[0], src);
00274     }
00275 
00276 #if defined(RECLS_API_FTP)
00277     string_type                         m_host;
00278     string_type                         m_username;
00279     string_type                         m_password;
00280 #endif /* RECLS_API_FTP */
00281         // TODO: Lose the file_path_buffer, and use auto_buffer directly
00282     file_path_buffer        m_directory_;
00283     file_path_buffer        m_pattern_;
00284     char_type const *const  m_directory;
00285     char_type const *const  m_pattern;
00286     recls_uint32_t          m_flags;
00288 
00289 // Not to be implemented
00290 private:
00291     basic_search_sequence(class_type const &);
00292     basic_search_sequence const &operator =(class_type const &);
00293 };
00294 
00295 /* 
00296  * Typedefs for commonly encountered types
00297  */
00298 
00300 typedef basic_search_sequence<recls_char_a_t, reclstl_traits<recls_char_a_t> >      search_sequence_a;
00302 typedef basic_search_sequence<recls_char_w_t, reclstl_traits<recls_char_w_t> >      search_sequence_w;
00303 
00304 /* 
00305 
00306 // class basic_search_sequence_value_type
00310 template<   typename C
00311         ,   typename T
00312         >
00313 class basic_search_sequence_value_type
00314 {
00317 public:
00319     typedef C                                                       char_type;
00321     typedef T                                                       traits_type;
00323     typedef basic_search_sequence_value_type<C, T>                  class_type;
00325     typedef ss_typename_type_k traits_type::entry_type              entry_type;
00327     typedef ss_typename_type_k traits_type::directory_parts_type    directory_parts_type;
00329 
00332 public:
00334     basic_search_sequence_value_type();
00335     basic_search_sequence_value_type(class_type const &rhs);
00336 private:
00337     basic_search_sequence_value_type(entry_type info)
00338         : m_info(info)
00339     {}
00340 public:
00342     ~basic_search_sequence_value_type();
00343 
00345     class_type &operator =(class_type const &rhs);
00347 
00350 public:
00352     string_t                get_path() const;
00353 #ifdef RECLS_PLATFORM_API_WIN32
00354     char_type               get_drive() const;
00355 #endif /* RECLS_PLATFORM_API_WIN32 */
00357     string_t                get_directory() const;
00359     string_t                get_directory_path() const;
00361     directory_parts_type    get_directory_parts() const;
00363     string_t                get_file() const;
00365     string_t                get_short_file() const;
00367     string_t                get_filename() const;
00369     string_t                get_fileext() const;
00370 
00371     recls_time_t            get_creation_time() const;
00372     recls_time_t            get_modification_time() const;
00373     recls_time_t            get_last_access_time() const;
00374     recls_time_t            get_last_status_change_time() const;
00375 
00376     recls_filesize_t        get_size() const;
00377 
00378     recls_bool_t            is_readonly() const;
00379     recls_bool_t            is_directory() const;
00380     recls_bool_t            is_link() const;
00381 
00383     char_type const         *c_str() const;
00384 
00386     entry_type const        &get_entry() const;
00388 
00389 // Members
00390 private:
00391     friend class basic_search_sequence_const_iterator<C, T, class_type>;
00392 
00393     entry_type  m_info;
00394 };
00395 
00396 // class basic_search_sequence_const_iterator
00400 template<   typename C
00401         ,   typename T
00402         ,   typename V
00403         >
00404 class basic_search_sequence_const_iterator
00405     : public stlsoft_ns_qual(iterator_base)<stlsoft_ns_qual_std(input_iterator_tag), V, ptrdiff_t, void, V>
00406 {
00407 public:
00409     typedef C                                               char_type;
00411     typedef T                                               traits_type;
00413     typedef V                                               value_type;
00415     typedef basic_search_sequence_const_iterator<C, T, V>   class_type;
00417     typedef ss_typename_type_k traits_type::entry_type      entry_type;
00418 private:
00419     typedef basic_search_sequence<C, T>                     sequence_type;
00420 
00421 private:
00422     explicit basic_search_sequence_const_iterator(hrecls_t hSrch)
00423         : m_handle(make_handle_(hSrch))
00424     {}
00425 public:
00427     basic_search_sequence_const_iterator();
00429     basic_search_sequence_const_iterator(class_type const &rhs);
00431     ~basic_search_sequence_const_iterator();
00432 
00433     // Copy assignment operator
00434     basic_search_sequence_const_iterator &operator =(class_type const &rhs);
00435 
00436 public:
00438     class_type &operator ++();
00440     void operator ++(int);
00442     const value_type operator *() const;
00444     recls_bool_t operator ==(class_type const &rhs) const;
00446     recls_bool_t operator !=(class_type const &rhs) const;
00447 
00448 // Implementation
00449 private:
00450     rss_shared_handle   *make_handle_(hrecls_t hSrch);
00451 
00452 // Members
00453 private:
00454     friend class basic_search_sequence<C, T>;
00455 
00456     rss_shared_handle   *m_handle;
00457 };
00458 
00460 // Shims
00461 
00472 template <typename C, typename T>
00473 inline recls_bool_t is_empty(basic_search_sequence<C, T> const &s)
00474 {
00475     return s.empty();
00476 }
00477 
00488 template <typename C, typename T>
00489 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00490 inline ss_typename_type_k basic_search_sequence_value_type<C, T>::char_type const *c_str_ptr(basic_search_sequence_value_type<C, T> const &v)
00491 #else
00492 inline C const *c_str_ptr(basic_search_sequence_value_type<C, T> const &v)
00493 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00494 {
00495     return v.c_str();
00496 }
00497 
00499 // Implementation
00500 
00501 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00502 
00503 // basic_search_sequence
00504 
00505 
00506 // Construction
00507 template <typename C, typename T>
00508 inline basic_search_sequence<C, T>::basic_search_sequence(char_type const *pattern, recls_uint32_t flags)
00509     : m_flags(flags)
00510     , m_directory(copy_or_null_(m_directory_, ""))
00511     , m_pattern(copy_or_null_(m_pattern_, pattern))
00512 {}
00513 
00514 template <typename C, typename T>
00515 inline basic_search_sequence<C, T>::basic_search_sequence(char_type const *directory, char_type const *pattern, recls_uint32_t flags)
00516     : m_flags(flags)
00517     , m_directory(copy_or_null_(m_directory_, directory))
00518     , m_pattern(copy_or_null_(m_pattern_, pattern))
00519 {}
00520 
00521 #if defined(RECLS_API_FTP)
00522 template <typename C, typename T>
00523 inline basic_search_sequence<C, T>::basic_search_sequence(char_type const *host, char_type const *username, char_type const *password, char_type const *directory, char_type const *pattern, recls_uint32_t flags)
00524     : m_host(host)
00525         , m_username(username)
00526         , m_password(password)
00527         , m_flags(flags)
00528     , m_directory(copy_or_null_(m_directory_, directory))
00529     , m_pattern(copy_or_null_(m_pattern_, pattern))
00530 {
00531         recls_message_assert("Must specify a hostname if using FTP", (NULL == username && NULL == password) || NULL != host);
00532 }
00533 #endif /* RECLS_API_FTP */
00534 
00535 // Iteration
00536 template <typename C, typename T>
00537 inline ss_typename_type_k basic_search_sequence<C, T>::const_iterator basic_search_sequence<C, T>::begin() const
00538 {
00539 #if defined(RECLS_API_FTP)
00540         if(m_host.empty())
00541         {
00542 #endif /* RECLS_API_FTP */
00543                 return const_iterator(traits_type::Search(m_directory, m_pattern, m_flags));
00544 #if defined(RECLS_API_FTP)
00545         }
00546         else
00547         {
00548                 return const_iterator(traits_type::SearchFtp(m_host.c_str(), m_username.c_str(), m_password.c_str(), m_directory, m_pattern, m_flags));
00549         }
00550 #endif /* RECLS_API_FTP */
00551 }
00552 
00553 template <typename C, typename T>
00554 inline ss_typename_type_k basic_search_sequence<C, T>::const_iterator basic_search_sequence<C, T>::end() const
00555 {
00556     return const_iterator();
00557 }
00558 
00559 // State
00560 template <typename C, typename T>
00561 inline ss_typename_type_k basic_search_sequence<C, T>::size_type basic_search_sequence<C, T>::size() const
00562 {
00563     const_iterator  b   =   begin();
00564     const_iterator  e   =   end();
00565     size_type       c   =   0;
00566 
00567     for(; b != e; ++b)
00568     {
00569         ++c;
00570     }
00571 
00572     return c;
00573 }
00574 
00575 template <typename C, typename T>
00576 inline recls_bool_t basic_search_sequence<C, T>::empty() const
00577 {
00578     return begin() == end();
00579 }
00580 
00581 template <typename C, typename T>
00582 inline /* static */ ss_typename_type_k basic_search_sequence<C, T>::size_type basic_search_sequence<C, T>::max_size()
00583 {
00584     return static_cast<size_type>(-1);
00585 }
00586 
00587 // basic_search_sequence_value_type
00588 
00589 template <typename C, typename T>
00590 inline basic_search_sequence_value_type<C, T>::basic_search_sequence_value_type()
00591     : m_info(NULL)
00592 {}
00593 
00594 template <typename C, typename T>
00595 inline basic_search_sequence_value_type<C, T>::basic_search_sequence_value_type(ss_typename_type_k basic_search_sequence_value_type<C, T>::class_type const &rhs)
00596     : m_info(traits_type::CopyDetails(rhs.m_info))
00597 {}
00598 
00599 template <typename C, typename T>
00600 inline basic_search_sequence_value_type<C, T>::~basic_search_sequence_value_type()
00601 {
00602     if(NULL != m_info)
00603     {
00604         traits_type::CloseDetails(m_info);
00605     }
00606 }
00607 
00608 template <typename C, typename T>
00609 inline ss_typename_type_k basic_search_sequence_value_type<C, T>::class_type &basic_search_sequence_value_type<C, T>::operator =(ss_typename_type_k basic_search_sequence_value_type<C, T>::class_type const &rhs)
00610 {
00611     if(NULL != m_info)
00612     {
00613         traits_type::CloseDetails(m_info);
00614     }
00615 
00616     m_info = traits_type::CopyDetails(rhs.m_info);
00617 
00618     return *this;
00619 }
00620 
00621 template <typename C, typename T>
00622 inline string_t basic_search_sequence_value_type<C, T>::get_path() const
00623 {
00624     recls_assert(NULL != m_info);
00625 
00626     return string_t(m_info->path.begin, m_info->path.end);
00627 }
00628 
00629 #ifdef RECLS_PLATFORM_API_WIN32
00630 template <typename C, typename T>
00631 inline ss_typename_type_k basic_search_sequence_value_type<C, T>::char_type basic_search_sequence_value_type<C, T>::get_drive() const
00632 {
00633     char_type   chDrive;
00634 
00635     return (Recls_GetDriveProperty(m_info, &chDrive), chDrive);
00636 }
00637 #endif /* RECLS_PLATFORM_API_WIN32 */
00638 
00639 template <typename C, typename T>
00640 inline string_t basic_search_sequence_value_type<C, T>::get_directory() const
00641 {
00642     recls_assert(NULL != m_info);
00643 
00644     return string_t(m_info->directory.begin, m_info->directory.end);
00645 }
00646 
00647 template <typename C, typename T>
00648 inline string_t basic_search_sequence_value_type<C, T>::get_directory_path() const
00649 {
00650     recls_assert(NULL != m_info);
00651 
00652     return string_t(m_info->path.begin, m_info->directory.end);
00653 }
00654 
00655 template <typename C, typename T>
00656 inline ss_typename_type_k basic_search_sequence_value_type<C, T>::directory_parts_type basic_search_sequence_value_type<C, T>::get_directory_parts() const
00657 {
00658     recls_assert(NULL != m_info);
00659 
00660     return directory_parts_type(m_info->directoryParts.begin, m_info->directoryParts.end);
00661 }
00662 
00663 template <typename C, typename T>
00664 inline string_t basic_search_sequence_value_type<C, T>::get_file() const
00665 {
00666     recls_assert(NULL != m_info);
00667 
00668     return string_t(m_info->fileName.begin, m_info->fileExt.end);
00669 }
00670 
00671 #if 0
00672 template <typename C, typename T>
00673 inline string_t basic_search_sequence_value_type<C, T>::get_short_file() const
00674 {
00675     return m_info.cAlternateFileName[0] != '\0' ? m_info.cAlternateFileName : m_info.cFileName;
00676 }
00677 #endif /* 0 */
00678 
00679 template <typename C, typename T>
00680 inline string_t basic_search_sequence_value_type<C, T>::get_filename() const
00681 {
00682     recls_assert(NULL != m_info);
00683 
00684     return string_t(m_info->fileName.begin, m_info->fileName.end);
00685 }
00686 
00687 template <typename C, typename T>
00688 inline string_t basic_search_sequence_value_type<C, T>::get_fileext() const
00689 {
00690     recls_assert(NULL != m_info);
00691 
00692     return string_t(m_info->fileExt.begin, m_info->fileExt.end);
00693 }
00694 
00695 template <typename C, typename T>
00696 inline recls_time_t basic_search_sequence_value_type<C, T>::get_creation_time() const
00697 {
00698     recls_assert(NULL != m_info);
00699 
00700     return Recls_GetCreationTime(m_info);
00701 }
00702 
00703 template <typename C, typename T>
00704 inline recls_time_t basic_search_sequence_value_type<C, T>::get_modification_time() const
00705 {
00706     recls_assert(NULL != m_info);
00707 
00708     return Recls_GetModificationTime(m_info);
00709 }
00710 
00711 template <typename C, typename T>
00712 inline recls_time_t basic_search_sequence_value_type<C, T>::get_last_access_time() const
00713 {
00714     recls_assert(NULL != m_info);
00715 
00716     return Recls_GetLastAccessTime(m_info);
00717 }
00718 
00719 template <typename C, typename T>
00720 inline recls_time_t basic_search_sequence_value_type<C, T>::get_last_status_change_time() const
00721 {
00722     recls_assert(NULL != m_info);
00723 
00724     return Recls_GetLastStatusChangeTime(m_info);
00725 }
00726 
00727 template <typename C, typename T>
00728 inline recls_filesize_t basic_search_sequence_value_type<C, T>::get_size() const
00729 {
00730     recls_assert(NULL != m_info);
00731 
00732     return m_info->size;
00733 }
00734 
00735 template <typename C, typename T>
00736 inline recls_bool_t basic_search_sequence_value_type<C, T>::is_readonly() const
00737 {
00738     recls_assert(NULL != m_info);
00739 
00740     return Recls_IsFileReadOnly(m_info);
00741 }
00742 
00743 template <typename C, typename T>
00744 inline recls_bool_t basic_search_sequence_value_type<C, T>::is_directory() const
00745 {
00746     recls_assert(NULL != m_info);
00747 
00748     return Recls_IsFileDirectory(m_info);
00749 }
00750 
00751 template <typename C, typename T>
00752 inline recls_bool_t basic_search_sequence_value_type<C, T>::is_link() const
00753 {
00754     recls_assert(NULL != m_info);
00755 
00756     return Recls_IsFileLink(m_info);
00757 }
00758 
00759 template <typename C, typename T>
00760 inline ss_typename_type_k basic_search_sequence_value_type<C, T>::char_type const * basic_search_sequence_value_type<C, T>::c_str() const
00761 {
00762     recls_assert(NULL != m_info);
00763 
00764     return m_info->path.begin;
00765 }
00766 
00767 template <typename C, typename T>
00768 inline ss_typename_type_k basic_search_sequence_value_type<C, T>::entry_type const &basic_search_sequence_value_type<C, T>::get_entry() const
00769 {
00770     return m_info;
00771 }
00772 
00773 // basic_search_sequence_const_iterator
00774 
00775 template <typename C, typename T, typename V>
00776 inline rss_shared_handle *basic_search_sequence_const_iterator<C, T, V>::make_handle_(hrecls_t hSrch)
00777 {
00778     return (NULL != hSrch) ? new rss_shared_handle(hSrch) : static_cast<rss_shared_handle*>(NULL);
00779 }
00780 
00781 template <typename C, typename T, typename V>
00782 inline basic_search_sequence_const_iterator<C, T, V>::basic_search_sequence_const_iterator()
00783     : m_handle(NULL)
00784 {}
00785 
00786 template <typename C, typename T, typename V>
00787 inline basic_search_sequence_const_iterator<C, T, V>::basic_search_sequence_const_iterator(class_type const &rhs)
00788     : m_handle(rhs.m_handle)
00789 {
00790     if(NULL != m_handle)
00791     {
00792         ++m_handle->cRefs;
00793     }
00794 }
00795 
00796 template <typename C, typename T, typename V>
00797 inline ss_typename_type_k basic_search_sequence_const_iterator<C, T, V>::class_type &basic_search_sequence_const_iterator<C, T, V>::operator =(typename basic_search_sequence_const_iterator<C, T, V>::class_type const &rhs)
00798 {
00799     if(NULL != m_handle)
00800     {
00801         m_handle->Release();
00802     }
00803 
00804     m_handle =   rhs.m_handle;
00805 
00806     if(NULL != m_handle)
00807     {
00808         ++m_handle->cRefs;
00809     }
00810 
00811     return *this;
00812 }
00813 
00814 template <typename C, typename T, typename V>
00815 inline basic_search_sequence_const_iterator<C, T, V>::~basic_search_sequence_const_iterator()
00816 {
00817     if(NULL != m_handle)
00818     {
00819         m_handle->Release();
00820     }
00821 }
00822 
00823 template <typename C, typename T, typename V>
00824 inline ss_typename_type_k basic_search_sequence_const_iterator<C, T, V>::class_type &basic_search_sequence_const_iterator<C, T, V>::operator ++()
00825 {
00826     recls_message_assert("Attempting to increment invalid iterator", NULL != m_handle);
00827 
00828     if(RECLS_FAILED(Recls_GetNext(m_handle->hSrch)))
00829     {
00830         m_handle->Release();
00831 
00832         m_handle = NULL;
00833     }
00834 
00835     return *this;
00836 }
00837 
00838 template <typename C, typename T, typename V>
00839 inline void basic_search_sequence_const_iterator<C, T, V>::operator ++(int)
00840 {
00841     operator ++();
00842 }
00843 
00844 template <typename C, typename T, typename V>
00845 inline const ss_typename_type_k basic_search_sequence_const_iterator<C, T, V>::value_type basic_search_sequence_const_iterator<C, T, V>::operator *() const
00846 {
00847     entry_type  info;
00848 
00849     recls_message_assert("Attempting to dereference invalid iterator", NULL != m_handle);
00850 
00851     if( m_handle->hSrch != NULL &&
00852         RECLS_SUCCEEDED(traits_type::GetDetails(m_handle->hSrch, &info)))
00853     {
00854         return value_type(info);
00855     }
00856     else
00857     {
00858         recls_message_assert("Dereferencing end()-valued iterator", 0);
00859 
00860         return value_type();
00861     }
00862 }
00863 
00864 template <typename C, typename T, typename V>
00865 inline recls_bool_t basic_search_sequence_const_iterator<C, T, V>::operator ==(class_type const &rhs) const
00866 {
00867     return (m_handle == NULL) && (rhs.m_handle == NULL);
00868 }
00869 
00870 template <typename C, typename T, typename V>
00871 inline recls_bool_t basic_search_sequence_const_iterator<C, T, V>::operator !=(class_type const &rhs) const
00872 {
00873     return ! operator ==(rhs);
00874 }
00875 
00876 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00877 
00878 /* 
00879 
00880 #if !defined(RECLS_NO_NAMESPACE)
00881 } /* namespace stl */
00882 } /* namespace recls */
00883 
00884 // Now we introduce the two shims into the STLSoft namespace - stlsoft.
00885 namespace stlsoft
00886 {
00887     using recls::stl::is_empty;
00888     using recls::stl::c_str_ptr;
00889 
00890 } // namespace stlsoft
00891 #endif /* !RECLS_NO_NAMESPACE */
00892 
00893 /* 
00894 
00895 #endif /* RECLS_INCL_H_RECLSTL_SEARCH_SEQUENCE */
00896 
00897 /* 

recls Library documentation Synesis Software Pty Ltd, 2001-2004