📄 file_path_buffer.hpp
字号:
}
#if !defined(STLSOFT_COMPILER_IS_COMO) || \
__COMO_VERSION__ >= 4303
/// \brief Returns a non-mutable (const) pointer to the internal buffer
const_reference operator [](size_t index) const
{
WINSTL_MESSAGE_ASSERT("Index out of range", !(size() < index));
return data()[index];
}
#else /* ? compiler */
#endif /* compiler */
/// \brief Returns the size of the internal buffer
size_type size() const
{
return m_buffer.size();
}
/// \brief Copies the contents into a caller supplied buffer
///
/// \param buffer Pointer to character buffer to receive the contents.
/// May be NULL, in which case the method returns size().
/// \param cchBuffer Number of characters of available space in \c buffer.
size_type copy(char_type *buffer, size_type cchBuffer) const
{
return stlsoft_ns_qual(copy_contents)(buffer, cchBuffer, m_buffer.data(), m_buffer.size());
}
/// @}
/// \name Operations
/// @{
public:
/// \brief Causes the drives to be examined again for the next instance.
///
/// \deprecated
static void refresh() stlsoft_throw_0()
{}
/// @}
/// \name Implementation
/// @{
private:
// Have to do it this way, as an inline, in-MIL tertiary operator causes
// Borland C++ to think that the answer's 5! 'tis a mysterious beastie,
// the old Borland compiler, is it not?
static size_type calc_path_max_()
{
size_type n;
if(::GetVersion() & 0x80000000)
{
n = CCH_9x;
}
else
{
n = CCH_NT;
}
return n;
}
/// @}
/// \name Members
/// @{
private:
buffer_type m_buffer;
/// @}
};
/* Typedefs to commonly encountered types. */
/// Instantiation of the basic_file_path_buffer template for the ANSI character type \c char
typedef basic_file_path_buffer<ws_char_a_t, processheap_allocator<ws_char_a_t> > file_path_buffer_a;
/// Instantiation of the basic_file_path_buffer template for the Unicode character type \c wchar_t
typedef basic_file_path_buffer<ws_char_w_t, processheap_allocator<ws_char_w_t> > file_path_buffer_w;
/// Instantiation of the basic_file_path_buffer template for the ambeint character type \c TCHAR
typedef basic_file_path_buffer<TCHAR, processheap_allocator<TCHAR> > file_path_buffer;
/* /////////////////////////////////////////////////////////////////////////
* Support for PlatformSTL redefinition by inheritance+namespace, for confused
* compilers (e.g. VC++ 6)
*/
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
template< ss_typename_param_k C
#ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
, ss_typename_param_k A = winstl_ns_qual(processheap_allocator)<C>
#else /* ? STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
, ss_typename_param_k A /* = processheap_allocator<C> */
#endif /* STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
>
class basic_file_path_buffer__
: public winstl_ns_qual(basic_file_path_buffer)<C, A>
{
private:
typedef winstl_ns_qual(basic_file_path_buffer)<C, A> parent_class_type;
public:
typedef basic_file_path_buffer__<C, A> class_type;
typedef ss_typename_type_k parent_class_type::value_type value_type;
typedef ss_typename_type_k parent_class_type::reference reference;
typedef ss_typename_type_k parent_class_type::const_reference const_reference;
typedef ss_typename_type_k parent_class_type::size_type size_type;
};
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////
* swapping
*/
template< ss_typename_param_k C
, ss_typename_param_k A
>
inline void swap(basic_file_path_buffer<C, A> &lhs, basic_file_path_buffer<C, A> &rhs)
{
lhs.swap(rhs);
}
/* /////////////////////////////////////////////////////////////////////////
* Shims
*/
template< ss_typename_param_k C
, ss_typename_param_k A
>
inline C const *c_str_ptr_null(basic_file_path_buffer<C, A> const &b)
{
return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
}
template< ss_typename_param_k A
>
inline ws_char_a_t const *c_str_ptr_null_a(basic_file_path_buffer<ws_char_a_t, A> const &b)
{
return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
}
template< ss_typename_param_k A
>
inline ws_char_w_t const *c_str_ptr_null_w(basic_file_path_buffer<ws_char_w_t, A> const &b)
{
return stlsoft_ns_qual(c_str_ptr_null)(b.c_str());
}
template< ss_typename_param_k C
, ss_typename_param_k A
>
inline C const *c_str_ptr(basic_file_path_buffer<C, A> const &b)
{
return b.c_str();
}
template< ss_typename_param_k A
>
inline ws_char_a_t const *c_str_ptr_a(basic_file_path_buffer<ws_char_a_t, A> const &b)
{
return b.c_str();
}
template< ss_typename_param_k A
>
inline ws_char_w_t const *c_str_ptr_w(basic_file_path_buffer<ws_char_w_t, A> const &b)
{
return b.c_str();
}
template< ss_typename_param_k C
, ss_typename_param_k A
>
inline C const *c_str_data(basic_file_path_buffer<C, A> const &b)
{
return b.c_str();
}
template< ss_typename_param_k A
>
inline ws_char_a_t const *c_str_data_a(basic_file_path_buffer<ws_char_a_t, A> const &b)
{
return b.c_str();
}
template< ss_typename_param_k A
>
inline ws_char_w_t const *c_str_data_w(basic_file_path_buffer<ws_char_w_t, A> const &b)
{
return b.c_str();
}
template< ss_typename_param_k C
, ss_typename_param_k A
>
inline ws_size_t c_str_len(basic_file_path_buffer<C, A> const &b)
{
return stlsoft_ns_qual(c_str_len)(b.c_str());
}
#if 0
template< ss_typename_param_k C
, ss_typename_param_k A
>
inline ws_size_t c_str_size(basic_file_path_buffer<C, A> const &b)
{
return stlsoft_ns_qual(c_str_size)(b.c_str());
}
#endif /* 0 */
template< ss_typename_param_k S
, ss_typename_param_k C
, ss_typename_param_k A
>
inline S &operator <<(S & s, basic_file_path_buffer<C, A> const &b)
{
s << b.c_str();
return s;
}
/* /////////////////////////////////////////////////////////////////////////
* Unit-testing
*/
#ifdef STLSOFT_UNITTEST
# include "./unittest/file_path_buffer_unittest_.h"
#endif /* STLSOFT_UNITTEST */
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _WINSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace winstl
# else
} // namespace winstl_project
} // namespace stlsoft
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
/* In the special case of Intel behaving as VC++ 7.0 or earlier on Win32, we
* illegally insert into the std namespace.
*/
#if defined(STLSOFT_CF_std_NAMESPACE)
# if ( ( defined(STLSOFT_COMPILER_IS_INTEL) && \
defined(_MSC_VER))) && \
_MSC_VER < 1310
namespace std
{
template< ss_typename_param_k C
, ss_typename_param_k A
>
inline void swap(winstl_ns_qual(basic_file_path_buffer)<C, A> &lhs, winstl_ns_qual(basic_file_path_buffer)<C, A> &rhs)
{
lhs.swap(rhs);
}
} // namespace std
# endif /* INTEL && _MSC_VER < 1310 */
#endif /* STLSOFT_CF_std_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*
* The string access shims exist either in the stlsoft namespace, or in the
* global namespace. This is required by the lookup rules.
*
*/
#ifndef _WINSTL_NO_NAMESPACE
# if !defined(_STLSOFT_NO_NAMESPACE) && \
!defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
namespace stlsoft
{
# else /* ? _STLSOFT_NO_NAMESPACE */
/* There is no stlsoft namespace, so must define in the global namespace */
# endif /* !_STLSOFT_NO_NAMESPACE */
using ::winstl::c_str_ptr_null;
using ::winstl::c_str_ptr_null_a;
using ::winstl::c_str_ptr_null_w;
using ::winstl::c_str_ptr;
using ::winstl::c_str_ptr_a;
using ::winstl::c_str_ptr_w;
using ::winstl::c_str_data;
using ::winstl::c_str_data_a;
using ::winstl::c_str_data_w;
using ::winstl::c_str_len;
#if 0
using ::winstl::c_str_size;
#endif /* 0 */
# if !defined(_STLSOFT_NO_NAMESPACE) && \
!defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace stlsoft
# else /* ? _STLSOFT_NO_NAMESPACE */
/* There is no stlsoft namespace, so must define in the global namespace */
# endif /* !_STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -