Skip to content
tiffany352 edited this page Jan 1, 2013 · 2 revisions

Types

typedef struct il_String {
  size_t length;
  const char *data;
} il_String;

A null-terminated string type that includes the length in the case of lacking \0 or embedded \0s. Will have memory management in the future probably.

Macros

#define il_string il_String

A convienience define, though it should probably be the other way around.

#define il_fromC(s) ...

Deprecated. Convert a const char* to an il_string. See il_CtoS.

#define il_l(s) ...

Convert a C string literal to an il_string.

#define il_toC il_StoC

Deprecated. Convert an il_string to a const char*. See il_StoC.

#define il_len(s) (strnlen(s.data, s.length))

Gets the length of an il_string, should be moved to a function for binary compatibility.

#define il_concat(...) ...

Concatenates any number of il_strings together, and returns the result.

Functions

il_String il_CtoS(const char * s, int len);

Converts a const char* to an il_string, with a length argument for how much to take (if it's -1, it will use strlen()).

const char *il_StoC(il_String s);

Converts an il_string to a const char*, which is typically just returning the 'data' argument, but makes sure the \0 is there.

int il_strcmp(il_String a, il_String b);

This function is strcmp for il_strings.

Clone this wiki locally