Substring manipulation API

Overview

// typedefs

typedef struct te_substring_t te_substring_t;

// structs

struct te_substring_t;

// global functions

static bool te_substring_is_valid(const te_substring_t* substr);
void te_substring_find(te_substring_t* substr, const char* str);
te_errno te_substring_replace(te_substring_t* substr, const char* str);
void te_substring_advance(te_substring_t* substr);
void te_substring_limit(te_substring_t* substr, const te_substring_t* limit);

// macros

#define TE_SUBSTRING_INIT(_base)

Detailed Documentation

Typedefs

typedef struct te_substring_t te_substring_t

Structure for describing a piece of string

Global Functions

static bool te_substring_is_valid(const te_substring_t* substr)

Check that substring is valid

Parameters:

substr

Substring

Returns:

true or false

void te_substring_find(te_substring_t* substr, const char* str)

Find a str starting at substr position and update it accordingly

Parameters:

substr

Substring

str

The string to find

te_errno te_substring_replace(te_substring_t* substr, const char* str)

Replace a substring at a given position, modifying the underlying te_string

Parameters:

substr

Substring

str

Replacement string

TE_EINVAL

Substring position is out of bounds.

Returns:

Status code.

void te_substring_advance(te_substring_t* substr)

Move the position by the length of the previously substring

Parameters:

substr

Substring

void te_substring_limit(te_substring_t* substr, const te_substring_t* limit)

Limit the length of the substr to position limit so that it ended right before limit

Parameters:

substr

Substring

limit

Limiting substring

Macros

#define TE_SUBSTRING_INIT(_base)

Substring initializer

Parameters:

_base

Pointer to the base string