# My Digital Signal Controller Library # The objective of MyDSC library is to implement controllers with help digital signal processors, digital signal controllers or mixed signals processors.

Dependents:   mydsc_sampling_example mydsc_sampling_example mydsc-serial-example mydsc-nonblocking-example

Committer:
ghsalazar
Date:
Wed Mar 04 13:38:48 2020 +0000
Revision:
2:1f276b0dd807
Parent:
1:2c47778e8a67
Child:
4:90c3f1288d41
Documenting interface.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ghsalazar 1:2c47778e8a67 1 /** @file: mydsc_kvp.h
ghsalazar 1:2c47778e8a67 2 @author Gastón H. Salazar-Silva <gaston_salazar@yahoo.com>
ghsalazar 2:1f276b0dd807 3
ghsalazar 2:1f276b0dd807 4 @brief A very basic key-value pair system is implemented.
ghsalazar 1:2c47778e8a67 5 **/
ghsalazar 1:2c47778e8a67 6
ghsalazar 1:2c47778e8a67 7 #ifndef MYDSC_kvp_H
ghsalazar 1:2c47778e8a67 8 #define MYDSC_kvp_H
ghsalazar 1:2c47778e8a67 9
ghsalazar 1:2c47778e8a67 10 #include <stdint.h>
ghsalazar 1:2c47778e8a67 11
ghsalazar 1:2c47778e8a67 12 #ifdef __cplusplus
ghsalazar 1:2c47778e8a67 13 extern "C" {
ghsalazar 1:2c47778e8a67 14 #endif
ghsalazar 1:2c47778e8a67 15
ghsalazar 2:1f276b0dd807 16 /// Error conditions on looking-up a key, or trying to setting the value.
ghsalazar 1:2c47778e8a67 17 enum mydsc_kvp_errno_t {
ghsalazar 1:2c47778e8a67 18 MYDSC_KVP_SUCCESS = 0,
ghsalazar 1:2c47778e8a67 19 MYDSC_KVP_NO_SET = -1,
ghsalazar 1:2c47778e8a67 20 MYDSC_KVP_NO_KEY = -2,
ghsalazar 1:2c47778e8a67 21 MYDSC_KVP_WRONG_VALUE = -3
ghsalazar 1:2c47778e8a67 22 };
ghsalazar 1:2c47778e8a67 23
ghsalazar 2:1f276b0dd807 24 /// The structure sets a linked list up.
ghsalazar 1:2c47778e8a67 25 typedef struct mydsc_kvp_struct {
ghsalazar 1:2c47778e8a67 26 char *key;
ghsalazar 1:2c47778e8a67 27 char* (*get_function)(void);
ghsalazar 1:2c47778e8a67 28 int (*set_function)(char*);
ghsalazar 1:2c47778e8a67 29 struct mydsc_kvp_struct *next_kvp;
ghsalazar 1:2c47778e8a67 30 } mydsc_kvp_t;
ghsalazar 1:2c47778e8a67 31
ghsalazar 2:1f276b0dd807 32 /// Initialize the linked list, then puts a first key ("version")
ghsalazar 2:1f276b0dd807 33 /// @param pkv is a pointer to the linked list.
ghsalazar 1:2c47778e8a67 34 int mydsc_kvp_init(mydsc_kvp_t* pkv);
ghsalazar 2:1f276b0dd807 35
ghsalazar 2:1f276b0dd807 36 /// Returns the value associated with a key.
ghsalazar 2:1f276b0dd807 37 /// @param pkv is a pointer to the linked list.
ghsalazar 2:1f276b0dd807 38 /// @param key is a character string to look-up in the linked list.
ghsalazar 2:1f276b0dd807 39 /// @return The value associated to the key, as a character string.
ghsalazar 1:2c47778e8a67 40 char* mydsc_kvp_get_value(mydsc_kvp_t* pkv, char* key);
ghsalazar 2:1f276b0dd807 41
ghsalazar 2:1f276b0dd807 42 /// Sets or change the value associated with a key.
ghsalazar 2:1f276b0dd807 43 /// @param pkv is a pointer to the linked list.
ghsalazar 2:1f276b0dd807 44 /// @param key is a character string to look-up in the linked list.
ghsalazar 2:1f276b0dd807 45 /// @param value is the new setting, encoded as a character string.
ghsalazar 2:1f276b0dd807 46 /// @return an error encoded as a mydsc_kvp_errno_t.
ghsalazar 1:2c47778e8a67 47 int mydsc_kvp_set_value(mydsc_kvp_t* pkv, char* key, char* value);
ghsalazar 2:1f276b0dd807 48
ghsalazar 2:1f276b0dd807 49 /// Appends a new key-value pair into the linked list.
ghsalazar 2:1f276b0dd807 50 /// @param pkv is a pointer to the linked list.
ghsalazar 2:1f276b0dd807 51 /// @param key is a character string to look-up in the linked list.
ghsalazar 2:1f276b0dd807 52 /// @param get_function is a pointer to a function.
ghsalazar 2:1f276b0dd807 53 /// @param set_function is a pointer to a function.
ghsalazar 2:1f276b0dd807 54 /// @return an error encoded as a mydsc_kvp_errno_t.
ghsalazar 1:2c47778e8a67 55 int mydsc_kvp_append(mydsc_kvp_t* pkv, char* key,
ghsalazar 1:2c47778e8a67 56 char* (*get_function)(void),
ghsalazar 1:2c47778e8a67 57 int (*set_function)(char*));
ghsalazar 1:2c47778e8a67 58
ghsalazar 1:2c47778e8a67 59 #ifdef __cplusplus
ghsalazar 1:2c47778e8a67 60 }
ghsalazar 1:2c47778e8a67 61 #endif
ghsalazar 1:2c47778e8a67 62
ghsalazar 1:2c47778e8a67 63 #endif // MYDSC_RING_BUFFER_H