a wrapper around strings
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
/*
|
||||
* What is this?
|
||||
*
|
||||
@@ -34,3 +37,5 @@ void listRemoveAt(list_t* l, int index);
|
||||
void listSetAt(list_t* l, int index, dataType_e type, void* element);
|
||||
|
||||
void* listGetAt(list_t* l, int index);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
#include <odweta/util.h>
|
||||
|
||||
typedef struct {
|
||||
char *content;
|
||||
size_t length;
|
||||
} string_t;
|
||||
|
||||
string_t *string_new(); // create a new empty string
|
||||
|
||||
string_t *string_from(char *chars); // create a new string from a given char_sequence
|
||||
|
||||
bool string_push_chars(string_t *this, char *chars); // append a char_sequence to a string
|
||||
bool string_push(string_t *this, string_t *other); // append a string to a string
|
||||
|
||||
compare_e string_compare(string_t *left, string_t* right); // compare two strings
|
||||
|
||||
void string_print(string_t *this); // print a string
|
||||
void string_println(string_t *this); // print a string with a \n
|
||||
|
||||
bool string_is_empty(string_t *this); // return true when s->content == ""
|
||||
|
||||
void string_cleanup(string_t *this); // memory cleanup
|
||||
|
||||
#endif
|
||||
+13
-1
@@ -1,6 +1,17 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum {
|
||||
LESS,
|
||||
LESS_EQUAL,
|
||||
EQUAL,
|
||||
NOT_EQUAL,
|
||||
GREATER,
|
||||
GREATER_EQUAL
|
||||
} compare_e;
|
||||
|
||||
typedef long unsigned int size_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -8,7 +19,8 @@ typedef enum {
|
||||
FLOAT = 1,
|
||||
CHAR = 2,
|
||||
VECTOR = 3, // allows for multi-dimensional arrays
|
||||
LIST = 4
|
||||
LIST = 4,
|
||||
BOOL = 5
|
||||
} dataType_e;
|
||||
|
||||
char* intToString(int x); // convert an int into a string
|
||||
|
||||
Reference in New Issue
Block a user