NewMadeleine

Documentation

Core types to define data descriptors. More...

Collaboration diagram for Data descriptors:

Data Structures

struct  nm_data_generator_s
 state of a data generator More...
 
struct  nm_data_chunk_s
 chunk of data returned by generators More...
 
struct  nm_data_properties_s
 block of static properties for a given data descriptor More...
 
struct  nm_data_ops_s
 set of operations available on data type. More...
 
struct  nm_data_s
 a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers More...
 
struct  nm_datav_s
 encapsulate a dynamic vector of nm_data More...
 

Macros

#define _NM_DATA_CONTENT_SIZE   64
 maximum size of content descriptor for nm_data More...
 
#define _NM_DATA_GENERATOR_SIZE   64
 maximum content size for generators More...
 
#define NM_DATA_USE_COROUTINE_GENERATOR
 whether to use coroutine-based generators More...
 
#define NM_DATA_USE_COROUTINE_SLICER
 whether to use coroutine-based slicers More...
 
#define NM_DATA_CHUNK_NULL   ((struct nm_data_chunk_s){ .ptr = NULL, .len = 0 })
 
#define nm_data_generator_default_init   &nm_data_generator_coroutine_init
 
#define nm_data_generator_default_next   &nm_data_generator_coroutine_next
 
#define nm_data_generator_default_destroy   &nm_data_generator_coroutine_destroy
 
#define NM_DATA_TYPE(ENAME, CONTENT_TYPE, OPS)
 macro to generate typed functions to init/access data fields. More...
 
#define NM_DATAV_INIT_SIZE   4
 initial size of an nm_datav More...
 

Typedefs

typedef void(* nm_data_apply_t) (void *ptr, nm_len_t len, void *_context)
 function to apply to each data chunk upon traversal More...
 
typedef void(* nm_data_traversal_t) (const void *_content, const nm_data_apply_t apply, void *_context)
 funtion to traverse data with app layout, i.e. More...
 
typedef void(* nm_data_generator_init_t) (const struct nm_data_s *p_data, void *_generator)
 initializes a generator (i.e. More...
 
typedef struct nm_data_chunk_s(* nm_data_generator_next_t) (const struct nm_data_s *p_data, void *_generator)
 returns next data chunk for the given generator. More...
 
typedef void(* nm_data_generator_destroy_t) (const struct nm_data_s *p_data, void *_generator)
 destroys resources allocated by generator More...
 
typedef void(* nm_data_properties_compute_t) (struct nm_data_s *p_data)
 function to compute data properties More...
 

Functions

static int nm_data_chunk_isnull (const struct nm_data_chunk_s *p_chunk)
 
void nm_data_generator_coroutine_init (const struct nm_data_s *p_data, void *_generator)
 
struct nm_data_chunk_s nm_data_generator_coroutine_next (const struct nm_data_s *p_data, void *_generator)
 
void nm_data_generator_coroutine_destroy (const struct nm_data_s *p_data, void *_generator)
 
void nm_data_generator_generic_init (const struct nm_data_s *p_data, void *_generator)
 
struct nm_data_chunk_s nm_data_generator_generic_next (const struct nm_data_s *p_data, void *_generator)
 
void nm_data_default_properties_compute (struct nm_data_s *p_data)
 
static void nm_datav_init (struct nm_datav_s *p_datav)
 initialize a datav More...
 
static void nm_datav_destroy (struct nm_datav_s *p_datav)
 destroys a datav More...
 
static void nm_datav_add_chunk_data (struct nm_datav_s *p_datav, const struct nm_data_s *p_data)
 add a chunk of data to datav; given p_data content is copied. More...
 
static void nm_datav_add_chunk (struct nm_datav_s *p_datav, const void *ptr, nm_len_t len)
 add a chunk of contiguous data to a datav More...
 
static nm_len_t nm_datav_size (struct nm_datav_s *p_datav)
 get the size (number of bytes) of data contained in the datav More...
 
static void nm_datav_uncommit (struct nm_datav_s *p_datav)
 'uncommit' a datav: explicitely declare that nm_data pointing to this datav has been destroyed. More...
 

Detailed Description

Core types to define data descriptors.

Macro Definition Documentation

◆ _NM_DATA_CONTENT_SIZE

#define _NM_DATA_CONTENT_SIZE   64

maximum size of content descriptor for nm_data

Definition at line 73 of file nm_data.h.

◆ _NM_DATA_GENERATOR_SIZE

#define _NM_DATA_GENERATOR_SIZE   64

maximum content size for generators

Definition at line 75 of file nm_data.h.

◆ NM_DATA_CHUNK_NULL

#define NM_DATA_CHUNK_NULL   ((struct nm_data_chunk_s){ .ptr = NULL, .len = 0 })

Definition at line 124 of file nm_data.h.

◆ nm_data_generator_default_destroy

#define nm_data_generator_default_destroy   &nm_data_generator_coroutine_destroy

Definition at line 154 of file nm_data.h.

◆ nm_data_generator_default_init

#define nm_data_generator_default_init   &nm_data_generator_coroutine_init

Definition at line 152 of file nm_data.h.

◆ nm_data_generator_default_next

#define nm_data_generator_default_next   &nm_data_generator_coroutine_next

Definition at line 153 of file nm_data.h.

◆ NM_DATA_TYPE

#define NM_DATA_TYPE (   ENAME,
  CONTENT_TYPE,
  OPS 
)

