44 lines
857 B
C
44 lines
857 B
C
//
|
|
// Created by xemon on 11.11.22.
|
|
//
|
|
|
|
#include "BaseTypes/Strings.h"
|
|
#include "memory.h"
|
|
|
|
#define StringGetLinkTemplate(T) \
|
|
tStringLink String##T##GetLink(tString##T *string) { \
|
|
return (tStringLink) {.length = &string->length, .data = string->data}; \
|
|
}
|
|
|
|
StringGetLinkTemplate(8)
|
|
|
|
StringGetLinkTemplate(16)
|
|
|
|
StringGetLinkTemplate(32)
|
|
|
|
StringGetLinkTemplate(64)
|
|
|
|
StringGetLinkTemplate(128)
|
|
|
|
StringGetLinkTemplate(Static)
|
|
|
|
|
|
#define StringStaticInit(STR) (tStringStatic){.data = STR, .length = sizeof(STR)-1}
|
|
|
|
|
|
#define StringCopyT(T) \
|
|
void String##T##Copy(tString##T *dest, char *source, uint8_t sourceLen) { \
|
|
dest->length = sourceLen > T ? T : sourceLen; \
|
|
memcpy(dest->data, source, dest->length); \
|
|
}
|
|
|
|
StringCopyT(8)
|
|
|
|
StringCopyT(16)
|
|
|
|
StringCopyT(32)
|
|
|
|
StringCopyT(64)
|
|
|
|
StringCopyT(128)
|