This commit is contained in:
Krzosa Karol
2024-08-16 07:23:50 +02:00
parent 2065c9ded7
commit afd4e1d21c
9 changed files with 44 additions and 20 deletions

View File

@@ -796,23 +796,13 @@ int64_t CreateWidecharFromChar(wchar_t *buffer, int64_t buffer_size, char *i
inline bool operator==(String a, String b) { return AreEqual(a, b); }
inline bool operator!=(String a, String b) { return !AreEqual(a, b); }
#if defined(__has_attribute) && defined(_MSC_VER) && !defined(__clang__)
#if __has_attribute(format)
#define PrintfFormatAttribute(fmt, va) __attribute__((format(printf, fmt, va)))
#endif
#endif
#ifndef PrintfFormatAttribute
#define PrintfFormatAttribute(fmt, va)
#endif
#define STRING_FORMAT(allocator, data, result) \
va_list args1; \
va_start(args1, data); \
String result = FormatV(allocator, data, args1); \
va_end(args1)
String Format(Allocator allocator, const char *data, ...) PrintfFormatAttribute(2, 3);
String Format(Allocator allocator, const char *data, ...);
String FormatV(Allocator allocator, const char *data, va_list args1);
String ToString(Allocator allocator, String16 string);
String ToString(Allocator allocator, wchar_t *string, int64_t len);
@@ -1569,7 +1559,7 @@ String FormatV(Allocator allocator, const char *data, va_list args1) {
return res;
}
String Format(Allocator allocator, const char *data, ...) PrintfFormatAttribute(2, 3) {
String Format(Allocator allocator, const char *data, ...) {
STRING_FORMAT(allocator, data, result);
return result;
}

View File

@@ -237,7 +237,7 @@ bool StartsWith(String16 a, String16 start, unsigned ignore_case = false) {
return result;
}
String16 Copy(Allocator allocator, String16 string) {
String16 Copy16(Allocator allocator, String16 string) {
wchar_t *copy = (wchar_t *)AllocSize(allocator, sizeof(wchar_t) * (string.len + 1));
memcpy(copy, string.data, string.len);
copy[string.len] = 0;
@@ -245,7 +245,7 @@ String16 Copy(Allocator allocator, String16 string) {
return result;
}
String16 Copy(Allocator allocator, wchar_t *string) {
String16 Copy16(Allocator allocator, wchar_t *string) {
String16 s = {string, (int64_t)WideLength(string)};
return Copy(allocator, s);
}