Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
sol-str-slice.h File Reference

These are routines that Soletta provides for its string slice implementation. More...

#include <ctype.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sol-macros.h>
#include <sol-types.h>

Go to the source code of this file.

Data Structures

struct  sol_str_slice
 String slice type. More...
 

Macros

#define SOL_STR_SLICE_EMPTY   { .len = 0, .data = "" }
 Helper macro to make easier to declare an empty string slice. More...
 
#define SOL_STR_SLICE_LITERAL(_s)   { (sizeof(SOL_STR_STATIC_ASSERT_LITERAL(_s)) - 1), (_s) }
 Helper macro to make easier to declare a string slice from a string literal. More...
 
#define SOL_STR_SLICE_PRINT(_s)   (int)(_s).len, (_s).data
 Helper macro to be used together with "%.*s" formatting in 'printf()' family of functions. More...
 
#define SOL_STR_SLICE_STR(_s, _len)   (struct sol_str_slice){.len = (_len), .data = (_s) }
 Helper macro to make easier to declare a string slice from a string. More...
 
#define SOL_STR_STATIC_ASSERT_LITERAL(_s)   ("" _s)
 Helper macro to assert that the parameter is a string literal. More...
 

Typedefs

typedef struct sol_str_slice sol_str_slice
 String slice type. More...
 

Functions

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. More...
 
char * sol_str_slice_contains (const struct sol_str_slice haystack, const struct sol_str_slice needle)
 Checks if haystack contains needle. More...
 
static void sol_str_slice_copy (char *dst, const struct sol_str_slice src)
 Copies the content of slice src into string dst. More...
 
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. More...
 
static struct sol_str_slice sol_str_slice_from_blob (const struct sol_blob *blob)
 Populates a slice from a sol_blob. More...
 
static struct sol_str_slice sol_str_slice_from_str (const char *s)
 Populates a slice from a string. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static char * sol_str_slice_str_contains (const struct sol_str_slice haystack, const char *needle)
 Checks if haystack contains needle. More...
 
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. More...
 
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() More...
 
static bool sol_str_slice_str_starts_with (const struct sol_str_slice slice, const char *prefix)
 Checks if slice begins with prefix. More...
 
static struct sol_blobsol_str_slice_to_blob (const struct sol_str_slice slice)
 Creates a blob from a slice. More...
 
int sol_str_slice_to_int (const struct sol_str_slice s, long int *value)
 Converts a string slice to an integer. More...
 
static char * sol_str_slice_to_str (const struct sol_str_slice slice)
 Creates a string from a string slice. More...
 
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. More...
 

Detailed Description

These are routines that Soletta provides for its string slice implementation.