57 #define SOL_STR_STATIC_ASSERT_LITERAL(_s) ("" _s)
62 #define SOL_STR_SLICE_LITERAL(_s) { (sizeof(SOL_STR_STATIC_ASSERT_LITERAL(_s)) - 1), (_s) }
67 #define SOL_STR_SLICE_STR(_s, _len) (struct sol_str_slice){.len = (_len), .data = (_s) }
72 #define SOL_STR_SLICE_EMPTY { .len = 0, .data = "" }
78 #define SOL_STR_SLICE_PRINT(_s) (int)(_s).len, (_s).data
102 return b && a.
len == strlen(b) && (memcmp(a.
data, b, a.
len) == 0);
136 return b && a.
len == strlen(b) && (strncasecmp(a.
data, b, a.
len) == 0);
192 memcpy(dst, src.
data, src.
len);
207 return slice.
len >= prefix.
len && strncmp(slice.
data, prefix.
data, prefix.
len) == 0;
221 size_t len = strlen(prefix);
223 return slice.
len >= len && strncmp(slice.
data, prefix, len) == 0;
275 blob_mem = malloc(slice.
len);
279 memcpy(blob_mem, slice.
data, slice.
len);
282 blob_mem, slice.
len);
314 return strndup(slice.
data, slice.
len);
329 while (copy.
len && isspace((uint8_t)*copy.
data)) {
349 while (copy.
len != 0) {
350 uint8_t c = copy.
data[copy.
len - 1];
357 if (slice.len - copy.
len)
static bool sol_str_slice_str_case_eq(const struct sol_str_slice a, const char *b)
Checks if the content of the slice is equal to the string.
Definition: sol-str-slice.h:134
bool sol_str_slice_split_iterate(const struct sol_str_slice slice, struct sol_str_slice *token, const char **itr, const struct sol_str_slice delim)
Do an one step split iteration over a slice.
static bool sol_str_slice_starts_with(const struct sol_str_slice slice, const struct sol_str_slice prefix)
Checks if slice begins with prefix.
Definition: sol-str-slice.h:205
static char * sol_str_slice_str_contains(const struct sol_str_slice haystack, const char *needle)
Checks if haystack contains needle.
Definition: sol-str-slice.h:176
struct sol_str_slice sol_str_slice
String slice type.
These routines are used for Soletta types' manipulation.
static struct sol_str_slice sol_str_slice_trim(struct sol_str_slice slice)
Returns a slice based on slice but without either leading or trailing white spaces.
Definition: sol-str-slice.h:371
static struct sol_str_slice sol_str_slice_remove_trailing_whitespace(struct sol_str_slice slice)
Returns a slice based on slice but without trailing white spaces.
Definition: sol-str-slice.h:345
struct sol_blob * sol_blob_new(const struct sol_blob_type *type, struct sol_blob *parent, const void *mem, size_t size)
Creates a new blob instance of the given type type.
These are common Soletta macros.
const struct sol_blob_type SOL_BLOB_TYPE_DEFAULT
Blob type object for the default implementation.
static struct sol_str_slice sol_str_slice_from_blob(const struct sol_blob *blob)
Populates a slice from a sol_blob.
Definition: sol-str-slice.h:255
static struct sol_buffer value
Definition: server.c:42
static bool sol_str_slice_str_starts_with(const struct sol_str_slice slice, const char *prefix)
Checks if slice begins with prefix.
Definition: sol-str-slice.h:219
String slice type.
Definition: sol-str-slice.h:84
static struct sol_str_slice sol_str_slice_remove_leading_whitespace(struct sol_str_slice slice)
Returns a slice based on slice but without leading white spaces.
Definition: sol-str-slice.h:325
static struct sol_str_slice sol_str_slice_from_str(const char *s)
Populates a slice from a string.
Definition: sol-str-slice.h:238
const char * data
Slice data.
Definition: sol-str-slice.h:86
char * sol_str_slice_contains(const struct sol_str_slice haystack, const struct sol_str_slice needle)
Checks if haystack contains needle.
Data type describing the default blob implementation.
Definition: sol-types.h:468
#define SOL_ATTR_NON_NULL(...)
Specifies that some function parameters should be non-null pointers.
Definition: sol-macros.h:193
#define SOL_STR_SLICE_STR(_s, _len)
Helper macro to make easier to declare a string slice from a string.
Definition: sol-str-slice.h:67
static bool sol_str_slice_case_eq(const struct sol_str_slice a, const struct sol_str_slice b)
Checks if the content of both slices are equal.
Definition: sol-str-slice.h:152
int sol_str_slice_to_int(const struct sol_str_slice s, long int *value)
Converts a string slice to an integer.
Soletta vector is an array that grows dynamically.
Definition: sol-vector.h:58
static struct sol_blob * sol_str_slice_to_blob(const struct sol_str_slice slice)
Creates a blob from a slice.
Definition: sol-str-slice.h:270
static char * sol_str_slice_to_str(const struct sol_str_slice slice)
Creates a string from a string slice.
Definition: sol-str-slice.h:312
static bool sol_str_slice_eq(const struct sol_str_slice a, const struct sol_str_slice b)
Checks if the content of both slices are equal.
Definition: sol-str-slice.h:116
static bool sol_str_slice_str_eq(const struct sol_str_slice a, const char *b)
Checks if the content of the slice is equal to the string.
Definition: sol-str-slice.h:100
size_t len
Slice length.
Definition: sol-str-slice.h:85
static bool sol_str_slice_str_split_iterate(const struct sol_str_slice slice, struct sol_str_slice *token, const char **itr, const char *delim)
Wrapper over sol_str_slice_split_iterate()
Definition: sol-str-slice.h:431
static void sol_str_slice_copy(char *dst, const struct sol_str_slice src)
Copies the content of slice src into string dst.
Definition: sol-str-slice.h:190
struct sol_vector sol_str_slice_split(const struct sol_str_slice slice, const char *delim, size_t maxsplit)
Return a list of the words in a given string slice, using delim as delimiter string.