📄 time.hpp
字号:
return c_str_data_w(t.st, ws_false_v);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_data(UDATE const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr(t.st, bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_data(UDATE const& t)
{
return c_str_data(t.st, ws_false_v);
}
#endif /* WINSTL_UDATE_DEFINED */
/* /////////////////////////////////////////////////////////////////////////
* c_str_ptr_null
*/
// SYSTEMTIME
inline stlsoft_ns_qual(basic_shim_string)<ws_char_a_t> c_str_ptr_null_a(SYSTEMTIME const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_a(t, bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_a_t> c_str_ptr_null_a(SYSTEMTIME const& t)
{
return c_str_ptr_null_a(t, ws_false_v);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_w_t> c_str_ptr_null_w(SYSTEMTIME const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_w(t, bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_w_t> c_str_ptr_null_w(SYSTEMTIME const& t)
{
return c_str_ptr_null_w(t, ws_false_v);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_ptr_null(SYSTEMTIME const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr(t, bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_ptr_null(SYSTEMTIME const& t)
{
return c_str_ptr_null(t, ws_false_v);
}
// FILETIME
inline stlsoft_ns_qual(basic_shim_string)<ws_char_a_t> c_str_ptr_null_a(FILETIME const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_null_a(FILETIME2SYSTEMTIME(t), bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_a_t> c_str_ptr_null_a(FILETIME const& t)
{
return c_str_ptr_null_a(FILETIME2SYSTEMTIME(t), ws_false_v);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_w_t> c_str_ptr_null_w(FILETIME const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_null_w(FILETIME2SYSTEMTIME(t), bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_w_t> c_str_ptr_null_w(FILETIME const& t)
{
return c_str_ptr_null_w(FILETIME2SYSTEMTIME(t), ws_false_v);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_ptr_null(FILETIME const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_null(FILETIME2SYSTEMTIME(t), bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_ptr_null(FILETIME const& t)
{
return c_str_ptr_null(FILETIME2SYSTEMTIME(t), ws_false_v);
}
// UDATE
#ifdef WINSTL_UDATE_DEFINED
inline stlsoft_ns_qual(basic_shim_string)<ws_char_a_t> c_str_ptr_null_a(UDATE const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_null_a(t.st, bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_a_t> c_str_ptr_null_a(UDATE const& t)
{
return c_str_ptr_null_a(t.st, ws_false_v);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_w_t> c_str_ptr_null_w(UDATE const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_null_w(t.st, bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<ws_char_w_t> c_str_ptr_null_w(UDATE const& t)
{
return c_str_ptr_null_w(t.st, ws_false_v);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_ptr_null(UDATE const& t, ws_bool_t bMilliseconds)
{
return c_str_ptr_null(t.st, bMilliseconds);
}
inline stlsoft_ns_qual(basic_shim_string)<TCHAR> c_str_ptr_null(UDATE const& t)
{
return c_str_ptr_null(t.st, ws_false_v);
}
#endif /* WINSTL_UDATE_DEFINED */
/* /////////////////////////////////////////////////////////////////////////
* c_str_len
*
* NOTE: The following are provided as function overloads, rather than, as
* originally implemented, with defaulted bMilliseconds argument, because
* DMC++ gives "ambiguous reference to symbol" errors. (And I didn't have
* time to investigate further.)
*/
// SYSTEMTIME
inline ws_size_t c_str_len_a(SYSTEMTIME const& t, ws_bool_t bMilliseconds)
{
int (STLSOFT_STDCALL *pfnGetTimeFormatA)( LCID Locale // locale
, DWORD dwFlags // options
, CONST SYSTEMTIME *lpTime // time
, ws_char_a_t const *lpFormat // time format string
, ws_char_a_t *lpTimeStr // formatted string buffer
, int cchTime) // size of string buffer
= bMilliseconds ? GetTimeFormat_msA : ::GetTimeFormatA;
const int cchDate = ::GetDateFormatA(LOCALE_USER_DEFAULT, 0, &t, NULL, NULL, 0);
const int cchTime = pfnGetTimeFormatA(LOCALE_USER_DEFAULT, 0, &t, NULL, NULL, 0);
const ws_size_t cchTotal = static_cast<ws_size_t>((cchDate - 1) + 1 + (cchTime - 1)); // GetDateFormat() + space + GetTimeFormat() (subtracting 1 for terminating NUL in each count returned)
return cchTotal;
}
inline ws_size_t c_str_len_a(SYSTEMTIME const& t)
{
return c_str_len_a(t, ws_false_v);
}
inline ws_size_t c_str_len_w(SYSTEMTIME const& t, ws_bool_t bMilliseconds)
{
int (STLSOFT_STDCALL *pfnGetTimeFormatW)( LCID Locale // locale
, DWORD dwFlags // options
, CONST SYSTEMTIME *lpTime // time
, ws_char_w_t const *lpFormat // time format string
, ws_char_w_t *lpTimeStr // formatted string buffer
, int cchTime) // size of string buffer
= bMilliseconds ? GetTimeFormat_msW : ::GetTimeFormatW;
const int cchDate = ::GetDateFormatW(LOCALE_USER_DEFAULT, 0, &t, NULL, NULL, 0);
const int cchTime = pfnGetTimeFormatW(LOCALE_USER_DEFAULT, 0, &t, NULL, NULL, 0);
const ws_size_t cchTotal = static_cast<ws_size_t>((cchDate - 1) + 1 + (cchTime - 1)); // GetDateFormat() + space + GetTimeFormat() (subtracting 1 for terminating NUL in each count returned)
return cchTotal;
}
inline ws_size_t c_str_len_w(SYSTEMTIME const& t)
{
return c_str_len_w(t, ws_false_v);
}
inline ws_size_t c_str_len(SYSTEMTIME const& t, ws_bool_t bMilliseconds)
{
#ifdef UNICODE
return c_str_len_w(t, bMilliseconds);
#else /* ? UNICODD */
return c_str_len_a(t, bMilliseconds);
#endif /* UNICODD */
}
inline ws_size_t c_str_len(SYSTEMTIME const& t)
{
return c_str_len(t, ws_false_v);
}
// FILETIME
inline ws_size_t c_str_len_a(FILETIME const& t, ws_bool_t bMilliseconds)
{
return c_str_len_a(FILETIME2SYSTEMTIME(t), bMilliseconds);
}
inline ws_size_t c_str_len_a(FILETIME const& t)
{
return c_str_len_a(FILETIME2SYSTEMTIME(t), ws_false_v);
}
inline ws_size_t c_str_len_w(FILETIME const& t, ws_bool_t bMilliseconds)
{
return c_str_len_w(FILETIME2SYSTEMTIME(t), bMilliseconds);
}
inline ws_size_t c_str_len_w(FILETIME const& t)
{
return c_str_len_w(FILETIME2SYSTEMTIME(t), ws_false_v);
}
inline ws_size_t c_str_len(FILETIME const& t, ws_bool_t bMilliseconds)
{
return c_str_len(FILETIME2SYSTEMTIME(t), bMilliseconds);
}
inline ws_size_t c_str_len(FILETIME const& t)
{
return c_str_len(FILETIME2SYSTEMTIME(t), ws_false_v);
}
// UDATE
#ifdef WINSTL_UDATE_DEFINED
inline ws_size_t c_str_len_a(UDATE const& t, ws_bool_t bMilliseconds)
{
return c_str_len_a(t.st, bMilliseconds);
}
inline ws_size_t c_str_len_a(UDATE const& t)
{
return c_str_len_a(t.st, ws_false_v);
}
inline ws_size_t c_str_len_w(UDATE const& t, ws_bool_t bMilliseconds)
{
return c_str_len_w(t.st, bMilliseconds);
}
inline ws_size_t c_str_len_w(UDATE const& t)
{
return c_str_len_w(t.st, ws_false_v);
}
inline ws_size_t c_str_len(UDATE const& t, ws_bool_t bMilliseconds)
{
return c_str_len(t.st, bMilliseconds);
}
inline ws_size_t c_str_len(UDATE const& t)
{
return c_str_len(t.st, ws_false_v);
}
#endif /* WINSTL_UDATE_DEFINED */
/* /////////////////////////////////////////////////////////////////////////
* Stream inserter
*/
/** \brief An inserter function for SYSTEMTIME into output streams
*
* \ingroup group__library__shims__string_access
*
*/
template <ss_typename_param_k S>
inline S& operator <<(S& s, SYSTEMTIME const& st)
{
stream_insert(s, st);
return s;
}
/** \brief An inserter function for FILETIME into output streams
*
* \ingroup group__library__shims__string_access
*
*/
template <ss_typename_param_k S>
inline S& operator <<(S& s, FILETIME const& ft)
{
stream_insert(s, ft);
return s;
}
#ifdef WINSTL_UDATE_DEFINED
/** \brief An inserter function for UDATE into output streams
*
* \ingroup group__library__shims__string_access
*
*/
template <ss_typename_param_k S>
inline S& operator <<(S& s, UDATE const& ud)
{
stream_insert(s, ud);
return s;
}
#endif /* WINSTL_UDATE_DEFINED */
/* ////////////////////////////////////////////////////////////////////// */
#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 */
/** \brief An inserter function for SYSTEMTIME into output streams
*
* \ingroup group__library__shims__string_access
*
*/
template <ss_typename_param_k S>
inline S& operator <<(S& s, SYSTEMTIME const& st)
{
::winstl::stream_insert(s, st);
return s;
}
/** \brief An inserter function for FILETIME into output streams
*
* \ingroup group__library__shims__string_access
*
*/
template <ss_typename_param_k S>
inline S& operator <<(S& s, FILETIME const& st)
{
::winstl::stream_insert(s, st);
return s;
}
namespace stlsoft
{
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;
using ::winstl::c_str_len_a;
using ::winstl::c_str_len_w;
} // namespace stlsoft
#endif /* !_WINSTL_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*/
#ifndef _WINSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
/* There is no stlsoft namespace, so must define ::winstl */
namespace winstl
{
# else
/* Define stlsoft::winstl_project */
namespace stlsoft
{
namespace winstl_project
{
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
////////////////////////////////////////////////////////////////////////////
// Unit-testing
#ifdef STLSOFT_UNITTEST
# include "./unittest/time_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 */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !WINSTL_INCL_WINSTL_SHIMS_ACCESS_STRING_HPP_TIME */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -