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.

656 lines
21 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/filesystem/file_path_buffer.hpp
  3. *
  4. * Purpose: Contains the basic_file_path_buffer template class, and ANSI
  5. * and Unicode specialisations thereof.
  6. *
  7. * Created: 7th February 2002
  8. * Updated: 26th February 2011
  9. *
  10. * Thanks to: Pablo Aguilar for discovering the Borland weirdness which is now
  11. * addressed with the calc_path_max_() method.
  12. *
  13. * Home: http://stlsoft.org/
  14. *
  15. * Copyright (c) 2002-2011, Matthew Wilson and Synesis Software
  16. * All rights reserved.
  17. *
  18. * Redistribution and use in source and binary forms, with or without
  19. * modification, are permitted provided that the following conditions are met:
  20. *
  21. * - Redistributions of source code must retain the above copyright notice, this
  22. * list of conditions and the following disclaimer.
  23. * - Redistributions in binary form must reproduce the above copyright notice,
  24. * this list of conditions and the following disclaimer in the documentation
  25. * and/or other materials provided with the distribution.
  26. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  27. * any contributors may be used to endorse or promote products derived from
  28. * this software without specific prior written permission.
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  31. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  34. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  36. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  37. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  38. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  39. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGE.
  41. *
  42. * ////////////////////////////////////////////////////////////////////// */
  43. /** \file winstl/filesystem/file_path_buffer.hpp
  44. *
  45. * \brief [C++ only] Definition of the winstl::basic_file_path_buffer class
  46. * template
  47. * (\ref group__library__filesystem "File System" Library).
  48. */
  49. #ifndef WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER
  50. #define WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER
  51. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  52. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_MAJOR 4
  53. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_MINOR 4
  54. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_REVISION 2
  55. # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_EDIT 118
  56. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  57. /* /////////////////////////////////////////////////////////////////////////
  58. * Compatibility
  59. */
  60. /*
  61. [Incompatibilies-start]
  62. STLSOFT_COMPILER_IS_MSVC: _MSC_VER<1200
  63. [Incompatibilies-end]
  64. */
  65. /* /////////////////////////////////////////////////////////////////////////
  66. * Includes
  67. */
  68. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  69. # include <winstl/winstl.h>
  70. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  71. #define WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
  72. #if defined(STLSOFT_COMPILER_IS_MSVC)
  73. # if _MSC_VER < 1100
  74. # error winstl/filesystem/file_path_buffer.hpp is not compatible with Visual C++ prior to version 5.0
  75. # elif _MSC_VER < 1200
  76. # undef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
  77. # else /* ? _MSC_VER */
  78. /* Nothing to do */
  79. # endif /* _MSC_VER */
  80. #endif /* compiler */
  81. #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
  82. # include <stlsoft/shims/access/string.hpp>
  83. #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING */
  84. #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
  85. # ifndef STLSOFT_INCL_STLSOFT_HPP_MEMORY_AUTO_BUFFER
  86. # include <stlsoft/memory/auto_buffer.hpp>
  87. # endif /* !STLSOFT_INCL_STLSOFT_HPP_MEMORY_AUTO_BUFFER */
  88. #else /* ? WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  89. # include <vector>
  90. #endif /* WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  91. #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR
  92. # include <winstl/memory/processheap_allocator.hpp>
  93. #endif /* !WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR */
  94. #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_COPY_FUNCTIONS
  95. # include <stlsoft/string/copy_functions.hpp>
  96. #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_COPY_FUNCTIONS */
  97. /* /////////////////////////////////////////////////////////////////////////
  98. * Namespace
  99. */
  100. #ifndef _WINSTL_NO_NAMESPACE
  101. # if defined(_STLSOFT_NO_NAMESPACE) || \
  102. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  103. /* There is no stlsoft namespace, so must define ::winstl */
  104. namespace winstl
  105. {
  106. # else
  107. /* Define stlsoft::winstl_project */
  108. namespace stlsoft
  109. {
  110. namespace winstl_project
  111. {
  112. # endif /* _STLSOFT_NO_NAMESPACE */
  113. #endif /* !_WINSTL_NO_NAMESPACE */
  114. /* /////////////////////////////////////////////////////////////////////////
  115. * Classes
  116. */
  117. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  118. template <ss_typename_param_k C>
  119. struct is_ansi
  120. {
  121. enum { value = 0 };
  122. };
  123. STLSOFT_TEMPLATE_SPECIALISATION
  124. struct is_ansi<ws_char_a_t>
  125. {
  126. enum { value = 1 };
  127. };
  128. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  129. // class basic_file_path_buffer
  130. /** \brief Acts as a buffer with sufficient size for any drive on the host machine
  131. *
  132. * \ingroup group__library__filesystem
  133. *
  134. * This class is a non-template class primarily so that separate instantiations
  135. * are not created for each instantiation of the basic_file_path_buffer.
  136. *
  137. * This class provides a simple function, which is to provide the maximum path
  138. * length for the host. This information is then cached due to the static nature
  139. * of the get_drivesvar_() method, although it can be reset by calling the
  140. * refresh() method on the buffer class.
  141. *
  142. * \param C The character type
  143. * \param A The allocator type
  144. * \param CCH The size of the internal member path structure. On translators that support default template arguments this default to (\c 1 + \c WINSTL_CONST_MAX_PATH)
  145. */
  146. template< ss_typename_param_k C
  147. #ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
  148. , ss_typename_param_k A = processheap_allocator<C>
  149. #else /* ? STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
  150. , ss_typename_param_k A /* = processheap_allocator<C> */
  151. #endif /* STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
  152. >
  153. class basic_file_path_buffer
  154. {
  155. /// \name Member Constants
  156. /// @{
  157. private:
  158. enum
  159. {
  160. internalBufferSize = 1 + WINSTL_CONST_MAX_PATH
  161. };
  162. enum
  163. {
  164. CCH_9x = WINSTL_CONST_MAX_PATH
  165. , CCH_NT = (is_ansi<C>::value ? WINSTL_CONST_MAX_PATH : CONST_NT_MAX_PATH)
  166. };
  167. /// \brief The buffer type
  168. #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
  169. typedef stlsoft_ns_qual(auto_buffer)< C
  170. # if defined(STLSOFT_COMPILER_IS_BORLAND)
  171. // This is necessary, since Borland will attempt an auto_buffer with what
  172. // seems like 0 size, or maybe it just can't define the type. Who can tell?
  173. , 1 + WINSTL_CONST_MAX_PATH
  174. # else /* ? compiler */
  175. , internalBufferSize
  176. # endif /* compiler */
  177. , A
  178. > buffer_type;
  179. #else /* ? WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  180. typedef stlsoft_ns_qual_std(vector)<C> buffer_type;
  181. #endif /* WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  182. /// @}
  183. /// \name Member Types
  184. /// @{
  185. public:
  186. /// \brief The character type
  187. typedef C char_type;
  188. /// \brief The allocator type
  189. typedef A allocator_type;
  190. /// \brief The current parameterisation of the type
  191. typedef basic_file_path_buffer<C, A> class_type;
  192. /// \brief The value type
  193. typedef ss_typename_type_k buffer_type::value_type value_type;
  194. /// \brief The reference type
  195. typedef value_type& reference;
  196. /// \brief The non-mutating (const) reference type
  197. typedef value_type const& const_reference;
  198. /// \brief The size type
  199. typedef ss_typename_type_k buffer_type::size_type size_type;
  200. /// @}
  201. /// \name Construction
  202. /// @{
  203. public:
  204. /// \brief Default constructor
  205. basic_file_path_buffer()
  206. : m_buffer(1 + calc_path_max_())
  207. {
  208. #ifdef _DEBUG
  209. ::memset(&m_buffer[0], '?', m_buffer.size());
  210. m_buffer[m_buffer.size() - 1] = '\0';
  211. #endif /* _DEBUG */
  212. }
  213. /// \brief Copy constructor
  214. basic_file_path_buffer(class_type const& rhs)
  215. : m_buffer(rhs.size())
  216. {
  217. stlsoft_ns_qual(pod_copy_n)(data(), rhs.data(), m_buffer.size());
  218. }
  219. /// \brief Copy assignment operator
  220. class_type& operator =(class_type const& rhs)
  221. {
  222. m_buffer.resize(rhs.size());
  223. stlsoft_ns_qual(pod_copy_n)(data(), rhs.data(), m_buffer.size());
  224. return *this;
  225. }
  226. /// @}
  227. /// \name Operations
  228. /// @{
  229. public:
  230. /// \brief Swaps the contents with those of another instance
  231. ///
  232. /// \param rhs The instance whose contents will be swapped with the
  233. /// callee
  234. ///
  235. /// \note The complexity of this operation is not guaranteed
  236. /// to be constant-time. See the documentation for
  237. /// \link stlsoft::auto_buffer auto_buffer\endlink for
  238. /// further details.
  239. void swap(class_type& rhs) stlsoft_throw_0()
  240. {
  241. m_buffer.swap(rhs.m_buffer);
  242. }
  243. /// @}
  244. /// \name Accessors
  245. /// @{
  246. public:
  247. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  248. value_type const* data() const
  249. {
  250. #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
  251. return m_buffer.data();
  252. #else /* ? WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  253. return &m_buffer[0];
  254. #endif /* WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  255. }
  256. value_type* data()
  257. {
  258. #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
  259. return m_buffer.data();
  260. #else /* ? WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  261. return &m_buffer[0];
  262. #endif /* WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER */
  263. }
  264. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  265. /// \brief Returns a pointer to a nul-terminated string
  266. value_type const* c_str() const
  267. {
  268. return this->data();
  269. }
  270. /// \brief Returns a mutable (non-const) pointer to the internal buffer
  271. reference operator [](ws_size_t index)
  272. {
  273. buffer_type& this_ = m_buffer;
  274. return this_[index];
  275. }
  276. #if !defined(STLSOFT_COMPILER_IS_COMO) || \
  277. __COMO_VERSION__ >= 4303
  278. /// \brief Returns a non-mutable (const) pointer to the internal buffer
  279. const_reference operator [](ws_size_t index) const
  280. {
  281. WINSTL_MESSAGE_ASSERT("Index out of range", !(size() < index));
  282. return data()[index];
  283. }
  284. #else /* ? compiler */
  285. #endif /* compiler */
  286. /// \brief Returns the size of the internal buffer
  287. size_type size() const
  288. {
  289. return m_buffer.size();
  290. }
  291. /// \brief Returns the maximum size of the internal buffer
  292. static size_type max_size()
  293. {
  294. return calc_path_max_();
  295. }
  296. /// \brief Copies the contents into a caller supplied buffer
  297. ///
  298. /// \param buffer Pointer to character buffer to receive the contents.
  299. /// May be NULL, in which case the method returns size().
  300. /// \param cchBuffer Number of characters of available space in \c buffer.
  301. size_type copy(char_type *buffer, size_type cchBuffer) const
  302. {
  303. return stlsoft_ns_qual(copy_contents)(buffer, cchBuffer, m_buffer.data(), m_buffer.size());
  304. }
  305. /// @}
  306. /// \name Operations
  307. /// @{
  308. public:
  309. /// \brief Causes the drives to be examined again for the next instance.
  310. ///
  311. /// \deprecated
  312. static void refresh() stlsoft_throw_0()
  313. {}
  314. /// @}
  315. /// \name Implementation
  316. /// @{
  317. private:
  318. // Have to do it this way, as an inline, in-MIL tertiary operator causes
  319. // Borland C++ to think that the answer's 5! 'tis a mysterious beastie,
  320. // the old Borland compiler, is it not?
  321. static size_type calc_path_max_()
  322. {
  323. size_type n;
  324. if(::GetVersion() & 0x80000000)
  325. {
  326. n = CCH_9x;
  327. }
  328. else
  329. {
  330. n = CCH_NT;
  331. }
  332. return n;
  333. }
  334. /// @}
  335. /// \name Members
  336. /// @{
  337. private:
  338. buffer_type m_buffer;
  339. /// @}
  340. };
  341. /* Typedefs to commonly encountered types. */
  342. /** \brief Specialisation of the basic_file_path_buffer template for the ANSI character type \c char
  343. *
  344. * \ingroup group__library__filesystem
  345. */
  346. typedef basic_file_path_buffer<ws_char_a_t, processheap_allocator<ws_char_a_t> > file_path_buffer_a;
  347. /** \brief Specialisation of the basic_file_path_buffer template for the Unicode character type \c wchar_t
  348. *
  349. * \ingroup group__library__filesystem
  350. */
  351. typedef basic_file_path_buffer<ws_char_w_t, processheap_allocator<ws_char_w_t> > file_path_buffer_w;
  352. /** \brief Specialisation of the basic_file_path_buffer template for the ambeint character type \c TCHAR
  353. *
  354. * \ingroup group__library__filesystem
  355. */
  356. typedef basic_file_path_buffer<TCHAR, processheap_allocator<TCHAR> > file_path_buffer;
  357. /* /////////////////////////////////////////////////////////////////////////
  358. * Support for PlatformSTL redefinition by inheritance+namespace, for confused
  359. * compilers (e.g. VC++ 6)
  360. */
  361. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  362. template< ss_typename_param_k C
  363. #ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
  364. , ss_typename_param_k A = winstl_ns_qual(processheap_allocator)<C>
  365. #else /* ? STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
  366. , ss_typename_param_k A /* = processheap_allocator<C> */
  367. #endif /* STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
  368. >
  369. class basic_file_path_buffer__
  370. : public winstl_ns_qual(basic_file_path_buffer)<C, A>
  371. {
  372. private:
  373. typedef winstl_ns_qual(basic_file_path_buffer)<C, A> parent_class_type;
  374. public:
  375. typedef basic_file_path_buffer__<C, A> class_type;
  376. typedef ss_typename_type_k parent_class_type::value_type value_type;
  377. typedef ss_typename_type_k parent_class_type::reference reference;
  378. typedef ss_typename_type_k parent_class_type::const_reference const_reference;
  379. typedef ss_typename_type_k parent_class_type::size_type size_type;
  380. };
  381. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  382. /* /////////////////////////////////////////////////////////////////////////
  383. * swapping
  384. */
  385. template< ss_typename_param_k C
  386. , ss_typename_param_k A
  387. >
  388. inline void swap(basic_file_path_buffer<C, A>& lhs, basic_file_path_buffer<C, A>& rhs)
  389. {
  390. lhs.swap(rhs);
  391. }
  392. /* /////////////////////////////////////////////////////////////////////////
  393. * Shims
  394. */
  395. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  396. template <ss_typename_param_k A>
  397. inline ws_char_a_t const* c_str_data_a(winstl_ns_qual(basic_file_path_buffer)<ws_char_a_t, A> const& b)
  398. {
  399. return b.c_str();
  400. }
  401. template <ss_typename_param_k A>
  402. inline ws_char_w_t const* c_str_data_w(winstl_ns_qual(basic_file_path_buffer)<ws_char_w_t, A> const& b)
  403. {
  404. return b.c_str();
  405. }
  406. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  407. /** \brief \ref group__concept__shim__string_access__c_str_data for winstl::basic_file_path_buffer
  408. *
  409. * \ingroup group__concept__shim__string_access
  410. */
  411. template< ss_typename_param_k C
  412. , ss_typename_param_k A
  413. >
  414. inline C const* c_str_data(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
  415. {
  416. return b.c_str();
  417. }
  418. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  419. template <ss_typename_param_k A>
  420. inline ws_size_t c_str_len_a(winstl_ns_qual(basic_file_path_buffer)<ws_char_a_t, A> const& b)
  421. {
  422. return stlsoft_ns_qual(c_str_len_a)(b.c_str());
  423. }
  424. template <ss_typename_param_k A>
  425. inline ws_size_t c_str_len_w(winstl_ns_qual(basic_file_path_buffer)<ws_char_w_t, A> const& b)
  426. {
  427. return stlsoft_ns_qual(c_str_len_w)(b.c_str());
  428. }
  429. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  430. /** \brief \ref group__concept__shim__string_access__c_str_len for winstl::basic_file_path_buffer
  431. *
  432. * \ingroup group__concept__shim__string_access
  433. */
  434. template< ss_typename_param_k C
  435. , ss_typename_param_k A
  436. >
  437. inline ws_size_t c_str_len(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
  438. {
  439. return stlsoft_ns_qual(c_str_len)(b.c_str());
  440. }
  441. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  442. template <ss_typename_param_k A>
  443. inline ws_char_a_t const* c_str_ptr_a(winstl_ns_qual(basic_file_path_buffer)<ws_char_a_t, A> const& b)
  444. {
  445. return b.c_str();
  446. }
  447. template <ss_typename_param_k A>
  448. inline ws_char_w_t const* c_str_ptr_w(winstl_ns_qual(basic_file_path_buffer)<ws_char_w_t, A> const& b)
  449. {
  450. return b.c_str();
  451. }
  452. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  453. /** \brief \ref group__concept__shim__string_access__c_str_ptr for winstl::basic_file_path_buffer
  454. *
  455. * \ingroup group__concept__shim__string_access
  456. */
  457. template< ss_typename_param_k C
  458. , ss_typename_param_k A
  459. >
  460. inline C const* c_str_ptr(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
  461. {
  462. return b.c_str();
  463. }
  464. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  465. template <ss_typename_param_k A>
  466. inline ws_char_a_t const* c_str_ptr_null_a(winstl_ns_qual(basic_file_path_buffer)<ws_char_a_t, A> const& b)
  467. {
  468. return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
  469. }
  470. template <ss_typename_param_k A>
  471. inline ws_char_w_t const* c_str_ptr_null_w(winstl_ns_qual(basic_file_path_buffer)<ws_char_w_t, A> const& b)
  472. {
  473. return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
  474. }
  475. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  476. /** \brief \ref group__concept__shim__string_access__c_str_ptr_null for winstl::basic_file_path_buffer
  477. *
  478. * \ingroup group__concept__shim__string_access
  479. */
  480. template< ss_typename_param_k C
  481. , ss_typename_param_k A
  482. >
  483. inline C const* c_str_ptr_null(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
  484. {
  485. return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
  486. }
  487. /** \brief \ref group__concept__shim__stream_insertion "stream insertion shim" for winstl::basic_file_path_buffer
  488. *
  489. * \ingroup group__concept__shim__stream_insertion
  490. */
  491. template< ss_typename_param_k S
  492. , ss_typename_param_k C
  493. , ss_typename_param_k A
  494. >
  495. inline S& operator <<(S& s, winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
  496. {
  497. s << b.c_str();
  498. return s;
  499. }
  500. /* /////////////////////////////////////////////////////////////////////////
  501. * Unit-testing
  502. */
  503. #ifdef STLSOFT_UNITTEST
  504. # include "./unittest/file_path_buffer_unittest_.h"
  505. #endif /* STLSOFT_UNITTEST */
  506. /* ////////////////////////////////////////////////////////////////////// */
  507. #ifndef _WINSTL_NO_NAMESPACE
  508. # if defined(_STLSOFT_NO_NAMESPACE) || \
  509. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  510. } // namespace winstl
  511. # else
  512. } // namespace winstl_project
  513. } // namespace stlsoft
  514. # endif /* _STLSOFT_NO_NAMESPACE */
  515. #endif /* !_WINSTL_NO_NAMESPACE */
  516. /* In the special case of Intel behaving as VC++ 7.0 or earlier on Win32, we
  517. * illegally insert into the std namespace.
  518. */
  519. #if defined(STLSOFT_CF_std_NAMESPACE)
  520. # if ( ( defined(STLSOFT_COMPILER_IS_INTEL) && \
  521. defined(_MSC_VER))) && \
  522. _MSC_VER < 1310
  523. namespace std
  524. {
  525. template< ss_typename_param_k C
  526. , ss_typename_param_k A
  527. >
  528. inline void swap(winstl_ns_qual(basic_file_path_buffer)<C, A>& lhs, winstl_ns_qual(basic_file_path_buffer)<C, A>& rhs)
  529. {
  530. lhs.swap(rhs);
  531. }
  532. } // namespace std
  533. # endif /* INTEL && _MSC_VER < 1310 */
  534. #endif /* STLSOFT_CF_std_NAMESPACE */
  535. /* /////////////////////////////////////////////////////////////////////////
  536. * Namespace
  537. *
  538. * The string access shims exist either in the stlsoft namespace, or in the
  539. * global namespace. This is required by the lookup rules.
  540. *
  541. */
  542. #ifndef _WINSTL_NO_NAMESPACE
  543. # if !defined(_STLSOFT_NO_NAMESPACE) && \
  544. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  545. namespace stlsoft
  546. {
  547. # else /* ? _STLSOFT_NO_NAMESPACE */
  548. /* There is no stlsoft namespace, so must define in the global namespace */
  549. # endif /* !_STLSOFT_NO_NAMESPACE */
  550. using ::winstl::c_str_ptr_null;
  551. using ::winstl::c_str_ptr_null_a;
  552. using ::winstl::c_str_ptr_null_w;
  553. using ::winstl::c_str_ptr;
  554. using ::winstl::c_str_ptr_a;
  555. using ::winstl::c_str_ptr_w;
  556. using ::winstl::c_str_data;
  557. using ::winstl::c_str_data_a;
  558. using ::winstl::c_str_data_w;
  559. using ::winstl::c_str_len;
  560. # if !defined(_STLSOFT_NO_NAMESPACE) && \
  561. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  562. } // namespace stlsoft
  563. # else /* ? _STLSOFT_NO_NAMESPACE */
  564. /* There is no stlsoft namespace, so must define in the global namespace */
  565. # endif /* !_STLSOFT_NO_NAMESPACE */
  566. #endif /* !_WINSTL_NO_NAMESPACE */
  567. /* ////////////////////////////////////////////////////////////////////// */
  568. #endif /* WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER */
  569. /* ///////////////////////////// end of file //////////////////////////// */