macro to generate typed functions to init/access data fields.

Parameters
ENAMEis the base name used to build symbols (must be a valid C token)
CONTENT_TYPEis the iterator internal state
OPSis a collection of operations of type nm_data_ops_s for the given type. At least nm_data_ops_s::p_traversal field must be non-NULL; other fields may be NULL and will be filled with default values.
Examples
nm_sr_custom_data.c.

Definition at line 201 of file nm_data.h.

◆ NM_DATA_USE_COROUTINE_GENERATOR

#define NM_DATA_USE_COROUTINE_GENERATOR

whether to use coroutine-based generators

Definition at line 82 of file nm_data.h.

◆ NM_DATA_USE_COROUTINE_SLICER

#define NM_DATA_USE_COROUTINE_SLICER

whether to use coroutine-based slicers

Definition at line 84 of file nm_data.h.

◆ NM_DATAV_INIT_SIZE

#define NM_DATAV_INIT_SIZE   4

initial size of an nm_datav

Definition at line 241 of file nm_data.h.

Typedef Documentation

◆ nm_data_apply_t

typedef void(* nm_data_apply_t) (void *ptr, nm_len_t len, void *_context)

function to apply to each data chunk upon traversal

Examples
nm_sr_custom_data.c.

Definition at line 100 of file nm_data.h.

◆ nm_data_generator_destroy_t

typedef void(* nm_data_generator_destroy_t) (const struct nm_data_s *p_data, void *_generator)

destroys resources allocated by generator

Definition at line 137 of file nm_data.h.

◆ nm_data_generator_init_t

typedef void(* nm_data_generator_init_t) (const struct nm_data_s *p_data, void *_generator)

initializes a generator (i.e.

semi-coroutine) for the given data type

Definition at line 117 of file nm_data.h.

◆ nm_data_generator_next_t

typedef struct nm_data_chunk_s(* nm_data_generator_next_t) (const struct nm_data_s *p_data, void *_generator)

returns next data chunk for the given generator.

_content and _generator must be consistent accross calls no error checking is done

Definition at line 125 of file nm_data.h.

◆ nm_data_properties_compute_t

typedef void(* nm_data_properties_compute_t) (struct nm_data_s *p_data)

function to compute data properties

Definition at line 170 of file nm_data.h.

◆ nm_data_traversal_t

typedef void(* nm_data_traversal_t) (const void *_content, const nm_data_apply_t apply, void *_context)

funtion to traverse data with app layout, i.e.

='map' functional operation

