Stardew Engine
Loading...
Searching...
No Matches
StardewString.h File Reference
#include "DynArray.h"
Include dependency graph for StardewString.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DECLARE_STATIC_STRING_COPY(copyName, copySrc)
 Declares and lazily intializes a buffer and copies src string into it, call at start of function passing in an arg so that you can tokenize the string with minimal dynamic memory allocation. uses a vector, but doesn't set the vectors size property, just uses it as a string buffer.
 

Functions

int Str_Tokenize (char *string, char sep)
 replaces occurences of the char "sep" in the string with null characters and returns the resulting number of strings.
 
void Str_AdvanceToNextToken (char **pNextToken)
 advance a char pointer to the null terminator and then past its
 

Macro Definition Documentation

◆ DECLARE_STATIC_STRING_COPY

#define DECLARE_STATIC_STRING_COPY (   copyName,
  copySrc 
)
Value:
static VECTOR(char) copyName = NULL; \
if(!copyName) \
{ \
copyName = NEW_VECTOR(char); \
copyName = VectorResize(copyName, 32000); \
} \
size_t len = strlen(copySrc); \
while(len > VectorCapacity(copyName)) \
{ \
copyName = VectorResize(copyName, VectorCapacity(copyName) * 2); \
} \
strcpy(copyName, copySrc);
void * VectorResize(void *vector, unsigned int size)
Definition DynArray.c:16
#define VectorCapacity(vector)
Definition DynArray.h:31
#define NEW_VECTOR(a)
Definition DynArray.h:34
#define VECTOR(a)
Definition WfGame.h:8

Declares and lazily intializes a buffer and copies src string into it, call at start of function passing in an arg so that you can tokenize the string with minimal dynamic memory allocation. uses a vector, but doesn't set the vectors size property, just uses it as a string buffer.

Parameters
copyNamename of string copy variable
copySrcsource string

Function Documentation

◆ Str_AdvanceToNextToken()

void Str_AdvanceToNextToken ( char **  pNextToken)

advance a char pointer to the null terminator and then past its

Parameters
pNextToken

◆ Str_Tokenize()

int Str_Tokenize ( char *  string,
char  sep 
)

replaces occurences of the char "sep" in the string with null characters and returns the resulting number of strings.

Parameters
string
sepseparator
Returns
number of tokens