offbrand
A collection of generic, reference counted datastructures in C for C
|
obstring Method Implementation More...
Macros | |
#define | REGEX_ERROR_BUFFER_SIZE 256 |
Functions | |
obstring * | obstring_new (const char *str) |
Creates a new obstring with the string of characters. More... | |
obstring * | obstring_copy_substring (const obstring *s, int64_t start, uint32_t length) |
Copies a sequence of characters from an obstring to create a new instance of obstring. More... | |
uint32_t | obstring_length (const obstring *s) |
Gets the length of an obstring. More... | |
char | obstring_char_at_index (const obstring *s, int64_t i) |
returns the character at the specified index More... | |
obstring * | obstring_concat (const obstring *s1, const obstring *s2) |
concatenates the two obstring instances into a new instance of obstring More... | |
const char * | obstring_cstring (const obstring *s) |
Gets the C string representation of an obstring instance. More... | |
obvector * | obstring_split (const obstring *s, const char *delim) |
Tokenizes an obstring over a character sequence. More... | |
uint8_t | obstring_find_substring (const obstring *s, const char *substring) |
Searches for an substring in an obstring. More... | |
obstring * | obstring_match_regex (const obstring *s, const char *regex) |
Finds the pattern matching an expression in an obstring. More... | |
obstring * | obstring_create_default (void) |
Default constructor for obstring. More... | |
ob_hash_t | obstring_hash (const obj *to_hash) |
Hash function for obstring. More... | |
int8_t | obstring_compare (const obj *a, const obj *b) |
Compares two instances of obstring. More... | |
void | obstring_display (const obj *str) |
Display function for an instance of obstring. More... | |
void | obstring_destroy (obj *to_dealloc) |
Destructor for obstring. More... | |
obstring Method Implementation
#define REGEX_ERROR_BUFFER_SIZE 256 |
Buffer size for a string to print on a regex error
char obstring_char_at_index | ( | const obstring * | s, |
int64_t | i | ||
) |
returns the character at the specified index
s | A pointer to an instance of obstring |
i | An integer denoting a characters position in the string. Negative integers are accepted, with -1 indicating the final non-NUL character in the string |
Compares two instances of obstring.
a | A non-NULL obj pointer to type obstring |
b | A non-NULL obj pointer to type obstring |
OB_LESS_THAN | obj a is less than b |
OB_GREATER_THAN | obj a is equivalent to b |
OB_EQUAL_TO | obj a is greater than b |
concatenates the two obstring instances into a new instance of obstring
s1 | A pointer to an instance of obstring |
s2 | A pointer to an instance of obstring |
Copies a sequence of characters from an obstring to create a new instance of obstring.
s | A pointer to an instance of obstring |
start | An integer denoting the position of the start of the sequence to copy within the string, character at position start included. Negative integers are accepted, with -1 indicating the final non-NUL character in the string |
length | An integer denoting the length of the string to be copied |
obstring* obstring_create_default | ( | void | ) |
Default constructor for obstring.
const char* obstring_cstring | ( | const obstring * | s) |
Gets the C string representation of an obstring instance.
s | A pointer to an instance of obstring |
void obstring_destroy | ( | obj * | to_dealloc) |
Destructor for obstring.
to_dealloc | An obj pointer to an instance of obstring with reference count of 0 |
void obstring_display | ( | const obj * | str) |
Display function for an instance of obstring.
str | A non-NULL obj pointer to type obstring |
uint8_t obstring_find_substring | ( | const obstring * | s, |
const char * | to_find | ||
) |
Searches for an substring in an obstring.
s | A pointer to an instance of obstring to be searched |
to_find | A NUL terminated C string containing the sequence of characters to find |
0 | The substring was not found in the search string |
non-zero | The substring was found in the search string |
Hash function for obstring.
to_hash | An obj pointer to an instance of obstring |
uint32_t obstring_length | ( | const obstring * | s) |
Gets the length of an obstring.
s | A pointer to an instance of obstring |
Finds the pattern matching an expression in an obstring.
s | A pointer to and instance of obstring to be searched |
regex | A pointer to an instance of obstring containing the expression to attempt to match |
The POSIX Extended Regular Expression syntax is used to interpret the provided expression
obstring* obstring_new | ( | const char * | str) |
Creates a new obstring with the string of characters.
str | A NUL terminated C string |
The provided C string is not stored directly in an instance of obstring and so can be modified and free'd without affecting the created obstring.
Tokenizes an obstring over a character sequence.
s | A pointer to an instance of obstring to be tokenized |
delim | A NUL terminated C string indicating the character or sequence of characters on which to break a string |
A multicharacter obstring will not cause the the original string to be split on each character, but rather the original string will be split on complete instances of delim.