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/search_sequence.hpp

Go to the documentation of this file.
00001 /* 
00002  * File:        recls/stl/search_sequence.hpp
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:     19th May 2005
00009  *
00010  * Home:        http://recls.org/
00011  *
00012  * Copyright 2003-2005, Matthew Wilson and Synesis Software
00013  * All rights reserved.
00014  *
00015  * Redistribution and use in source and binary forms, with or without 
00016  * modification, are permitted provided that the following conditions are met:
00017  *
00018  * - Redistributions of source code must retain the above copyright notice, this
00019  *   list of conditions and the following disclaimer. 
00020  * - Redistributions in binary form must reproduce the above copyright notice,
00021  *   this list of conditions and the following disclaimer in the documentation
00022  *   and/or other materials provided with the distribution.
00023  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00024  *   any contributors may be used to endorse or promote products derived from
00025  *   this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038  *
00039  * 
00040 
00041 
00042 #ifndef RECLS_INCL_RECLSTL_STL_HPP_SEARCH_SEQUENCE
00043 #define RECLS_INCL_RECLSTL_STL_HPP_SEARCH_SEQUENCE
00044 
00045 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00046 # define RECLS_VER_RECLSTL_STL_HPP_SEARCH_SEQUENCE_MAJOR    3
00047 # define RECLS_VER_RECLSTL_STL_HPP_SEARCH_SEQUENCE_MINOR    1
00048 # define RECLS_VER_RECLSTL_STL_HPP_SEARCH_SEQUENCE_REVISION 3
00049 # define RECLS_VER_RECLSTL_STL_HPP_SEARCH_SEQUENCE_EDIT     38
00050 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00051 
00058 /* 
00059  * Includes
00060  */
00061 
00062 #ifndef RECLS_INCL_RECLS_STL_HPP_RECLS
00063 # include <recls/stl/recls.hpp>
00064 #endif /* !RECLS_INCL_RECLS_STL_HPP_RECLS */
00065 #ifndef RECLS_INCL_RECLS_STL_HPP_TRAITS
00066 # include <recls/stl/traits.hpp>
00067 #endif /* !RECLS_INCL_RECLS_STL_HPP_TRAITS */
00068 #if defined(RECLS_PLATFORM_IS_UNIX)
00069 # include <unixstl/file_path_buffer.hpp>
00070 #elif defined(RECLS_PLATFORM_IS_WIN32)
00071 # include <winstl/file_path_buffer.hpp>
00072 #else
00073 # error Platform not (yet) recognised
00074 #endif /* platform */
00075 #include <stlsoft/simple_string.hpp>
00076 
00077 /* 
00078  * Namespace
00079  */
00080 
00081 #if !defined(RECLS_NO_NAMESPACE)
00082 namespace recls
00083 {
00084 
00085 namespace stl
00086 {
00087 #endif /* !RECLS_NO_NAMESPACE */
00088 
00089 #if defined(RECLS_PLATFORM_IS_WIN32)
00090 typedef winstl::basic_file_path_buffer<recls_char_t>    file_path_buffer;
00091 #elif defined(RECLS_PLATFORM_IS_UNIX)
00092 typedef unixstl::basic_file_path_buffer<recls_char_t>   file_path_buffer;
00093 #else
00094 # error Platform not (yet) recognised
00095 #endif /* platform */
00096 
00097 /* 
00098  * Forward declarations
00099  */
00100 
00101 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00102 
00103 template<   typename C
00104         ,   typename T
00105         >
00106 class basic_search_sequence_value_type;
00107 
00108 template<   typename C
00109         ,   typename T
00110         ,   typename V
00111         >
00112 class basic_search_sequence_const_iterator;
00113 
00114 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00115 
00116 /* 
00117  * Utility classes
00118  */
00119 
00120 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00121 struct rss_shared_handle
00122 {
00123     hrecls_t        hSrch;
00124     recls_sint32_t  cRefs;
00125 
00126 public:
00127     explicit rss_shared_handle(hrecls_t h)
00128         : hSrch(h)
00129         , cRefs(1)
00130     {}
00131     void Release()
00132     {
00133         if(--cRefs == 0)
00134         {
00135             delete this;
00136         }
00137     }
00138 #if defined(__STLSOFT_COMPILER_IS_GCC)
00139 protected:
00140 #else /* ? __STLSOFT_COMPILER_IS_GCC */
00141 private:
00142 #endif /* __STLSOFT_COMPILER_IS_GCC */
00143     ~rss_shared_handle()
00144     {
00145         recls_message_assert("Shared search handle being destroyed with outstanding references!", 0 == cRefs);
00146 
00147         if(NULL != hSrch)
00148         {
00149             Recls_SearchClose(hSrch);
00150         }
00151     }
00152 };
00153 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00154 
00155 /* 
00156  * Classes
00157  */
00158 
00159 // class basic_search_sequence
00166 template<   typename C
00167 #ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00168         ,   typename T = reclstl_traits<C>
00169 #else
00170         ,   typename T /* = reclstl_traits<C> */
00171 #endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
00172         >
00173 class basic_search_sequence
00174 {
00177 public:
00179     typedef C                                                       char_type;
00181     typedef T                                                       traits_type;
00183     typedef basic_search_sequence<C, T>                             class_type;
00185     typedef basic_search_sequence_value_type<C, T>                  value_type;
00187     typedef basic_search_sequence_const_iterator<C, T, value_type>  const_iterator;
00189     typedef value_type                                              &reference;
00191     typedef value_type const                                        &const_reference;
00193     typedef ss_typename_type_k traits_type::entry_type              entry_type;
00195     typedef size_t                                                  size_type;
00197     typedef ptrdiff_t                                               difference_type;
00199     typedef stlsoft::basic_simple_string<C>                         string_type;
00201 
00204 public:
00206     basic_search_sequence(char_type const *pattern, recls_uint32_t flags);
00207 #if defined(__STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT)
00208 
00209     template <typename S>
00210     basic_search_sequence(S const &pattern, recls_uint32_t flags)
00211         : m_directory(copy_or_null_(m_directory_, stlsoft_ns_qual(c_str_ptr)("")))
00212         , m_pattern(copy_or_null_(m_pattern_, stlsoft_ns_qual(c_str_ptr)(pattern)))
00213         , m_flags(flags)
00214     {}
00215 #endif /* __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
00216 
00217     basic_search_sequence(char_type const *directory, char_type const *pattern, recls_uint32_t flags);
00218 #if defined(__STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT)
00219 
00220     template <typename S1, typename S2>
00221     basic_search_sequence(S1 const &directory, S2 const &pattern, recls_uint32_t flags)
00222         : m_directory(copy_or_null_(m_directory_, stlsoft_ns_qual(c_str_ptr)(directory)))
00223         , m_pattern(copy_or_null_(m_pattern_, stlsoft_ns_qual(c_str_ptr)(pattern)))
00224         , m_flags(flags)
00225     {}
00226 #endif /* __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
00227 #if defined(RECLS_API_FTP)
00228 
00229     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);
00230 #endif /* RECLS_API_FTP */
00231 
00232     ~basic_search_sequence()
00233     {
00234         stlsoft_static_assert(stlsoft_raw_offsetof(class_type, m_directory_) < stlsoft_raw_offsetof(class_type, m_directory));
00235         stlsoft_static_assert(stlsoft_raw_offsetof(class_type, m_pattern_) < stlsoft_raw_offsetof(class_type, m_pattern));
00236     }
00238 
00241 public:
00245     const_iterator  begin() const;
00249     const_iterator  end() const;
00251 
00254 public:
00256     size_type           size() const;
00258     recls_bool_t        empty() const;
00260     static size_type    max_size();
00262 
00265 private:
00266     friend class basic_search_sequence_value_type<C, T>;
00267     friend class basic_search_sequence_const_iterator<C, T, value_type>;
00268 
00269     // This one is implemented in-class as it allows sequence to be used by VC++ 5
00270     static char_type const  *copy_or_null_(file_path_buffer &dest, char_type const *src)
00271     {
00272         return (NULL == src) ? static_cast<char_type const*>(NULL) : traits_type::str_copy(&dest[0], src);
00273     }
00274 
00275 #if defined(RECLS_API_FTP)
00276     string_type             m_host;
00277     string_type             m_username;
00278     string_type             m_password;
00279 #endif /* RECLS_API_FTP */
00280     // TODO: Lose the file_path_buffer, and use auto_buffer directly
00281     file_path_buffer        m_directory_;
00282     file_path_buffer        m_pattern_;
00283     char_type const *const  m_directory;
00284     char_type const *const  m_pattern;
00285     recls_uint32_t          m_flags;
00287 
00288 // Not to be implemented
00289 private:
00290     basic_search_sequence(class_type const &);
00291     basic_search_sequence const &operator =(class_type const &);
00292 };
00293 
00294 /* 
00295  * Typedefs for commonly encountered types
00296  */
00297 
00299 typedef basic_search_sequence<recls_char_a_t, reclstl_traits<recls_char_a_t> >      search_sequence_a;
00301 typedef basic_search_sequence<recls_char_w_t, reclstl_traits<recls_char_w_t> >      search_sequence_w;
00302 
00303 /* 
00304 
00305 // class basic_search_sequence_value_type
00309 template<   typename C
00310         ,   typename T
00311         >
00312 class basic_search_sequence_value_type
00313 {
00316 public:
00318     typedef C                                                       char_type;
00320     typedef T                                                       traits_type;
00322     typedef basic_search_sequence_value_type<C, T>                  class_type;
00324     typedef ss_typename_type_k traits_type::entry_type              entry_type;
00326     typedef ss_typename_type_k traits_type::directory_parts_type    directory_parts_type;
00328 
00331 public:
00333     basic_search_sequence_value_type();
00334     basic_search_sequence_value_type(class_type const &rhs);
00335 private:
00336     basic_search_sequence_value_type(entry_type info)
00337         : m_info(info)
00338     {}
00339 public:
00341     ~basic_search_sequence_value_type();
00342 
00344     class_type &operator =(class_type const &rhs);
00346 
00349 public:
00351     string_t                get_path() const;
00352 #ifdef RECLS_PLATFORM_API_WIN32
00353     char_type               get_drive() const;
00354 #endif /* RECLS_PLATFORM_API_WIN32 */
00356     string_t                get_directory() const;
00358     string_t                get_directory_path() const;
00359 #if defined(RECLS_DOCUMENTATION_SKIP_SECTION) || \
00360     (   RECLS_VER_MAJOR > 1 || \
00361         RECLS_VER_MINOR >= 6)
00362 
00363     string_t                get_UNC_drive() const;
00364 #endif /* recls 1.6.x */
00365 #ifndef RECLS_PURE_API
00366 
00367     directory_parts_type    get_directory_parts() const;
00368 #endif /* !RECLS_PURE_API */
00369 
00370     string_t                get_file() const;
00372     string_t                get_short_file() const;
00374     string_t                get_filename() const;
00376     string_t                get_fileext() const;
00377 
00378     recls_time_t            get_creation_time() const;
00379     recls_time_t            get_modification_time() const;
00380     recls_time_t            get_last_access_time() const;
00381     recls_time_t            get_last_status_change_time() const;
00382 
00383     recls_filesize_t        get_size() const;
00384 
00385     recls_bool_t            is_readonly() const;
00386     recls_bool_t            is_directory() const;
00387     recls_bool_t            is_link() const;
00388 #if defined(RECLS_DOCUMENTATION_SKIP_SECTION) || \
00389     (   RECLS_VER_MAJOR > 1 || \
00390         RECLS_VER_MINOR >= 6)
00391 
00392     recls_bool_t            is_UNC() const;
00393 #endif /* recls 1.6.x */
00394 
00395 #ifndef RECLS_PURE_API
00396 
00397     char_type const         *c_str() const;
00398 #endif /* !RECLS_PURE_API */
00399 
00401     entry_type const        &get_entry() const;
00403 
00405 private:
00406 #ifdef RECLS_PURE_API
00407     static string_t get_string_(size_t (RECLS_CALLCONV_DEFAULT *pfn)(recls_info_t, recls_char_t *, size_t), entry_type info)
00408     {
00409         file_path_buffer    buffer;
00410         size_t              cch =   pfn(info, &buffer[0], buffer.size());
00411 
00412         return string_t(&buffer[0], cch);
00413     }
00414 #endif /* RECLS_PURE_API */
00415 
00416 // Members
00417 private:
00418     friend class basic_search_sequence_const_iterator<C, T, class_type>;
00419 
00420     entry_type  m_info;
00421 };
00422 
00423 // class basic_search_sequence_const_iterator
00427 template<   typename C
00428         ,   typename T
00429         ,   typename V
00430         >
00431 class basic_search_sequence_const_iterator
00432     : public stlsoft_ns_qual(iterator_base)<stlsoft_ns_qual_std(input_iterator_tag), V, ptrdiff_t, void, V>
00433 {
00434 public:
00436     typedef C                                               char_type;
00438     typedef T                                               traits_type;
00440     typedef V                                               value_type;
00442     typedef basic_search_sequence_const_iterator<C, T, V>   class_type;
00444     typedef ss_typename_type_k traits_type::entry_type      entry_type;
00445 private:
00446     typedef basic_search_sequence<C, T>                     sequence_type;
00447 
00448 private:
00449     explicit basic_search_sequence_const_iterator(hrecls_t hSrch)
00450         : m_handle(make_handle_(hSrch))
00451     {}
00452 public:
00454     basic_search_sequence_const_iterator();
00456     basic_search_sequence_const_iterator(class_type const &rhs);
00458     ~basic_search_sequence_const_iterator();
00459 
00460     // Copy assignment operator
00461     basic_search_sequence_const_iterator &operator =(class_type const &rhs);
00462 
00463 public:
00465     class_type &operator ++();
00467     void operator ++(int);
00469     const value_type operator *() const;
00471     recls_bool_t operator ==(class_type const &rhs) const;
00473     recls_bool_t operator !=(class_type const &rhs) const;
00474 
00475 // Implementation
00476 private:
00477     rss_shared_handle   *make_handle_(hrecls_t hSrch);
00478 
00479 // Members
00480 private:
00481     friend class basic_search_sequence<C, T>;
00482 
00483     rss_shared_handle   *m_handle;
00484 };
00485 
00487 // Shims
00488 
00499 template <typename C, typename T>
00500 inline recls_bool_t is_empty(basic_search_sequence<C, T> const &s)
00501 {
00502     return s.empty();
00503 }
00504 
00505 #ifndef RECLS_PURE_API
00516 template <typename C, typename T>
00517 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00518 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)
00519 #else
00520 inline C const *c_str_ptr(basic_search_sequence_value_type<C, T> const &v)
00521 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00522 {
00523     return v.c_str();
00524 }
00525 
00526 template <typename C, typename T>
00527 inline size_t c_str_len(basic_search_sequence_value_type<C, T> const &v)
00528 {
00529     return stlsoft_ns_qual(c_str_len)(v.c_str());
00530 }
00531 #endif /* !RECLS_PURE_API */
00532 
00534 // IOStream compatibility
00535 
00536 template<   typename S
00537         ,   typename C
00538         ,   typename T
00539         >
00540 inline S &operator <<(S &s, basic_search_sequence_value_type<C, T> const &v)
00541 {
00542 #ifdef RECLS_PURE_API
00543     s << v.c_str();
00544 #else /* ? RECLS_PURE_API */
00545     s << v.get_path();
00546 #endif /* RECLS_PURE_API */
00547 
00548     return s;
00549 }
00550 
00552 // Implementation
00553 
00554 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00555 
00556 // basic_search_sequence
00557 
00558 
00559 // Construction
00560 template <typename C, typename T>
00561 inline basic_search_sequence<C, T>::basic_search_sequence(char_type const *pattern, recls_uint32_t flags)
00562     : m_directory(copy_or_null_(m_directory_, ""))
00563     , m_pattern(copy_or_null_(m_pattern_, pattern))
00564     , m_flags(flags)
00565 {}
00566 
00567 template <typename C, typename T>
00568 inline basic_search_sequence<C, T>::basic_search_sequence(char_type const *directory, char_type const *pattern, recls_uint32_t flags)
00569     : m_directory(copy_or_null_(m_directory_, directory))
00570     , m_pattern(copy_or_null_(m_pattern_, pattern))
00571     , m_flags(flags)
00572 {}
00573 
00574 #if defined(RECLS_API_FTP)
00575 template <typename C, typename T>
00576 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)
00577     : m_host(host)
00578     , m_username(username)
00579     , m_password(password)
00580     , m_directory(copy_or_null_(m_directory_, directory))
00581     , m_pattern(copy_or_null_(m_pattern_, pattern))
00582     , m_flags(flags)
00583 {
00584     recls_message_assert("Must specify a hostname if using FTP", (NULL == username && NULL == password) || NULL != host);
00585 }
00586 #endif /* RECLS_API_FTP */
00587 
00588 // Iteration
00589 template <typename C, typename T>
00590 inline ss_typename_type_k basic_search_sequence<C, T>::const_iterator basic_search_sequence<C, T>::begin() const
00591 {
00592 #if defined(RECLS_API_FTP)
00593     if(m_host.empty())
00594     {
00595 #endif /* RECLS_API_FTP */
00596         return const_iterator(traits_type::Search(m_directory, m_pattern, m_flags));
00597 #if defined(RECLS_API_FTP)
00598     }
00599     else
00600     {
00601         return const_iterator(traits_type::SearchFtp(m_host.c_str(), m_username.c_str(), m_password.c_str(), m_directory, m_pattern, m_flags));
00602     }
00603 #endif /* RECLS_API_FTP */
00604 }
00605 
00606 template <typename C, typename T>
00607 inline ss_typename_type_k basic_search_sequence<C, T>::const_iterator basic_search_sequence<C, T>::end() const
00608 {
00609     return const_iterator();
00610 }
00611 
00612 // State
00613 template <typename C, typename T>
00614 inline ss_typename_type_k basic_search_sequence<C, T>::size_type basic_search_sequence<C, T>::size() const
00615 {
00616     const_iterator  b   =   begin();
00617     const_iterator  e   =   end();
00618     size_type       c   =   0;
00619 
00620     for(; b != e; ++b)
00621     {
00622         ++c;
00623     }
00624 
00625     return c;
00626 }
00627 
00628 template <typename C, typename T>
00629 inline recls_bool_t basic_search_sequence<C, T>::empty() const
00630 {
00631     return begin() == end();
00632 }
00633 
00634 template <typename C, typename T>
00635 inline /* static */ ss_typename_type_k basic_search_sequence<C, T>::size_type basic_search_sequence<C, T>::max_size()
00636 {
00637     return static_cast<size_type>(-1);
00638 }
00639 
00640 // basic_search_sequence_value_type
00641 
00642 
00643 template <typename C, typename T>
00644 inline basic_search_sequence_value_type<C, T>::basic_search_sequence_value_type()
00645     : m_info(NULL)
00646 {}
00647 
00648 template <typename C, typename T>
00649 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)
00650     : m_info(traits_type::CopyDetails(rhs.m_info))
00651 {}
00652 
00653 template <typename C, typename T>
00654 inline basic_search_sequence_value_type<C, T>::~basic_search_sequence_value_type()
00655 {
00656     if(NULL != m_info)
00657     {
00658         traits_type::CloseDetails(m_info);
00659     }
00660 }
00661 
00662 template <typename C, typename T>
00663 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)
00664 {
00665     if(NULL != m_info)
00666     {
00667         traits_type::CloseDetails(m_info);
00668     }
00669 
00670     m_info = traits_type::CopyDetails(rhs.m_info);
00671 
00672     return *this;
00673 }
00674 
00675 template <typename C, typename T>
00676 inline string_t basic_search_sequence_value_type<C, T>::get_path() const
00677 {
00678     recls_assert(NULL != m_info);
00679 
00680 #ifdef RECLS_PURE_API
00681     return get_string_(Recls_GetPathProperty, m_info);
00682 #else /* ? RECLS_PURE_API */
00683     return string_t(m_info->path.begin, m_info->path.end);
00684 #endif /* RECLS_PURE_API */
00685 }
00686 
00687 #ifdef RECLS_PLATFORM_API_WIN32
00688 template <typename C, typename T>
00689 inline ss_typename_type_k basic_search_sequence_value_type<C, T>::char_type basic_search_sequence_value_type<C, T>::get_drive() const
00690 {
00691     char_type   chDrive;
00692 
00693     return (Recls_GetDriveProperty(m_info, &chDrive), chDrive);
00694 }
00695 #endif /* RECLS_PLATFORM_API_WIN32 */
00696 
00697 template <typename C, typename T>
00698 inline string_t basic_search_sequence_value_type<C, T>::get_directory() const
00699 {
00700     recls_assert(NULL != m_info);
00701 
00702 #ifdef RECLS_PURE_API
00703     return get_string_(Recls_GetDirectoryProperty, m_info);
00704 #else /* ? RECLS_PURE_API */
00705     return string_t(m_info->directory.begin, m_info->directory.end);
00706 #endif /* RECLS_PURE_API */
00707 }
00708 
00709 template <typename C, typename T>
00710 inline string_t basic_search_sequence_value_type<C, T>::get_directory_path() const
00711 {
00712     recls_assert(NULL != m_info);
00713 
00714 #ifdef RECLS_PURE_API
00715     return get_string_(Recls_GetDirectoryPathProperty, m_info);
00716 #else /* ? RECLS_PURE_API */
00717     return string_t(m_info->path.begin, m_info->directory.end);
00718 #endif /* RECLS_PURE_API */
00719 }
00720 
00721 #if defined(RECLS_DOCUMENTATION_SKIP_SECTION) || \
00722     (   RECLS_VER_MAJOR > 1 || \
00723         RECLS_VER_MINOR >= 6)
00724 template <typename C, typename T>
00725 inline string_t basic_search_sequence_value_type<C, T>::get_UNC_drive() const
00726 {
00727     recls_assert(NULL != m_info);
00728 
00729 #if 0
00730     if(!is_UNC())
00731     {
00732         return string_t();
00733     }
00734     else
00735     {
00736 #ifdef RECLS_PURE_API
00737         string_t    directoryPath   =   get_directory_path();
00738         size_t      directoryLen    =   Recls_GetDirectoryProperty(m_info, NULL, 0);
00739 
00740         return string_t(directoryPath, 0, directoryPath.length() - directoryLen);
00741 #else /* ? RECLS_PURE_API */
00742         return string_t(m_info->path.begin, m_info->directory.begin);
00743 #endif /* RECLS_PURE_API */
00744     }
00745 #else /* ? 0 */
00746 # ifdef RECLS_PURE_API
00747     return get_string_(Recls_GetUNCDriveProperty, m_info);
00748 # else /* ? RECLS_PURE_API */
00749     return string_t(m_info->path.begin, m_info->directory.begin);
00750 # endif /* RECLS_PURE_API */
00751 #endif /* 0 */
00752 }
00753 #endif /* recls 1.6.x */
00754 
00755 #ifndef RECLS_PURE_API
00756 template <typename C, typename T>
00757 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
00758 {
00759     recls_assert(NULL != m_info);
00760 
00761     return directory_parts_type(m_info->directoryParts.begin, m_info->directoryParts.end);
00762 }
00763 #endif /* !RECLS_PURE_API */
00764 
00765 template <typename C, typename T>
00766 inline string_t basic_search_sequence_value_type<C, T>::get_file() const
00767 {
00768     recls_assert(NULL != m_info);
00769 
00770 #ifdef RECLS_PURE_API
00771     return get_string_(Recls_GetFileProperty, m_info);
00772 #else /* ? RECLS_PURE_API */
00773     return string_t(m_info->fileName.begin, m_info->fileExt.end);
00774 #endif /* RECLS_PURE_API */
00775 }
00776 
00777 #if 0
00778 template <typename C, typename T>
00779 inline string_t basic_search_sequence_value_type<C, T>::get_short_file() const
00780 {
00781     return m_info.cAlternateFileName[0] != '\0' ? m_info.cAlternateFileName : m_info.cFileName;
00782 }
00783 #endif /* 0 */
00784 
00785 template <typename C, typename T>
00786 inline string_t basic_search_sequence_value_type<C, T>::get_filename() const
00787 {
00788     recls_assert(NULL != m_info);
00789 
00790 #ifdef RECLS_PURE_API
00791     return get_string_(Recls_GetFileNameProperty, m_info);
00792 #else /* ? RECLS_PURE_API */
00793     return string_t(m_info->fileName.begin, m_info->fileName.end);
00794 #endif /* RECLS_PURE_API */
00795 }
00796 
00797 template <typename C, typename T>
00798 inline string_t basic_search_sequence_value_type<C, T>::get_fileext() const
00799 {
00800     recls_assert(NULL != m_info);
00801 
00802 #ifdef RECLS_PURE_API
00803     return get_string_(Recls_GetFileExtProperty, m_info);
00804 #else /* ? RECLS_PURE_API */
00805     return string_t(m_info->fileExt.begin, m_info->fileExt.end);
00806 #endif /* RECLS_PURE_API */
00807 }
00808 
00809 template <typename C, typename T>
00810 inline recls_time_t basic_search_sequence_value_type<C, T>::get_creation_time() const
00811 {
00812     recls_assert(NULL != m_info);
00813 
00814     return Recls_GetCreationTime(m_info);
00815 }
00816 
00817 template <typename C, typename T>
00818 inline recls_time_t basic_search_sequence_value_type<C, T>::get_modification_time() const
00819 {
00820     recls_assert(NULL != m_info);
00821 
00822     return Recls_GetModificationTime(m_info);
00823 }
00824 
00825 template <typename C, typename T>
00826 inline recls_time_t basic_search_sequence_value_type<C, T>::get_last_access_time() const
00827 {
00828     recls_assert(NULL != m_info);
00829 
00830     return Recls_GetLastAccessTime(m_info);
00831 }
00832 
00833 template <typename C, typename T>
00834 inline recls_time_t basic_search_sequence_value_type<C, T>::get_last_status_change_time() const
00835 {
00836     recls_assert(NULL != m_info);
00837 
00838     return Recls_GetLastStatusChangeTime(m_info);
00839 }
00840 
00841 template <typename C, typename T>
00842 inline recls_filesize_t basic_search_sequence_value_type<C, T>::get_size() const
00843 {
00844     recls_assert(NULL != m_info);
00845 
00846 #ifdef RECLS_PURE_API
00847     recls_filesize_t    size;
00848 
00849     return (Recls_GetSizeProperty(m_info, &size), size);
00850 #else /* ? RECLS_PURE_API */
00851     return m_info->size;
00852 #endif /* RECLS_PURE_API */
00853 }
00854 
00855 template <typename C, typename T>
00856 inline recls_bool_t basic_search_sequence_value_type<C, T>::is_readonly() const
00857 {
00858     recls_assert(NULL != m_info);
00859 
00860     return Recls_IsFileReadOnly(m_info);
00861 }
00862 
00863 template <typename C, typename T>
00864 inline recls_bool_t basic_search_sequence_value_type<C, T>::is_directory() const
00865 {
00866     recls_assert(NULL != m_info);
00867 
00868     return Recls_IsFileDirectory(m_info);
00869 }
00870 
00871 template <typename C, typename T>
00872 inline recls_bool_t basic_search_sequence_value_type<C, T>::is_link() const
00873 {
00874     recls_assert(NULL != m_info);
00875 
00876     return Recls_IsFileLink(m_info);
00877 }
00878 
00879 #if defined(RECLS_DOCUMENTATION_SKIP_SECTION) || \
00880     (   RECLS_VER_MAJOR > 1 || \
00881         RECLS_VER_MINOR >= 6)
00882 template <typename C, typename T>
00883 inline recls_bool_t basic_search_sequence_value_type<C, T>::is_UNC() const
00884 {
00885     recls_assert(NULL != m_info);
00886 
00887     return Recls_IsFileUNC(m_info);
00888 }
00889 #endif /* recls 1.6.x */
00890 
00891 #ifndef RECLS_PURE_API
00892 template <typename C, typename T>
00893 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
00894 {
00895     recls_assert(NULL != m_info);
00896 
00897     return m_info->path.begin;
00898 }
00899 #endif /* !RECLS_PURE_API */
00900 
00901 template <typename C, typename T>
00902 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
00903 {
00904     return m_info;
00905 }
00906 
00907 // basic_search_sequence_const_iterator
00908 
00909 template <typename C, typename T, typename V>
00910 inline rss_shared_handle *basic_search_sequence_const_iterator<C, T, V>::make_handle_(hrecls_t hSrch)
00911 {
00912     return (NULL != hSrch) ? new rss_shared_handle(hSrch) : static_cast<rss_shared_handle*>(NULL);
00913 }
00914 
00915 template <typename C, typename T, typename V>
00916 inline basic_search_sequence_const_iterator<C, T, V>::basic_search_sequence_const_iterator()
00917     : m_handle(NULL)
00918 {}
00919 
00920 template <typename C, typename T, typename V>
00921 inline basic_search_sequence_const_iterator<C, T, V>::basic_search_sequence_const_iterator(class_type const &rhs)
00922     : m_handle(rhs.m_handle)
00923 {
00924     if(NULL != m_handle)
00925     {
00926         ++m_handle->cRefs;
00927     }
00928 }
00929 
00930 template <typename C, typename T, typename V>
00931 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)
00932 {
00933     if(NULL != m_handle)
00934     {
00935         m_handle->Release();
00936     }
00937 
00938     m_handle =   rhs.m_handle;
00939 
00940     if(NULL != m_handle)
00941     {
00942         ++m_handle->cRefs;
00943     }
00944 
00945     return *this;
00946 }
00947 
00948 template <typename C, typename T, typename V>
00949 inline basic_search_sequence_const_iterator<C, T, V>::~basic_search_sequence_const_iterator()
00950 {
00951     if(NULL != m_handle)
00952     {
00953         m_handle->Release();
00954     }
00955 }
00956 
00957 template <typename C, typename T, typename V>
00958 inline ss_typename_type_k basic_search_sequence_const_iterator<C, T, V>::class_type &basic_search_sequence_const_iterator<C, T, V>::operator ++()
00959 {
00960     recls_message_assert("Attempting to increment invalid iterator", NULL != m_handle);
00961 
00962     if(RECLS_FAILED(Recls_GetNext(m_handle->hSrch)))
00963     {
00964         m_handle->Release();
00965 
00966         m_handle = NULL;
00967     }
00968 
00969     return *this;
00970 }
00971 
00972 template <typename C, typename T, typename V>
00973 inline void basic_search_sequence_const_iterator<C, T, V>::operator ++(int)
00974 {
00975     operator ++();
00976 }
00977 
00978 template <typename C, typename T, typename V>
00979 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
00980 {
00981     entry_type  info;
00982 
00983     recls_message_assert("Attempting to dereference invalid iterator", NULL != m_handle);
00984 
00985     if( m_handle->hSrch != NULL &&
00986         RECLS_SUCCEEDED(traits_type::GetDetails(m_handle->hSrch, &info)))
00987     {
00988         return value_type(info);
00989     }
00990     else
00991     {
00992         recls_message_assert("Dereferencing end()-valued iterator", 0);
00993 
00994         return value_type();
00995     }
00996 }
00997 
00998 template <typename C, typename T, typename V>
00999 inline recls_bool_t basic_search_sequence_const_iterator<C, T, V>::operator ==(class_type const &rhs) const
01000 {
01001     return (m_handle == NULL) && (rhs.m_handle == NULL);
01002 }
01003 
01004 template <typename C, typename T, typename V>
01005 inline recls_bool_t basic_search_sequence_const_iterator<C, T, V>::operator !=(class_type const &rhs) const
01006 {
01007     return ! operator ==(rhs);
01008 }
01009 
01010 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
01011 
01012 /* 
01013 
01014 #if !defined(RECLS_NO_NAMESPACE)
01015 } /* namespace stl */
01016 } /* namespace recls */
01017 
01018 // Now we introduce the two shims into the STLSoft namespace - stlsoft.
01019 namespace stlsoft
01020 {
01021     using recls::stl::is_empty;
01022 #ifndef RECLS_PURE_API
01023     using recls::stl::c_str_ptr;
01024     using recls::stl::c_str_len;
01025 #endif /* !RECLS_PURE_API */
01026 
01027 } // namespace stlsoft
01028 #endif /* !RECLS_NO_NAMESPACE */
01029 
01030 /* 
01031 
01032 #endif /* RECLS_INCL_RECLSTL_STL_HPP_SEARCH_SEQUENCE */
01033 
01034 /* 

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