00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00052 #ifndef WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER
00053 #define WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER
00054
00055 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00056 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_MAJOR 4
00057 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_MINOR 4
00058 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_REVISION 2
00059 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER_EDIT 117
00060 #endif
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00077 # include <winstl/winstl.h>
00078 #endif
00079
00080 #define WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
00081
00082 #if defined(STLSOFT_COMPILER_IS_MSVC)
00083 # if _MSC_VER < 1100
00084 # error winstl/filesystem/file_path_buffer.hpp is not compatible with Visual C++ prior to version 5.0
00085 # elif _MSC_VER < 1200
00086 # undef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
00087 # else
00088
00089 # endif
00090 #endif
00091
00092 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00093 # include <stlsoft/shims/access/string.hpp>
00094 #endif
00095 #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
00096 # ifndef STLSOFT_INCL_STLSOFT_HPP_MEMORY_AUTO_BUFFER
00097 # include <stlsoft/memory/auto_buffer.hpp>
00098 # endif
00099 #else
00100 # include <vector>
00101 #endif
00102 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR
00103 # include <winstl/memory/processheap_allocator.hpp>
00104 #endif
00105 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_COPY_FUNCTIONS
00106 # include <stlsoft/string/copy_functions.hpp>
00107 #endif
00108
00109
00110
00111
00112
00113 #ifndef _WINSTL_NO_NAMESPACE
00114 # if defined(_STLSOFT_NO_NAMESPACE) || \
00115 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00116
00117 namespace winstl
00118 {
00119 # else
00120
00121
00122 namespace stlsoft
00123 {
00124
00125 namespace winstl_project
00126 {
00127
00128 # endif
00129 #endif
00130
00131
00132
00133
00134
00135 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00136 template <ss_typename_param_k C>
00137 struct is_ansi
00138 {
00139 enum { value = 0 };
00140 };
00141
00142 STLSOFT_TEMPLATE_SPECIALISATION
00143 struct is_ansi<ws_char_a_t>
00144 {
00145 enum { value = 1 };
00146 };
00147 #endif
00148
00149
00166 template< ss_typename_param_k C
00167 #ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00168 , ss_typename_param_k A = processheap_allocator<C>
00169 #else
00170 , ss_typename_param_k A
00171 #endif
00172 >
00173 class basic_file_path_buffer
00174 {
00177 private:
00178 enum
00179 {
00180 internalBufferSize = 1 + WINSTL_CONST_MAX_PATH
00181 };
00182
00183 enum
00184 {
00185 CCH_9x = WINSTL_CONST_MAX_PATH
00186 , CCH_NT = (is_ansi<C>::value ? WINSTL_CONST_MAX_PATH : CONST_NT_MAX_PATH)
00187 };
00188
00190 #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
00191 typedef stlsoft_ns_qual(auto_buffer)< C
00192 # if defined(STLSOFT_COMPILER_IS_BORLAND)
00193
00194
00195 , 1 + WINSTL_CONST_MAX_PATH
00196 # else
00197 , internalBufferSize
00198 # endif
00199 , A
00200 > buffer_type;
00201 #else
00202 typedef stlsoft_ns_qual_std(vector)<C> buffer_type;
00203 #endif
00205
00208 public:
00210 typedef C char_type;
00212 typedef A allocator_type;
00214 typedef basic_file_path_buffer<C, A> class_type;
00216 typedef ss_typename_type_k buffer_type::value_type value_type;
00218 typedef value_type& reference;
00220 typedef value_type const& const_reference;
00222 typedef ss_typename_type_k buffer_type::size_type size_type;
00224
00227 public:
00229 basic_file_path_buffer()
00230 : m_buffer(1 + calc_path_max_())
00231 {
00232 #ifdef _DEBUG
00233 ::memset(&m_buffer[0], '?', m_buffer.size());
00234 m_buffer[m_buffer.size() - 1] = '\0';
00235 #endif
00236 }
00238 basic_file_path_buffer(class_type const& rhs)
00239 : m_buffer(rhs.size())
00240 {
00241 stlsoft_ns_qual(pod_copy_n)(data(), rhs.data(), m_buffer.size());
00242 }
00244 class_type& operator =(class_type const& rhs)
00245 {
00246 m_buffer.resize(rhs.size());
00247 stlsoft_ns_qual(pod_copy_n)(data(), rhs.data(), m_buffer.size());
00248
00249 return *this;
00250 }
00252
00255 public:
00265 void swap(class_type& rhs) stlsoft_throw_0()
00266 {
00267 m_buffer.swap(rhs.m_buffer);
00268 }
00270
00273 public:
00274 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00275 value_type const *data() const
00276 {
00277 #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
00278 return m_buffer.data();
00279 #else
00280 return &m_buffer[0];
00281 #endif
00282 }
00283 value_type *data()
00284 {
00285 #ifdef WINSTL_FILE_PATH_BUFFER_USE_AUTO_BUFFER
00286 return m_buffer.data();
00287 #else
00288 return &m_buffer[0];
00289 #endif
00290 }
00291 #endif
00292
00294 value_type const* c_str() const
00295 {
00296 return this->data();
00297 }
00298
00300 reference operator [](ws_size_t index)
00301 {
00302 buffer_type &this_ = m_buffer;
00303
00304 return this_[index];
00305 }
00306 #if !defined(STLSOFT_COMPILER_IS_COMO) || \
00307 __COMO_VERSION__ >= 4303
00309 const_reference operator [](ws_size_t index) const
00310 {
00311 WINSTL_MESSAGE_ASSERT("Index out of range", !(size() < index));
00312
00313 return data()[index];
00314 }
00315 #else
00316 #endif
00317
00319 size_type size() const
00320 {
00321 return m_buffer.size();
00322 }
00323
00325 static size_type max_size()
00326 {
00327 return calc_path_max_();
00328 }
00329
00335 size_type copy(char_type *buffer, size_type cchBuffer) const
00336 {
00337 return stlsoft_ns_qual(copy_contents)(buffer, cchBuffer, m_buffer.data(), m_buffer.size());
00338 }
00340
00343 public:
00347 static void refresh() stlsoft_throw_0()
00348 {}
00350
00353 private:
00354
00355
00356
00357 static size_type calc_path_max_()
00358 {
00359 size_type n;
00360
00361 if(::GetVersion() & 0x80000000)
00362 {
00363 n = CCH_9x;
00364 }
00365 else
00366 {
00367 n = CCH_NT;
00368 }
00369
00370 return n;
00371 }
00373
00376 private:
00377 buffer_type m_buffer;
00379 };
00380
00381
00386 typedef basic_file_path_buffer<ws_char_a_t, processheap_allocator<ws_char_a_t> > file_path_buffer_a;
00391 typedef basic_file_path_buffer<ws_char_w_t, processheap_allocator<ws_char_w_t> > file_path_buffer_w;
00396 typedef basic_file_path_buffer<TCHAR, processheap_allocator<TCHAR> > file_path_buffer;
00397
00398
00399
00400
00401
00402
00403 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00404
00405 template< ss_typename_param_k C
00406 #ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00407 , ss_typename_param_k A = winstl_ns_qual(processheap_allocator)<C>
00408 #else
00409 , ss_typename_param_k A
00410 #endif
00411 >
00412 class basic_file_path_buffer__
00413 : public winstl_ns_qual(basic_file_path_buffer)<C, A>
00414 {
00415 private:
00416 typedef winstl_ns_qual(basic_file_path_buffer)<C, A> parent_class_type;
00417 public:
00418 typedef basic_file_path_buffer__<C, A> class_type;
00419 typedef ss_typename_type_k parent_class_type::value_type value_type;
00420 typedef ss_typename_type_k parent_class_type::reference reference;
00421 typedef ss_typename_type_k parent_class_type::const_reference const_reference;
00422 typedef ss_typename_type_k parent_class_type::size_type size_type;
00423 };
00424
00425 #endif
00426
00427
00428
00429
00430
00431 template< ss_typename_param_k C
00432 , ss_typename_param_k A
00433 >
00434 inline void swap(basic_file_path_buffer<C, A>& lhs, basic_file_path_buffer<C, A>& rhs)
00435 {
00436 lhs.swap(rhs);
00437 }
00438
00439
00440
00441
00442
00443 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00444
00445 template <ss_typename_param_k A>
00446 inline ws_char_a_t const* c_str_data_a(winstl_ns_qual(basic_file_path_buffer)<ws_char_a_t, A> const& b)
00447 {
00448 return b.c_str();
00449 }
00450 template <ss_typename_param_k A>
00451 inline ws_char_w_t const* c_str_data_w(winstl_ns_qual(basic_file_path_buffer)<ws_char_w_t, A> const& b)
00452 {
00453 return b.c_str();
00454 }
00455
00456 #endif
00457
00462 template< ss_typename_param_k C
00463 , ss_typename_param_k A
00464 >
00465 inline C const* c_str_data(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
00466 {
00467 return b.c_str();
00468 }
00469
00470
00471 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00472
00473 template <ss_typename_param_k A>
00474 inline ws_size_t c_str_len_a(winstl_ns_qual(basic_file_path_buffer)<ws_char_a_t, A> const& b)
00475 {
00476 return stlsoft_ns_qual(c_str_len_a)(b.c_str());
00477 }
00478 template <ss_typename_param_k A>
00479 inline ws_size_t c_str_len_w(winstl_ns_qual(basic_file_path_buffer)<ws_char_w_t, A> const& b)
00480 {
00481 return stlsoft_ns_qual(c_str_len_w)(b.c_str());
00482 }
00483
00484 #endif
00485
00490 template< ss_typename_param_k C
00491 , ss_typename_param_k A
00492 >
00493 inline ws_size_t c_str_len(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
00494 {
00495 return stlsoft_ns_qual(c_str_len)(b.c_str());
00496 }
00497
00498
00499 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00500
00501 template <ss_typename_param_k A>
00502 inline ws_char_a_t const* c_str_ptr_a(winstl_ns_qual(basic_file_path_buffer)<ws_char_a_t, A> const& b)
00503 {
00504 return b.c_str();
00505 }
00506 template <ss_typename_param_k A>
00507 inline ws_char_w_t const* c_str_ptr_w(winstl_ns_qual(basic_file_path_buffer)<ws_char_w_t, A> const& b)
00508 {
00509 return b.c_str();
00510 }
00511
00512 #endif
00513
00518 template< ss_typename_param_k C
00519 , ss_typename_param_k A
00520 >
00521 inline C const* c_str_ptr(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
00522 {
00523 return b.c_str();
00524 }
00525
00526
00527
00528 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00529
00530 template <ss_typename_param_k A>
00531 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)
00532 {
00533 return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
00534 }
00535 template <ss_typename_param_k A>
00536 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)
00537 {
00538 return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
00539 }
00540
00541 #endif
00542
00547 template< ss_typename_param_k C
00548 , ss_typename_param_k A
00549 >
00550 inline C const* c_str_ptr_null(winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
00551 {
00552 return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
00553 }
00554
00555
00556
00557
00562 template< ss_typename_param_k S
00563 , ss_typename_param_k C
00564 , ss_typename_param_k A
00565 >
00566 inline S& operator <<(S& s, winstl_ns_qual(basic_file_path_buffer)<C, A> const& b)
00567 {
00568 s << b.c_str();
00569
00570 return s;
00571 }
00572
00573
00574
00575
00576
00577 #ifdef STLSOFT_UNITTEST
00578 # include "./unittest/file_path_buffer_unittest_.h"
00579 #endif
00580
00581
00582
00583 #ifndef _WINSTL_NO_NAMESPACE
00584 # if defined(_STLSOFT_NO_NAMESPACE) || \
00585 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00586 }
00587 # else
00588 }
00589 }
00590 # endif
00591 #endif
00592
00593
00594
00595
00596 #if defined(STLSOFT_CF_std_NAMESPACE)
00597 # if ( ( defined(STLSOFT_COMPILER_IS_INTEL) && \
00598 defined(_MSC_VER))) && \
00599 _MSC_VER < 1310
00600 namespace std
00601 {
00602 template< ss_typename_param_k C
00603 , ss_typename_param_k A
00604 >
00605 inline void swap(winstl_ns_qual(basic_file_path_buffer)<C, A>& lhs, winstl_ns_qual(basic_file_path_buffer)<C, A>& rhs)
00606 {
00607 lhs.swap(rhs);
00608 }
00609 }
00610 # endif
00611 #endif
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621 #ifndef _WINSTL_NO_NAMESPACE
00622 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00623 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00624 namespace stlsoft
00625 {
00626 # else
00627
00628 # endif
00629
00630 using ::winstl::c_str_ptr_null;
00631 using ::winstl::c_str_ptr_null_a;
00632 using ::winstl::c_str_ptr_null_w;
00633
00634 using ::winstl::c_str_ptr;
00635 using ::winstl::c_str_ptr_a;
00636 using ::winstl::c_str_ptr_w;
00637
00638 using ::winstl::c_str_data;
00639 using ::winstl::c_str_data_a;
00640 using ::winstl::c_str_data_w;
00641
00642 using ::winstl::c_str_len;
00643
00644 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00645 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00646 }
00647 # else
00648
00649 # endif
00650 #endif
00651
00652
00653
00654 #endif
00655
00656