1 #if !defined(_BTKUTILS_MEM_HPP_) 2 #define _BTKUTILS_MEM_HPP_ 10 BTKAPI
size_t U16Strlen(
const char16_t *str);
11 BTKAPI
int U16Strcmp(
const char16_t *s1,
const char16_t *s2);
12 BTKAPI
int U16Strcasecmp(
const char16_t *s1,
const char16_t *s2);
19 BTKAPI
size_t Utf16To8(std::string&,std::u16string_view);
25 BTKAPI
size_t Utf8To16(std::u16string&,std::string_view);
37 BTKAPI Sint64
ParseHex(std::string_view txt);
38 BTKAPI Sint64 ParseInt(std::string_view txt);
48 template<
class T,auto Alloc = std::malloc>
50 T* ret =
static_cast<T*
>(Alloc(size));
54 std::memcpy(ret,ptr,size);
65 template<
class T,auto Alloc = std::malloc>
67 return Memdup<T,Alloc>(ptr,
sizeof(T));
69 template<
class T,auto Alloc = std::malloc>
71 return Memdup<T,Alloc>(&ref,
sizeof(T));
79 inline std::string
Utf16To8(std::u16string_view utf16){
97 #endif // _BTKUTILS_MEM_HPP_ BTKAPI Sint64 ParseHex(std::string_view txt)
Parse a hex string.
Definition: mem.cpp:197
This header include many useful containers.
Definition: async.hpp:7
BTKAPI size_t Utf16To8(std::string &, std::u16string_view)
Convert u16string to u8string.
Definition: mem.cpp:109
BTKAPI size_t Utf8To16(std::u16string &, std::string_view)
Convert u8string to u16string.
Definition: mem.cpp:114
T * Memdup(const T *ptr, size_t size)
A helper template for dup memory.
Definition: mem.hpp:49
BTKAPI bool IsValidUtf8(std::string_view)
Check a string is vaid utf8.
Definition: mem.cpp:119