sstr.h docs v1.0
Documentation for the sstr.h string library
sstr.h And Documentation Made By Tobin Cavanaugh: Github URL , Personal Site

Go to the source code of this file.

//sstr.h uses:
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stdint.h>

Macros

#define char* $
#define begin(NAME)
#define end(NAME)
#define from(a)
#define resize(a, size)
#define from_fmt(fmt, ...)
#define append_fmt(a, fmt, ...)
#define append(a, b)
#define insert(_str, _index, _add)
#define substr(a, _start, _len)
#define realize(a)
#define stackify(a)


# $

#define char*

Definition for a string. Highly recommended to limit its use to only stack strings for the sake of your sanity.

Definition:
char*


# $append

#define append ( a,
b
)

Appends b to a.

Parameters:
a : The base $
b : The $ to be appended
Returns:
$ : The resulting combined string

Definition at line 78 of file sstr.h.



#$append_fmt

#define append_fmt ( a,
fmt,
...
)

Appends the arguments formatted to fmt to the base. Uses the standard C formatting. Think printf

Parameters:
a : The base $
fmt : The format string for the following varargs
... : The varags, comma separated
Returns:
$ : The resulting combined string.

Definition at line 68 of file sstr.h.



#$begin

#define begin ( NAME ) void __run_ ## NAME (void){

Used with combination with $end(1). Creates a nested function as to allow arena allocation like behavior. Use $realize to convert a stack $ to a heap string.

Parameters:
NAME : Unique name to link with $end
Returns:
void

Definition at line 23 of file sstr.h.



#$end

#define end ( NAME ) } __run_ ## NAME ();

Used in combination with $begin(1)

Parameters:
NAME : Unique name to link with $begin
Returns:
void

Definition at line 28 of file sstr.h.



#$from

#define from ( a )

Manually allocates stack memory for your string

Parameters:
a : The source C string literal
Returns:
$ : The newly created $

Definition at line 33 of file sstr.h.



#$from_fmt

#define from_fmt ( fmt,
...
)

Creates a $ from a C printf style format and args.

Parameters:
fmt : The format to create the string from
... : The varargs to fill into the format
Returns:
$ : A $ of the correct formatting

Definition at line 54 of file sstr.h.



#$insert

#define insert ( _str,
_index,
_add
)

Inserts _add into the $ _str at _index

Parameters:
_str : The base string
_index : The index in _str for _add to be inserted at. This will be clamped between [0 and strLen+1].
_add : The $ to be inserted
Returns:
$ : A $ with the same contents as _str but with _add inserted.

Definition at line 93 of file sstr.h.



#$realize

#define realize ( a )

Creates a heap allocated string from the $

Parameters:
a : The $ to be allocated
Returns:
char * : A char pointer to the newly allocated string

Definition at line 172 of file sstr.h.



#$resize

#define resize ( a,
size
)

Creates a new $ with the corresponding size and matching data

Parameters:
a : The base $ to be resized
size : The size of the new $
Returns:
$ : The new $

Definition at line 44 of file sstr.h.



#$stackify

#define stackify ( a )

Creates a stack allocated string from the $

Parameters:
a : The $ to be allocated
Returns:
$ : The stack string

Definition at line 182 of file sstr.h.



#$substr

#define substr ( a,
_start,
_len
)

Takes a substring of a $ from start with len

Parameters:
a : The base $
_start : The start index. In the case this is negative, the negative numbers will be subtracted from length. This means that an index of -1 and a length of 3 will result in the first 2 characters being read.
_len : The length of the substringa
Returns:
$ : The resulting substring as a stack string

Definition at line 137 of file sstr.h.