BaseTypes/Inc/BaseTypes/Strings.h

82 lines
1.7 KiB
C

//
// Created by xemon on 10.11.22.
//
#ifndef UVEOS_ON_NATION_STRINGS_H
#define UVEOS_ON_NATION_STRINGS_H
#include "stdint.h"
#define tString(T) \
typedef struct { \
uint8_t length; \
char data[T]; \
} tString##T;
tString(8)
tString(16)
tString(32)
tString(64)
tString(128)
tString(255)
typedef struct {
uint8_t length;
char *data;
} tStringStatic;
typedef struct {
uint8_t *length;
char *data;
} tStringLink;
#define StringGetLinkTemplateD(T) \
tStringLink String##T##GetLink(tString##T *string);
StringGetLinkTemplateD(8)
StringGetLinkTemplateD(16)
StringGetLinkTemplateD(32)
StringGetLinkTemplateD(64)
StringGetLinkTemplateD(128)
StringGetLinkTemplateD(255)
StringGetLinkTemplateD(Static)
#define StringStaticInit(STR) (tStringStatic){.data = (char*)(STR), .length = sizeof(STR)-1}
#define StringArrInit(STR) (tStringStatic){.data = (char*)(STR), .length = sizeof(STR)}
#define StringCopyTD(T) \
void String##T##Copy(tString##T *dest, char *source, uint8_t sourceLen);
StringCopyTD(8)
StringCopyTD(16)
StringCopyTD(32)
StringCopyTD(64)
StringCopyTD(128)
StringCopyTD(255)
#define StringCopyStaticTemplate(T) \
String##T##Copy(DEST,STR,sizeof(STR)-1)
#define String8CopyStatic(DEST, STR) String8Copy(DEST,STR,sizeof(STR)-1)
#define String16CopyStatic(DEST, STR) String16Copy(DEST,STR,sizeof(STR)-1)
#define String32CopyStatic(DEST, STR) String32Copy(DEST,STR,sizeof(STR)-1)
#define String64CopyStatic(DEST, STR) String64Copy(DEST,STR,sizeof(STR)-1)
#define String128CopyStatic(DEST, STR) String128Copy(DEST,STR,sizeof(STR)-1)
#define String255CopyStatic(DEST, STR) String128Copy(DEST,STR,sizeof(STR)-1)
#endif //UVEOS_ON_NATION_STRINGS_H