41 size_t len = std::strlen(src);
43 error::throwTrace<std::invalid_argument>(
44 std::string(
"String size is too long: ") + src);
47 std::memcpy(out->data(), src, len);
49 std::memset(out->data() + len,
'\0', N - len);
58 if (h != INVALID_HANDLE_VALUE) {
64 using HandlePtr = std::unique_ptr<HANDLE, HandleDeleter>;
71 if (h != INVALID_HANDLE_VALUE) {
77 using HeapPtr = std::unique_ptr<HANDLE, heapDeleter>;
88 using ComPtr = std::unique_ptr<T, ComDeleter>;
98 using FilePtr = std::unique_ptr<FILE, FileDeleter>;
105 inline std::unique_ptr<char[]>
wc2utf8(
const wchar_t *in)
107 int len = ::WideCharToMultiByte(CP_UTF8, 0, in, -1,
nullptr, 0,
nullptr,
nullptr);
108 std::unique_ptr<char[]> pBuf(
new char[len]);
109 ::WideCharToMultiByte(CP_UTF8, 0, in, -1, pBuf.get(), len,
nullptr,
nullptr);
117 inline std::unique_ptr<wchar_t[]>
utf82wc(
const char *in)
119 int len = ::MultiByteToWideChar(CP_UTF8, 0, in, -1,
nullptr, 0);
120 std::unique_ptr<wchar_t[]> pBuf(
new wchar_t[len]);
121 ::MultiByteToWideChar(CP_UTF8, 0, in, -1, pBuf.get(), len);
147 const char *p = key.data();
148 for (
size_t i = 0; i < key.size(); i++) {
149 hashCode = hashCode * 31 + p[i];
std::unique_ptr< char[]> wc2utf8(const wchar_t *in)
Wide char to UTF-8.
void createFixedString(std::array< char, N > *out, const char *src)
Create yappy::util::IdString from C-style string.
std::array< char, 16 > IdString
Fixed size char array for string ID.
std::unique_ptr< FILE, FileDeleter > FilePtr
unique_ptr of FILE with FileDeleter.
size_t operator()(const yappy::util::IdString &key) const
Deleter: auto IUnknown::Release().
void operator()(FILE *fp)
std::unique_ptr< HANDLE, heapDeleter > HeapPtr
unique_ptr of HANDLE with heapDeleter.
noncopyable & operator=(const noncopyable &)=delete
Deleter: auto CloseHandle().
Auto CoInitializeEx() and CoUninitialize() class.
std::unique_ptr< HANDLE, HandleDeleter > HandlePtr
unique_ptr of HANDLE with HandleDeleter.
std::unique_ptr< wchar_t[]> utf82wc(const char *in)
UTF-8 to wide char.
CoInitialize()
CoInitializeEx(nullptr, COINIT_MULTITHREADED)
void operator()(HANDLE h)
Deleter: auto HeapDestroy().
~CoInitialize()
CoUninitialize()
void operator()(IUnknown *p)
std::unique_ptr< T, ComDeleter > ComPtr
unique_ptr of IUnknown with ComDeleter.
void operator()(HANDLE h)