Parameters
_contentcontent description of data type
applyfunction to apply to all chunks
_contextcontext pointer given to apply function

Definition at line 107 of file nm_data.h.

Function Documentation

◆ nm_data_chunk_isnull()

static int nm_data_chunk_isnull ( const struct nm_data_chunk_s p_chunk)
inlinestatic

Definition at line 125 of file nm_data.h.

References nm_data_chunk_s::ptr.

◆ nm_data_default_properties_compute()

void nm_data_default_properties_compute ( struct nm_data_s p_data)

compute data properties; not for enduser, exported for use by inline function

◆ nm_data_generator_coroutine_destroy()

void nm_data_generator_coroutine_destroy ( const struct nm_data_s p_data,
void *  _generator 
)

used internally by NM_DATA_TYPE in nm_data_s

◆ nm_data_generator_coroutine_init()

void nm_data_generator_coroutine_init ( const struct nm_data_s p_data,
void *  _generator 
)

used internally by NM_DATA_TYPE in nm_data_s

◆ nm_data_generator_coroutine_next()

struct nm_data_chunk_s nm_data_generator_coroutine_next ( const struct nm_data_s p_data,
void *  _generator 
)

used internally by NM_DATA_TYPE in nm_data_s

◆ nm_data_generator_generic_init()

void nm_data_generator_generic_init ( const struct nm_data_s p_data,
void *  _generator 
)

used internally by NM_DATA_TYPE in nm_data_s

◆ nm_data_generator_generic_next()

struct nm_data_chunk_s nm_data_generator_generic_next ( const struct nm_data_s p_data,
void *  _generator 
)

used internally by NM_DATA_TYPE in nm_data_s

◆ nm_datav_add_chunk()

static void nm_datav_add_chunk ( struct nm_datav_s p_datav,
const void *  ptr,
nm_len_t  len 
)
inlinestatic

add a chunk of contiguous data to a datav

Definition at line 593 of file nm_data.h.

References len, nm_data_contiguous_build(), and nm_datav_add_chunk_data().

Here is the call graph for this function:

◆ nm_datav_add_chunk_data()

static void nm_datav_add_chunk_data ( struct nm_datav_s p_datav,
const struct nm_data_s p_data 
)
inlinestatic

add a chunk of data to datav; given p_data content is copied.

Definition at line 572 of file nm_data.h.

References nm_datav_s::allocated, nm_datav_s::commited, nm_datav_s::data, nm_datav_s::n_data, NM_DATAV_INIT_SIZE, and nm_datav_s::p_data.

Referenced by nm_datav_add_chunk(), nm_rpc_irecv_body_data(), and nm_rpc_recv_header_data().

Here is the caller graph for this function:

◆ nm_datav_destroy()

static void nm_datav_destroy ( struct nm_datav_s p_datav)
inlinestatic

destroys a datav

Definition at line 562 of file nm_data.h.

References nm_datav_s::data, and nm_datav_s::p_data.

◆ nm_datav_init()

static void nm_datav_init ( struct nm_datav_s p_datav)
inlinestatic

initialize a datav

Definition at line 554 of file nm_data.h.

References nm_datav_s::allocated, nm_datav_s::commited, nm_datav_s::data, nm_datav_s::n_data, and nm_datav_s::p_data.

◆ nm_datav_size()

static nm_len_t nm_datav_size ( struct nm_datav_s p_datav)
inlinestatic

get the size (number of bytes) of data contained in the datav

Definition at line 600 of file nm_data.h.

References nm_datav_s::n_data, nm_data_size(), nm_datav_s::p_data, and size.

Referenced by nm_rpc_recv_header_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nm_datav_uncommit()

static void nm_datav_uncommit ( struct nm_datav_s p_datav)
inlinestatic

'uncommit' a datav: explicitely declare that nm_data pointing to this datav has been destroyed.

Use with care!

Definition at line 611 of file nm_data.h.

References nm_datav_s::commited.

Referenced by nm_rpc_recv_header_data().

Here is the caller graph for this function: