Compare commits
4 Commits
a9d87b4cfd
...
master
Author | SHA1 | Date | |
---|---|---|---|
b2f0ac3a3b | |||
de592cebb9 | |||
9588b602a9 | |||
b99b2fc19e |
@@ -2383,6 +2383,9 @@ namespace stdex
|
|||||||
socket(_In_ const socket& other);
|
socket(_In_ const socket& other);
|
||||||
socket& operator =(_In_ const socket& other);
|
socket& operator =(_In_ const socket& other);
|
||||||
|
|
||||||
|
// Force use of valid() method when testing handle.
|
||||||
|
operator bool() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
socket(_Inout_ socket&& other) noexcept : m_h(other.m_h)
|
socket(_Inout_ socket&& other) noexcept : m_h(other.m_h)
|
||||||
{
|
{
|
||||||
@@ -3582,7 +3585,7 @@ namespace stdex
|
|||||||
#endif
|
#endif
|
||||||
size_t available = m_size - m_offset;
|
size_t available = m_size - m_offset;
|
||||||
if (length <= available) {
|
if (length <= available) {
|
||||||
stdex_assert(m_data || !length);
|
stdex_assert(&m_data[m_offset] || !length);
|
||||||
memcpy(data, &m_data[m_offset], length);
|
memcpy(data, &m_data[m_offset], length);
|
||||||
m_offset += length;
|
m_offset += length;
|
||||||
m_state = state_t::ok;
|
m_state = state_t::ok;
|
||||||
@@ -3592,7 +3595,7 @@ namespace stdex
|
|||||||
m_state = state_t::eof;
|
m_state = state_t::eof;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
stdex_assert(m_data || !available);
|
stdex_assert(&m_data[m_offset] || !available);
|
||||||
memcpy(data, &m_data[m_offset], available);
|
memcpy(data, &m_data[m_offset], available);
|
||||||
m_offset += available;
|
m_offset += available;
|
||||||
m_state = state_t::ok;
|
m_state = state_t::ok;
|
||||||
@@ -3700,7 +3703,7 @@ namespace stdex
|
|||||||
if (!ok()) _Unlikely_
|
if (!ok()) _Unlikely_
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
stdex_assert(m_data || !length);
|
stdex_assert(&m_data[m_offset] || !length);
|
||||||
memcpy(&m_data[m_offset], data, length);
|
memcpy(&m_data[m_offset], data, length);
|
||||||
m_offset = end_offset;
|
m_offset = end_offset;
|
||||||
if (m_offset > m_size)
|
if (m_offset > m_size)
|
||||||
@@ -3723,7 +3726,7 @@ namespace stdex
|
|||||||
if (!ok()) _Unlikely_
|
if (!ok()) _Unlikely_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stdex_assert(m_data || !amount);
|
stdex_assert(&m_data[m_offset] || !amount);
|
||||||
memset(&m_data[m_offset], byte, amount);
|
memset(&m_data[m_offset], byte, amount);
|
||||||
m_offset = end_offset;
|
m_offset = end_offset;
|
||||||
if (m_offset > m_size)
|
if (m_offset > m_size)
|
||||||
|
@@ -58,6 +58,8 @@ namespace stdex
|
|||||||
///
|
///
|
||||||
/// Character type for system functions
|
/// Character type for system functions
|
||||||
///
|
///
|
||||||
|
/// \note TODO: Should migrate to std::filesystem::path::value_type. Research UNICODE/_UNICODE behavior on Windows.
|
||||||
|
///
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
using schar_t = TCHAR;
|
using schar_t = TCHAR;
|
||||||
#else
|
#else
|
||||||
@@ -73,8 +75,32 @@ namespace stdex
|
|||||||
///
|
///
|
||||||
/// String for system functions
|
/// String for system functions
|
||||||
///
|
///
|
||||||
|
/// \note TODO: Should migrate to std::filesystem::path. Research UNICODE/_UNICODE behavior on Windows.
|
||||||
|
///
|
||||||
using sstring = std::basic_string<stdex::schar_t>;
|
using sstring = std::basic_string<stdex::schar_t>;
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
inline sstring to_sstring(int value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(long value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(long long value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(unsigned value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(unsigned long value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(unsigned long long value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(float value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(double value) { return std::to_wstring(value); }
|
||||||
|
inline sstring to_sstring(long double value) { return std::to_wstring(value); }
|
||||||
|
#else
|
||||||
|
inline sstring to_sstring(int value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(long value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(long long value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(unsigned value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(unsigned long value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(unsigned long long value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(float value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(double value) { return std::to_string(value); }
|
||||||
|
inline sstring to_sstring(long double value) { return std::to_string(value); }
|
||||||
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
/// String for system functions for backward compatibility
|
/// String for system functions for backward compatibility
|
||||||
/// Use stdex::sstring
|
/// Use stdex::sstring
|
||||||
@@ -200,6 +226,10 @@ namespace stdex
|
|||||||
///
|
///
|
||||||
operator T() const noexcept { return m_h; }
|
operator T() const noexcept { return m_h; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Force use of valid() method when testing handle.
|
||||||
|
operator bool() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
T m_h;
|
T m_h;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user