You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

789 lines
25 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/filesystem/findvolume_sequence.hpp
  3. *
  4. * Purpose: Contains the basic_findvolume_sequence template class, and ANSI
  5. * and Unicode specialisations thereof.
  6. *
  7. * Notes: The original implementation of the class had the const_iterator
  8. * and value_type as nested classes. Unfortunately, Visual C++ 5 &
  9. * 6 both had either compilation or linking problems so these are
  10. * regretably now implemented as independent classes.
  11. *
  12. * Created: 15th January 2002
  13. * Updated: 21st June 2010
  14. *
  15. * Home: http://stlsoft.org/
  16. *
  17. * Copyright (c) 2002-2010, Matthew Wilson and Synesis Software
  18. * All rights reserved.
  19. *
  20. * Redistribution and use in source and binary forms, with or without
  21. * modification, are permitted provided that the following conditions are
  22. * met:
  23. *
  24. * - Redistributions of source code must retain the above copyright notice,
  25. * this list of conditions and the following disclaimer.
  26. * - Redistributions in binary form must reproduce the above copyright
  27. * notice, this list of conditions and the following disclaimer in the
  28. * documentation and/or other materials provided with the distribution.
  29. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  30. * names of any contributors may be used to endorse or promote products
  31. * derived from this software without specific prior written permission.
  32. *
  33. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  34. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  35. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  36. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  37. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  38. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  39. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  40. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  41. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  42. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  43. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. *
  45. * ////////////////////////////////////////////////////////////////////// */
  46. /** \file winstl/filesystem/findvolume_sequence.hpp
  47. *
  48. * \brief [C++ only] Definition of the winstl::basic_findvolume_sequence
  49. * class template
  50. * (\ref group__library__filesystem "File System" Library).
  51. */
  52. #ifndef WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FINDVOLUME_SEQUENCE
  53. #define WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FINDVOLUME_SEQUENCE
  54. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  55. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FINDVOLUME_SEQUENCE_MAJOR 4
  56. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FINDVOLUME_SEQUENCE_MINOR 3
  57. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FINDVOLUME_SEQUENCE_REVISION 7
  58. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FINDVOLUME_SEQUENCE_EDIT 116
  59. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  60. /* /////////////////////////////////////////////////////////////////////////
  61. * Includes
  62. */
  63. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  64. # include <winstl/winstl.h>
  65. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  66. #ifndef WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS
  67. # include <winstl/filesystem/filesystem_traits.hpp>
  68. #endif /* !WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS */
  69. #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
  70. # include <stlsoft/util/std/iterator_helper.hpp>
  71. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER */
  72. #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
  73. # include <stlsoft/collections/util/collections.hpp>
  74. #endif /* !STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS */
  75. #ifdef STLSOFT_MINIMUM_SAS_INCLUDES
  76. # ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING
  77. # include <stlsoft/shims/access/string/std/c_string.h>
  78. # endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING */
  79. #else /* ? STLSOFT_MINIMUM_SAS_INCLUDES */
  80. # ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
  81. # include <stlsoft/shims/access/string.hpp>
  82. # endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING */
  83. #endif /* STLSOFT_MINIMUM_SAS_INCLUDES */
  84. /* /////////////////////////////////////////////////////////////////////////
  85. * Namespace
  86. */
  87. #ifndef _WINSTL_NO_NAMESPACE
  88. # if defined(_STLSOFT_NO_NAMESPACE) || \
  89. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  90. /* There is no stlsoft namespace, so must define ::winstl */
  91. namespace winstl
  92. {
  93. # else
  94. /* Define stlsoft::winstl_project */
  95. namespace stlsoft
  96. {
  97. namespace winstl_project
  98. {
  99. # endif /* _STLSOFT_NO_NAMESPACE */
  100. #endif /* !_WINSTL_NO_NAMESPACE */
  101. /* /////////////////////////////////////////////////////////////////////////
  102. * Enumerations
  103. */
  104. // The FindNextVolume API is not well documented so assume _MAX_PATH
  105. // (aka WINSTL_CONST_MAX_PATH)
  106. // is sufficient for volume names
  107. enum
  108. {
  109. MAX_VOL_NAME = WINSTL_CONST_MAX_PATH //!< The maximum number of characters in a volume name
  110. };
  111. /* /////////////////////////////////////////////////////////////////////////
  112. * Forward declarations
  113. */
  114. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  115. template <ss_typename_param_k C, ss_typename_param_k T>
  116. class basic_findvolume_sequence_value_type;
  117. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  118. class basic_findvolume_sequence_const_iterator;
  119. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  120. /* /////////////////////////////////////////////////////////////////////////
  121. * Classes
  122. */
  123. // class basic_findvolume_sequence
  124. /** \brief Presents an STL-like sequence interface over the volumes on a system
  125. *
  126. * \ingroup group__library__filesystem
  127. *
  128. * \note This class functions only on Windows 2000 and later
  129. *
  130. * \param C The character type
  131. * \param T The traits type. On translators that support default template arguments this defaults to filesystem_traits<C>
  132. */
  133. template< ss_typename_param_k C
  134. #ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
  135. , ss_typename_param_k T = filesystem_traits<C>
  136. #else /* ? STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
  137. , ss_typename_param_k T /* = filesystem_traits<C> */
  138. #endif /* STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
  139. >
  140. class basic_findvolume_sequence
  141. : public stlsoft_ns_qual(stl_collection_tag)
  142. {
  143. public:
  144. /// The character type
  145. typedef C char_type;
  146. /// The traits type
  147. typedef T traits_type;
  148. /// The current parameterisation of the type
  149. typedef basic_findvolume_sequence<C, T> class_type;
  150. /// The value type
  151. typedef basic_findvolume_sequence_value_type<C, T> value_type;
  152. /// The non-mutating (const) iterator type
  153. typedef basic_findvolume_sequence_const_iterator<C, T, value_type> const_iterator;
  154. /// The reference type
  155. typedef value_type& reference;
  156. /// The non-mutable (const) reference type
  157. typedef value_type const& const_reference;
  158. // Iteration
  159. public:
  160. /// Begins the iteration
  161. ///
  162. /// \return An iterator representing the start of the sequence
  163. const_iterator begin() const;
  164. /// Ends the iteration
  165. ///
  166. /// \return An iterator representing the end of the sequence
  167. const_iterator end() const;
  168. // State
  169. public:
  170. /// Evalulates whether the sequence is empty
  171. ws_bool_t empty() const;
  172. };
  173. /* /////////////////////////////////////////////////////////////////////////
  174. * Typedefs for commonly encountered types
  175. */
  176. /** \brief Specialisation of the basic_findvolume_sequence template for the ANSI character type \c char
  177. *
  178. * \ingroup group__library__filesystem
  179. */
  180. typedef basic_findvolume_sequence<ws_char_a_t, filesystem_traits<ws_char_a_t> > findvolume_sequence_a;
  181. /** \brief Specialisation of the basic_findvolume_sequence template for the Unicode character type \c wchar_t
  182. *
  183. * \ingroup group__library__filesystem
  184. */
  185. typedef basic_findvolume_sequence<ws_char_w_t, filesystem_traits<ws_char_w_t> > findvolume_sequence_w;
  186. /** \brief Specialisation of the basic_findvolume_sequence template for the Win32 character type \c TCHAR
  187. *
  188. * \ingroup group__library__filesystem
  189. */
  190. typedef basic_findvolume_sequence<TCHAR, filesystem_traits<TCHAR> > findvolume_sequence;
  191. /* ////////////////////////////////////////////////////////////////////// */
  192. // class basic_findvolume_sequence_value_type
  193. /** \brief Value type for the basic_findvolume_sequence
  194. *
  195. * \ingroup group__library__filesystem
  196. */
  197. template< ss_typename_param_k C
  198. , ss_typename_param_k T
  199. >
  200. class basic_findvolume_sequence_value_type
  201. {
  202. public:
  203. /// The character type
  204. typedef C char_type;
  205. /// The traits type
  206. typedef T traits_type;
  207. /// The current parameterisation of the type
  208. typedef basic_findvolume_sequence_value_type<C, T> class_type;
  209. public:
  210. /// Default constructor
  211. basic_findvolume_sequence_value_type();
  212. /// Copy constructor
  213. basic_findvolume_sequence_value_type(class_type const& rhs);
  214. private:
  215. basic_findvolume_sequence_value_type(char_type const* vol_name);
  216. public:
  217. /// Copy assignment operator
  218. class_type& operator =(class_type const& rhs);
  219. // Attributes
  220. public:
  221. /// Implicit conversion to non-mutable pointer-to-const of the volume name
  222. operator char_type const* () const
  223. {
  224. return m_name;
  225. }
  226. private:
  227. friend class basic_findvolume_sequence_const_iterator<C, T, class_type>;
  228. char_type m_name[MAX_VOL_NAME + 1];
  229. };
  230. // class basic_findvolume_sequence_const_iterator
  231. /** \brief Iterator type for the basic_findvolume_sequence, supporting the Input Iterator concept
  232. *
  233. * \ingroup group__library__filesystem
  234. */
  235. template< ss_typename_param_k C
  236. , ss_typename_param_k T
  237. , ss_typename_param_k V
  238. >
  239. class basic_findvolume_sequence_const_iterator
  240. : public stlsoft_ns_qual(iterator_base)<
  241. winstl_ns_qual_std(input_iterator_tag)
  242. , V
  243. , ws_ptrdiff_t
  244. , void // By-Value Temporary reference
  245. , V // By-Value Temporary reference
  246. >
  247. {
  248. public:
  249. /// The character type
  250. typedef C char_type;
  251. /// The traits type
  252. typedef T traits_type;
  253. /// The traits type
  254. typedef V value_type;
  255. /// The current parameterisation of the type
  256. typedef basic_findvolume_sequence_const_iterator<C, T, V> class_type;
  257. /// \name Utility classes
  258. /// @{
  259. private:
  260. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  261. struct shared_handle
  262. {
  263. public:
  264. typedef shared_handle class_type;
  265. // Members
  266. public:
  267. HANDLE hSrch;
  268. private:
  269. ss_sint32_t cRefs;
  270. public:
  271. ss_explicit_k shared_handle(HANDLE h)
  272. : hSrch(h)
  273. , cRefs(1)
  274. {}
  275. void AddRef()
  276. {
  277. ++cRefs;
  278. }
  279. void Release()
  280. {
  281. if(0 == --cRefs)
  282. {
  283. delete this;
  284. }
  285. }
  286. #if defined(STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR)
  287. protected:
  288. #else /* ? STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR */
  289. private:
  290. #endif /* STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR */
  291. ~shared_handle() stlsoft_throw_0()
  292. {
  293. WINSTL_MESSAGE_ASSERT("Shared search handle being destroyed with outstanding references!", 0 == cRefs);
  294. if(hSrch != INVALID_HANDLE_VALUE)
  295. {
  296. traits_type::find_volume_close(hSrch);
  297. }
  298. }
  299. private:
  300. shared_handle(class_type const&);
  301. class_type& operator =(class_type const&);
  302. };
  303. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  304. /// @}
  305. /// \name Construction
  306. /// @{
  307. private:
  308. basic_findvolume_sequence_const_iterator(basic_findvolume_sequence<C, T> const& l, HANDLE hSrch, char_type const* vol_name)
  309. : m_list(&l)
  310. , m_handle(new shared_handle(hSrch))
  311. {
  312. WINSTL_ASSERT(INVALID_HANDLE_VALUE != hSrch);
  313. if(NULL == m_handle)
  314. {
  315. traits_type::find_volume_close(hSrch);
  316. m_name[0] = '\0';
  317. }
  318. else
  319. {
  320. traits_type::char_copy(m_name, vol_name, STLSOFT_NUM_ELEMENTS(m_name));
  321. }
  322. }
  323. basic_findvolume_sequence_const_iterator(basic_findvolume_sequence<C, T> const& l);
  324. public:
  325. /// Default constructor
  326. basic_findvolume_sequence_const_iterator();
  327. /// Copy constructor
  328. basic_findvolume_sequence_const_iterator(class_type const& rhs);
  329. /// Destructor
  330. ~basic_findvolume_sequence_const_iterator() stlsoft_throw_0();
  331. /// Copy assignment operator
  332. class_type& operator =(class_type const& rhs);
  333. public:
  334. /// Pre-increment operator
  335. class_type& operator ++();
  336. /// Post-increment operator
  337. class_type operator ++(int);
  338. /// Dereference to access the value at the current position
  339. const value_type operator *() const;
  340. /// Evaluates whether \c this and \c rhs are equivalent
  341. ws_bool_t operator ==(class_type const& rhs) const;
  342. /// Evaluates whether \c this and \c rhs are not equivalent
  343. ws_bool_t operator !=(class_type const& rhs) const;
  344. // Members
  345. private:
  346. friend class basic_findvolume_sequence<C, T>;
  347. typedef basic_findvolume_sequence<C, T> list_type;
  348. list_type const* m_list;
  349. shared_handle* m_handle;
  350. char_type m_name[MAX_VOL_NAME + 1];
  351. };
  352. ////////////////////////////////////////////////////////////////////////////
  353. // Shims
  354. // c_str_data
  355. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  356. template <ss_typename_param_k T>
  357. inline ws_char_a_t const* c_str_data_a(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_a_t, T> const& v)
  358. {
  359. return v;
  360. }
  361. template <ss_typename_param_k T>
  362. inline ws_char_w_t const* c_str_data_w(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_w_t, T> const& v)
  363. {
  364. return v;
  365. }
  366. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  367. /** \brief \ref group__concept__shim__string_access__c_str_data for winstl::basic_findvolume_sequence_value_type
  368. *
  369. * \ingroup group__concept__shim__string_access
  370. */
  371. template <ss_typename_param_k C, ss_typename_param_k T>
  372. inline C const* c_str_data(winstl_ns_qual(basic_findvolume_sequence_value_type)<C, T> const& v)
  373. {
  374. return v;
  375. }
  376. // c_str_len
  377. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  378. template <ss_typename_param_k T>
  379. inline ws_size_t c_str_len_a(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_a_t, T> const& v)
  380. {
  381. return stlsoft_ns_qual(c_str_len_a(stlsoft_ns_qual(c_str_ptr_a(v))));
  382. }
  383. template <ss_typename_param_k T>
  384. inline ws_size_t c_str_len_w(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_w_t, T> const& v)
  385. {
  386. return stlsoft_ns_qual(c_str_len_w(stlsoft_ns_qual(c_str_ptr_w(v))));
  387. }
  388. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  389. /** \brief \ref group__concept__shim__string_access__c_str_len for winstl::basic_findvolume_sequence_value_type
  390. *
  391. * \ingroup group__concept__shim__string_access
  392. */
  393. template <ss_typename_param_k C, ss_typename_param_k T>
  394. inline ws_size_t c_str_len(winstl_ns_qual(basic_findvolume_sequence_value_type)<C, T> const& v)
  395. {
  396. return stlsoft_ns_qual(c_str_len(stlsoft_ns_qual(c_str_ptr(v))));
  397. }
  398. // c_str_ptr
  399. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  400. template <ss_typename_param_k T>
  401. inline ws_char_a_t const* c_str_ptr_a(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_a_t, T> const& v)
  402. {
  403. return v;
  404. }
  405. template <ss_typename_param_k T>
  406. inline ws_char_w_t const* c_str_ptr_w(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_w_t, T> const& v)
  407. {
  408. return v;
  409. }
  410. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  411. /** \brief \ref group__concept__shim__string_access__c_str_ptr for winstl::basic_findvolume_sequence_value_type
  412. *
  413. * \ingroup group__concept__shim__string_access
  414. */
  415. template <ss_typename_param_k C, ss_typename_param_k T>
  416. inline C const* c_str_ptr(winstl_ns_qual(basic_findvolume_sequence_value_type)<C, T> const& v)
  417. {
  418. return v;
  419. }
  420. // c_str_ptr_null
  421. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  422. template <ss_typename_param_k T>
  423. inline ws_char_a_t const* c_str_ptr_null_a(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_a_t, T> const& v)
  424. {
  425. return stlsoft_ns_qual(c_str_ptr_null_a(v));
  426. }
  427. template <ss_typename_param_k T>
  428. inline ws_char_w_t const* c_str_ptr_null_w(winstl_ns_qual(basic_findvolume_sequence_value_type)<ws_char_w_t, T> const& v)
  429. {
  430. return stlsoft_ns_qual(c_str_ptr_null_w(v));
  431. }
  432. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  433. /** \brief \ref group__concept__shim__string_access__c_str_ptr_null for winstl::basic_findvolume_sequence_value_type
  434. *
  435. * \ingroup group__concept__shim__string_access
  436. */
  437. template <ss_typename_param_k C, ss_typename_param_k T>
  438. inline C const* c_str_ptr_null(winstl_ns_qual(basic_findvolume_sequence_value_type)<C, T> const& v)
  439. {
  440. return stlsoft_ns_qual(c_str_ptr_null(v));
  441. }
  442. /* /////////////////////////////////////////////////////////////////////////
  443. * Deprecated Shims
  444. */
  445. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  446. template <ss_typename_param_k C, ss_typename_param_k T>
  447. inline ws_bool_t is_empty(winstl_ns_qual(basic_findvolume_sequence_value_type)<C, T> const& v)
  448. {
  449. return '\0' == v[0];
  450. }
  451. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  452. ////////////////////////////////////////////////////////////////////////////
  453. // Unit-testing
  454. #ifdef STLSOFT_UNITTEST
  455. # include "./unittest/findvolume_sequence_unittest_.h"
  456. #endif /* STLSOFT_UNITTEST */
  457. ////////////////////////////////////////////////////////////////////////////
  458. // Implementation
  459. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  460. // basic_findvolume_sequence
  461. template <ss_typename_param_k C, ss_typename_param_k T>
  462. inline ss_typename_type_ret_k basic_findvolume_sequence<C, T>::const_iterator basic_findvolume_sequence<C, T>::begin() const
  463. {
  464. char_type vol_name[MAX_VOL_NAME + 1];
  465. HANDLE hSrch = traits_type::find_first_volume(vol_name, STLSOFT_NUM_ELEMENTS(vol_name));
  466. if(hSrch != INVALID_HANDLE_VALUE)
  467. {
  468. #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
  469. try
  470. {
  471. #endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
  472. return const_iterator(*this, hSrch, vol_name);
  473. #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
  474. }
  475. catch(...)
  476. {
  477. traits_type::find_volume_close(hSrch);
  478. throw;
  479. }
  480. #endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
  481. }
  482. return const_iterator(*this);
  483. }
  484. template <ss_typename_param_k C, ss_typename_param_k T>
  485. inline ss_typename_type_ret_k basic_findvolume_sequence<C, T>::const_iterator basic_findvolume_sequence<C, T>::end() const
  486. {
  487. return const_iterator(*this);
  488. }
  489. template <ss_typename_param_k C, ss_typename_param_k T>
  490. inline ws_bool_t basic_findvolume_sequence<C, T>::empty() const
  491. {
  492. return begin() == end();
  493. }
  494. // basic_findvolume_sequence_value_type
  495. template <ss_typename_param_k C, ss_typename_param_k T>
  496. inline basic_findvolume_sequence_value_type<C, T>::basic_findvolume_sequence_value_type()
  497. {
  498. m_name[0] = '\0';
  499. }
  500. template <ss_typename_param_k C, ss_typename_param_k T>
  501. inline basic_findvolume_sequence_value_type<C, T>::basic_findvolume_sequence_value_type(class_type const& rhs)
  502. {
  503. traits_type::char_copy(m_name, rhs.m_name, STLSOFT_NUM_ELEMENTS(m_name));
  504. }
  505. template <ss_typename_param_k C, ss_typename_param_k T>
  506. inline basic_findvolume_sequence_value_type<C, T>::basic_findvolume_sequence_value_type(char_type const* vol_name)
  507. {
  508. traits_type::char_copy(m_name, vol_name, STLSOFT_NUM_ELEMENTS(m_name));
  509. }
  510. template <ss_typename_param_k C, ss_typename_param_k T>
  511. inline ss_typename_type_ret_k basic_findvolume_sequence_value_type<C, T>::class_type& basic_findvolume_sequence_value_type<C, T>::operator =(class_type const& rhs)
  512. {
  513. traits_type::char_copy(m_name, rhs.m_name, STLSOFT_NUM_ELEMENTS(m_name));
  514. return *this;
  515. }
  516. // basic_findvolume_sequence_const_iterator
  517. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  518. inline basic_findvolume_sequence_const_iterator<C, T, V>::basic_findvolume_sequence_const_iterator()
  519. : m_list(NULL)
  520. , m_handle(NULL)
  521. {
  522. m_name[0] = '\0';
  523. }
  524. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  525. inline basic_findvolume_sequence_const_iterator<C, T, V>::basic_findvolume_sequence_const_iterator(basic_findvolume_sequence<C, T> const& l)
  526. : m_list(&l)
  527. , m_handle(NULL)
  528. {
  529. m_name[0] = '\0';
  530. }
  531. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  532. inline basic_findvolume_sequence_const_iterator<C, T, V>::basic_findvolume_sequence_const_iterator(class_type const& rhs)
  533. : m_list(rhs.m_list)
  534. , m_handle(rhs.m_handle)
  535. {
  536. if(NULL != m_handle)
  537. {
  538. m_handle->AddRef();
  539. }
  540. }
  541. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  542. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  543. inline ss_typename_type_ret_k basic_findvolume_sequence_const_iterator<C, T, V>::class_type& basic_findvolume_sequence_const_iterator<C, T, V>::operator =(ss_typename_type_k basic_findvolume_sequence_const_iterator<C, T, V>::class_type const& rhs)
  544. {
  545. shared_handle *this_handle = m_handle;
  546. m_list = rhs.m_list;
  547. m_handle = rhs.m_handle;
  548. if(NULL != m_handle)
  549. {
  550. m_handle->AddRef();
  551. }
  552. if(NULL != this_handle)
  553. {
  554. this_handle->Release();
  555. }
  556. return *this;
  557. }
  558. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  559. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  560. inline basic_findvolume_sequence_const_iterator<C, T, V>::~basic_findvolume_sequence_const_iterator() stlsoft_throw_0()
  561. {
  562. if(NULL != m_handle)
  563. {
  564. m_handle->Release();
  565. }
  566. }
  567. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  568. inline ss_typename_type_ret_k basic_findvolume_sequence_const_iterator<C, T, V>::class_type& basic_findvolume_sequence_const_iterator<C, T, V>::operator ++()
  569. {
  570. WINSTL_MESSAGE_ASSERT("Attempting to increment an invalid iterator!", NULL != m_handle);
  571. if(!traits_type::find_next_volume(m_handle->hSrch, m_name, STLSOFT_NUM_ELEMENTS(m_name)))
  572. {
  573. m_handle->Release();
  574. m_handle = NULL;
  575. }
  576. return *this;
  577. }
  578. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  579. inline ss_typename_type_ret_k basic_findvolume_sequence_const_iterator<C, T, V>::class_type basic_findvolume_sequence_const_iterator<C, T, V>::operator ++(int)
  580. {
  581. class_type ret(*this);
  582. operator ++();
  583. return ret;
  584. }
  585. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  586. inline const ss_typename_type_k basic_findvolume_sequence_const_iterator<C, T, V>::value_type basic_findvolume_sequence_const_iterator<C, T, V>::operator *() const
  587. {
  588. if(NULL != m_handle)
  589. {
  590. return value_type(m_name);
  591. }
  592. else
  593. {
  594. return value_type();
  595. }
  596. }
  597. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  598. inline ws_bool_t basic_findvolume_sequence_const_iterator<C, T, V>::operator ==(class_type const& rhs) const
  599. {
  600. WINSTL_MESSAGE_ASSERT("Comparing iterators from separate sequences", (m_list == rhs.m_list || NULL == m_list || NULL == rhs.m_list));
  601. return m_handle == rhs.m_handle;
  602. }
  603. template <ss_typename_param_k C, ss_typename_param_k T, ss_typename_param_k V>
  604. inline ws_bool_t basic_findvolume_sequence_const_iterator<C, T, V>::operator !=(class_type const& rhs) const
  605. {
  606. return ! operator ==(rhs);
  607. }
  608. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  609. /* ////////////////////////////////////////////////////////////////////// */
  610. #ifndef _WINSTL_NO_NAMESPACE
  611. # if defined(_STLSOFT_NO_NAMESPACE) || \
  612. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  613. } // namespace winstl
  614. # else
  615. } // namespace winstl_project
  616. } // namespace stlsoft
  617. # endif /* _STLSOFT_NO_NAMESPACE */
  618. #endif /* !_WINSTL_NO_NAMESPACE */
  619. /* /////////////////////////////////////////////////////////////////////////
  620. * Namespace
  621. *
  622. * The string access shims exist either in the stlsoft namespace, or in the
  623. * global namespace. This is required by the lookup rules.
  624. *
  625. */
  626. #ifndef _WINSTL_NO_NAMESPACE
  627. # if !defined(_STLSOFT_NO_NAMESPACE) && \
  628. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  629. namespace stlsoft
  630. {
  631. # else /* ? _STLSOFT_NO_NAMESPACE */
  632. /* There is no stlsoft namespace, so must define in the global namespace */
  633. # endif /* !_STLSOFT_NO_NAMESPACE */
  634. using ::winstl::c_str_len;
  635. using ::winstl::c_str_len_a;
  636. using ::winstl::c_str_len_w;
  637. using ::winstl::c_str_data;
  638. using ::winstl::c_str_data_a;
  639. using ::winstl::c_str_data_w;
  640. using ::winstl::c_str_ptr;
  641. using ::winstl::c_str_ptr_a;
  642. using ::winstl::c_str_ptr_w;
  643. using ::winstl::c_str_ptr_null;
  644. //using ::winstl::c_str_ptr_null_a;
  645. //using ::winstl::c_str_ptr_null_w;
  646. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  647. using ::winstl::is_empty;
  648. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  649. # if !defined(_STLSOFT_NO_NAMESPACE) && \
  650. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  651. } // namespace stlsoft
  652. # else /* ? _STLSOFT_NO_NAMESPACE */
  653. /* There is no stlsoft namespace, so must define in the global namespace */
  654. # endif /* !_STLSOFT_NO_NAMESPACE */
  655. #endif /* !_WINSTL_NO_NAMESPACE */
  656. /* ////////////////////////////////////////////////////////////////////// */
  657. #endif /* WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FINDVOLUME_SEQUENCE */
  658. /* ///////////////////////////// end of file //////////////////////////// */