LCOV - code coverage report
Current view: top level - src/libs/highlevel - elektra_array_value.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 113 131 86.3 %
Date: 2019-09-12 12:28:41 Functions: 32 33 97.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief Elektra High Level API.
       5             :  *
       6             :  * @copyright BSD License (see doc/LICENSE.md or http://www.libelektra.org)
       7             :  */
       8             : 
       9             : #include "elektra.h"
      10             : #include "elektra/conversion.h"
      11             : #include "elektra/errors.h"
      12             : #include "kdbease.h"
      13             : #include "kdbhelper.h"
      14             : #include "kdbprivate.h"
      15             : 
      16             : #include <stdlib.h>
      17             : #include <string.h>
      18             : 
      19             : #ifdef __cplusplus
      20             : extern "C" {
      21             : #endif
      22             : 
      23             : #define CHECK_ERROR(elektra, error)                                                                                                        \
      24             :         if (error == NULL)                                                                                                                 \
      25             :         {                                                                                                                                  \
      26             :                 elektraFatalError (elektra, elektraErrorNullError (__func__));                                                             \
      27             :                 return;                                                                                                                    \
      28             :         }
      29             : 
      30             : /**
      31             :  * Sets the size of an array
      32             :  *
      33             :  * @param elektra The Elektra instance to use.
      34             :  * @param name    The (relative) name of the array.
      35             :  * @param size    The new size of the array.
      36             :  */
      37          38 : static void elektraArraySetSize (Elektra * elektra, const char * name, kdb_long_long_t size, ElektraError ** error)
      38             : {
      39          38 :         elektraSetLookupKey (elektra, name);
      40          38 :         Key * arrayParent = keyDup (elektra->lookupKey);
      41             : 
      42             :         char sizeString[ELEKTRA_MAX_ARRAY_SIZE];
      43          38 :         elektraWriteArrayNumber (sizeString, size - 1);
      44          38 :         keySetMeta (arrayParent, "array", sizeString);
      45          38 :         keySetString (arrayParent, "");
      46             : 
      47          38 :         elektraSaveKey (elektra, arrayParent, error);
      48          38 : }
      49             : 
      50             : /**
      51             :  * \addtogroup highlevel High-level API
      52             :  * @{
      53             :  */
      54             : 
      55             : /**
      56             :  * Gets the size of an array.
      57             :  *
      58             :  * @param elektra The Elektra instance to use.
      59             :  * @param name    The (relative) name of the array.
      60             :  * @return the size of the array, 0 is returned if the array is empty or doesn't exist
      61             :  */
      62         168 : kdb_long_long_t elektraArraySize (Elektra * elektra, const char * name)
      63             : {
      64         168 :         elektraSetLookupKey (elektra, name);
      65         168 :         Key * const arrayParent = ksLookup (elektra->config, elektra->lookupKey, 0);
      66         168 :         if (arrayParent == NULL)
      67             :         {
      68             :                 return 0;
      69             :         }
      70             : 
      71          98 :         const Key * const metaKey = keyGetMeta (arrayParent, "array");
      72          98 :         if (metaKey == NULL)
      73             :         {
      74             :                 return 0;
      75             :         }
      76             : 
      77          98 :         const char * sizeString = keyString (metaKey);
      78          98 :         int digitStart = elektraArrayValidateBaseNameString (sizeString);
      79          98 :         if (digitStart <= 0)
      80             :         {
      81             :                 return 0;
      82             :         }
      83             : 
      84          98 :         kdb_long_long_t size = strtoll (&sizeString[digitStart], NULL, 10) + 1;
      85             : 
      86          98 :         return size;
      87             : }
      88             : 
      89             : /**
      90             :  * Helper function for code generation.
      91             :  *
      92             :  * Finds an array element Key from its relative name and index.
      93             :  * Also checks type metadata, if @p type is not NULL.
      94             :  *
      95             :  * @param elektra The Elektra instance to use.
      96             :  * @param name    The relative name of the array.
      97             :  * @param index   The index of the array element.
      98             :  * @param type    The expected type metadata value.
      99             :  * @return the Key referenced by @p name or NULL, if a fatal error occurs and the fatal error handler returns to this function
     100             :  *   The returned pointer remains valid until the KeySet inside @p elektra is modified. Calls to elektraSet*() functions may
     101             :  *   cause such modifications. In any case, it becomes invalid when elektraClose() is called on @p elektra.
     102             :  */
     103          58 : Key * elektraFindArrayElementKey (Elektra * elektra, const char * name, kdb_long_long_t index, KDBType type)
     104             : {
     105          58 :         elektraSetArrayLookupKey (elektra, name, index);
     106          58 :         Key * const resultKey = ksLookup (elektra->config, elektra->lookupKey, 0);
     107          58 :         if (resultKey == NULL)
     108             :         {
     109           0 :                 elektraFatalError (elektra, elektraErrorKeyNotFound (keyName (elektra->lookupKey)));
     110           0 :                 return NULL;
     111             :         }
     112             : 
     113          58 :         if (type != NULL)
     114             :         {
     115          56 :                 const char * actualType = keyString (keyGetMeta (resultKey, "type"));
     116          56 :                 if (strcmp (actualType, type) != 0)
     117             :                 {
     118           0 :                         elektraFatalError (elektra, elektraErrorWrongType (keyName (elektra->lookupKey), type, actualType));
     119           0 :                         return NULL;
     120             :                 }
     121             :         }
     122             : 
     123             :         return resultKey;
     124             : }
     125             : 
     126             : /**
     127             :  * Resolves the reference stored in a key.
     128             :  * 1. Get the raw string value.
     129             :  * 2. Resolve that reference.
     130             :  * 3. Return resulting keyname relative to the parent key of the given Elektra instance.
     131             :  *
     132             :  * IMPORTANT: this method DOES NOT check the type metadata of the key, it is only intended
     133             :  * to be used by the code-generation API.
     134             :  *
     135             :  * @param elektra The Elektra instance to use.
     136             :  * @param name    The (relative) name of the array.
     137             :  * @param index   The index of the array element.
     138             :  * @return the resolved version of the reference stored in the specified key (relative to the parent key of @p elektra)
     139             :  * or NULL, if the key was not found, or the reference resolves two a key not below the parent key. The empty string is
     140             :  * returned, if the value was the empty string (no resolution is attempted).
     141             :  *   The returned pointer becomes invalid when this function is called again (even with the same arguments). It is also
     142             :  *   invalidated when elektraFindReference() or elektraClose() are called on @p elektra.
     143             :  */
     144           0 : const char * elektraFindReferenceArrayElement (Elektra * elektra, const char * name, kdb_long_long_t index)
     145             : {
     146           0 :         elektraSetArrayLookupKey (elektra, name, index);
     147           0 :         Key * const resultKey = ksLookup (elektra->config, elektra->lookupKey, 0);
     148           0 :         if (resultKey == NULL)
     149             :         {
     150             :                 return NULL;
     151             :         }
     152             : 
     153           0 :         const char * reference = keyString (resultKey);
     154             : 
     155           0 :         if (strlen (reference) == 0)
     156             :         {
     157             :                 return "";
     158             :         }
     159             : 
     160           0 :         if (elektra->resolvedReference != NULL)
     161             :         {
     162           0 :                 elektraFree (elektra->resolvedReference);
     163           0 :                 elektra->resolvedReference = NULL;
     164             :         }
     165             : 
     166           0 :         elektra->resolvedReference = elektraResolveReference (reference, elektra->lookupKey, elektra->parentKey);
     167             : 
     168           0 :         size_t len = strlen (elektra->resolvedReference);
     169           0 :         if (len < elektra->parentKeyLength ||
     170           0 :             strncmp (keyName (elektra->parentKey), elektra->resolvedReference, elektra->parentKeyLength) != 0)
     171             :         {
     172             :                 return NULL;
     173             :         }
     174             : 
     175           0 :         return &elektra->resolvedReference[elektra->parentKeyLength];
     176             : }
     177             : 
     178             : /**
     179             :  * Reads the type metadata of a given array element.
     180             :  *
     181             :  * @param elektra An Elektra instance.
     182             :  * @param name    The name of the array.
     183             :  * @param index   The index of the array element whose type information shall be read.
     184             :  * @return the KDBType of the key
     185             :  */
     186           2 : KDBType elektraGetArrayElementType (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     187             : {
     188           2 :         elektraSetArrayLookupKey (elektra, keyname, index);
     189           2 :         const Key * key = elektraFindArrayElementKey (elektra, keyname, index, NULL);
     190           2 :         const Key * metaKey = keyGetMeta (key, "type");
     191           2 :         return metaKey == NULL ? NULL : keyString (metaKey);
     192             : }
     193             : 
     194             : /**
     195             :  * Get the raw string value of an array element key.
     196             :  *
     197             :  * @param elektra The Elektra instance to use.
     198             :  * @param name    The (relative) name of the array.
     199             :  * @param index   The index of the array element.
     200             :  * @return the raw value of the specified key, or NULL if the key was not found
     201             :  *   The returned pointer remains valid until the internal state of @p elektra is modified.
     202             :  *   Calls to elektraSet*() functions may cause such modifications. In any case, it becomes
     203             :  *   invalid when elektraClose() is called on @p elektra.
     204             :  */
     205          10 : const char * elektraGetRawStringArrayElement (Elektra * elektra, const char * name, kdb_long_long_t index)
     206             : {
     207          10 :         elektraSetArrayLookupKey (elektra, name, index);
     208          10 :         Key * const resultKey = ksLookup (elektra->config, elektra->lookupKey, 0);
     209          10 :         return resultKey == NULL ? NULL : keyString (resultKey);
     210             : }
     211             : 
     212             : /**
     213             :  * Set the raw string value of an array element key.
     214             :  *
     215             :  * @param elektra The Elektra instance to use.
     216             :  * @param name    The (relative) name of the array.
     217             :  * @param index   The index of the array element.
     218             :  * @param value   The raw value to set.
     219             :  * @param type    The type to set in the metadata of the (array element) key.
     220             :  * @param error   Pointer to an ElektraError. Will be set in case saving fails.
     221             :  */
     222         134 : void elektraSetRawStringArrayElement (Elektra * elektra, const char * name, kdb_long_long_t index, const char * value, KDBType type,
     223             :                                       ElektraError ** error)
     224             : {
     225         134 :         CHECK_ERROR (elektra, error);
     226             : 
     227         134 :         if (elektraArraySize (elektra, name) < index)
     228             :         {
     229          38 :                 elektraArraySetSize (elektra, name, index + 1, error);
     230          38 :                 if (*error != NULL)
     231             :                 {
     232             :                         return;
     233             :                 }
     234             :         }
     235             : 
     236         134 :         elektraSetArrayLookupKey (elektra, name, index);
     237         134 :         Key * key = ksLookup (elektra->config, elektra->lookupKey, 0);
     238         134 :         if (key == NULL)
     239             :         {
     240          74 :                 key = keyDup (elektra->lookupKey);
     241             :         }
     242         134 :         keySetMeta (key, "type", type);
     243         134 :         keySetString (key, value);
     244             : 
     245         134 :         elektraSaveKey (elektra, key, error);
     246             : }
     247             : 
     248             : #define ELEKTRA_GET_ARRAY_ELEMENT_VALUE(KEY_TO_VALUE, KDB_TYPE, elektra, keyname, index, result)                                           \
     249             :         const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE);                                                  \
     250             :         if (key == NULL || !KEY_TO_VALUE (key, &result))                                                                                   \
     251             :         {                                                                                                                                  \
     252             :                 elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE, keyname, keyString (key)));                        \
     253             :                 return 0;                                                                                                                  \
     254             :         }
     255             : 
     256             : /**
     257             :  * Gets a string value array element.
     258             :  *
     259             :  * @param elektra The elektra instance to use.
     260             :  * @param keyname The (relative) name of the array to look up.
     261             :  * @param index   The index of the array element to look up.
     262             :  * @return the string stored at the given array element
     263             :  *   The returned pointer remains valid until the internal state of @p elektra is modified.
     264             :  *   Calls to elektraSet*() functions may cause such modifications. In any case, it becomes
     265             :  *   invalid when elektraClose() is called on @p elektra.
     266             :  */
     267           4 : const char * elektraGetStringArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     268             : {
     269             :         const char * result;
     270           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToString, KDB_TYPE_STRING, elektra, keyname, index, result);
     271           4 :         return result;
     272             : }
     273             : 
     274             : /**
     275             :  * Gets a boolean value array element.
     276             :  *
     277             :  * @param elektra The elektra instance to use.
     278             :  * @param keyname The (relative) name of the array to look up.
     279             :  * @param index   The index of the array element to look up.
     280             :  * @return the boolean stored at the given array element
     281             :  */
     282           4 : kdb_boolean_t elektraGetBooleanArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     283             : {
     284             :         kdb_boolean_t result;
     285           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToBoolean, KDB_TYPE_BOOLEAN, elektra, keyname, index, result);
     286           4 :         return result;
     287             : }
     288             : 
     289             : /**
     290             :  * Gets a char value array element.
     291             :  *
     292             :  * @param elektra The elektra instance to use.
     293             :  * @param keyname The (relative) name of the array to look up.
     294             :  * @param index   The index of the array element to look up.
     295             :  * @return the char stored at the given array element
     296             :  */
     297           4 : kdb_char_t elektraGetCharArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     298             : {
     299             :         kdb_char_t result;
     300           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToChar, KDB_TYPE_CHAR, elektra, keyname, index, result);
     301           4 :         return result;
     302             : }
     303             : 
     304             : /**
     305             :  * Gets an octet value array element.
     306             :  *
     307             :  * @param elektra The elektra instance to use.
     308             :  * @param keyname The (relative) name of the array to look up.
     309             :  * @param index   The index of the array element to look up.
     310             :  * @return the octet stored at the given array element
     311             :  */
     312           4 : kdb_octet_t elektraGetOctetArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     313             : {
     314             :         kdb_octet_t result;
     315           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToOctet, KDB_TYPE_OCTET, elektra, keyname, index, result);
     316           4 :         return result;
     317             : }
     318             : 
     319             : /**
     320             :  * Gets a short value array element.
     321             :  *
     322             :  * @param elektra The elektra instance to use.
     323             :  * @param keyname The (relative) name of the array to look up.
     324             :  * @param index   The index of the array element to look up.
     325             :  * @return the short stored at the given array element
     326             :  */
     327           4 : kdb_short_t elektraGetShortArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     328             : {
     329             :         kdb_short_t result;
     330           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToShort, KDB_TYPE_SHORT, elektra, keyname, index, result);
     331           4 :         return result;
     332             : }
     333             : 
     334             : /**
     335             :  * Gets a unsigned short value array element.
     336             :  *
     337             :  * @param elektra The elektra instance to use.
     338             :  * @param keyname The (relative) name of the array to look up.
     339             :  * @param index   The index of the array element to look up.
     340             :  * @return the unsigned short stored at the given array element
     341             :  */
     342           4 : kdb_unsigned_short_t elektraGetUnsignedShortArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     343             : {
     344             :         kdb_unsigned_short_t result;
     345           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToUnsignedShort, KDB_TYPE_UNSIGNED_SHORT, elektra, keyname, index, result);
     346           4 :         return result;
     347             : }
     348             : 
     349             : /**
     350             :  * Gets a long value array element.
     351             :  *
     352             :  * @param elektra The elektra instance to use.
     353             :  * @param keyname The (relative) name of the array to look up.
     354             :  * @param index   The index of the array element to look up.
     355             :  * @return the long stored at the given array element
     356             :  */
     357           8 : kdb_long_t elektraGetLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     358             : {
     359             :         kdb_long_t result;
     360           8 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToLong, KDB_TYPE_LONG, elektra, keyname, index, result);
     361           8 :         return result;
     362             : }
     363             : 
     364             : /**
     365             :  * Gets a unsigned long value array element.
     366             :  *
     367             :  * @param elektra The elektra instance to use.
     368             :  * @param keyname The (relative) name of the array to look up.
     369             :  * @param index   The index of the array element to look up.
     370             :  * @return the unsigned long stored at the given array element
     371             :  */
     372           4 : kdb_unsigned_long_t elektraGetUnsignedLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     373             : {
     374             :         kdb_unsigned_long_t result;
     375           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToUnsignedLong, KDB_TYPE_UNSIGNED_LONG, elektra, keyname, index, result);
     376           4 :         return result;
     377             : }
     378             : 
     379             : /**
     380             :  * Gets a long long value array element.
     381             :  *
     382             :  * @param elektra The elektra instance to use.
     383             :  * @param keyname The (relative) name of the array to look up.
     384             :  * @param index   The index of the array element to look up.
     385             :  * @return the long long stored at the given array element
     386             :  */
     387           4 : kdb_long_long_t elektraGetLongLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     388             : {
     389             :         kdb_long_long_t result;
     390           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToLongLong, KDB_TYPE_LONG_LONG, elektra, keyname, index, result);
     391           4 :         return result;
     392             : }
     393             : 
     394             : /**
     395             :  * Gets a unsigned long long value array element.
     396             :  *
     397             :  * @param elektra The elektra instance to use.
     398             :  * @param keyname The (relative) name of the array to look up.
     399             :  * @param index   The index of the array element to look up.
     400             :  * @return the unsigned long long stored at the given array element
     401             :  */
     402           4 : kdb_unsigned_long_long_t elektraGetUnsignedLongLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     403             : {
     404             :         kdb_unsigned_long_long_t result;
     405           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToUnsignedLongLong, KDB_TYPE_UNSIGNED_LONG_LONG, elektra, keyname, index, result);
     406           4 :         return result;
     407             : }
     408             : 
     409             : /**
     410             :  * Gets a float value array element.
     411             :  *
     412             :  * @param elektra The elektra instance to use.
     413             :  * @param keyname The (relative) name of the array to look up.
     414             :  * @param index   The index of the array element to look up.
     415             :  * @return the float stored at the given array element
     416             :  */
     417           4 : kdb_float_t elektraGetFloatArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     418             : {
     419             :         kdb_float_t result;
     420           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToFloat, KDB_TYPE_FLOAT, elektra, keyname, index, result);
     421           4 :         return result;
     422             : }
     423             : 
     424             : /**
     425             :  * Gets a double value array element.
     426             :  *
     427             :  * @param elektra The elektra instance to use.
     428             :  * @param keyname The (relative) name of the array to look up.
     429             :  * @param index   The index of the array element to look up.
     430             :  * @return the double stored at the given array element
     431             :  */
     432           4 : kdb_double_t elektraGetDoubleArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     433             : {
     434             :         kdb_double_t result;
     435           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToDouble, KDB_TYPE_DOUBLE, elektra, keyname, index, result);
     436           4 :         return result;
     437             : }
     438             : 
     439             : #ifdef ELEKTRA_HAVE_KDB_LONG_DOUBLE
     440             : 
     441             : /**
     442             :  * Gets a long double value array element.
     443             :  *
     444             :  * @param elektra The elektra instance to use.
     445             :  * @param keyname The (relative) name of the array to look up.
     446             :  * @param index   The index of the array element to look up.
     447             :  * @return the long double stored at the given array element
     448             :  */
     449           4 : kdb_long_double_t elektraGetLongDoubleArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index)
     450             : {
     451             :         kdb_long_double_t result;
     452           4 :         ELEKTRA_GET_ARRAY_ELEMENT_VALUE (elektraKeyToLongDouble, KDB_TYPE_LONG_DOUBLE, elektra, keyname, index, result);
     453           4 :         return result;
     454             : }
     455             : 
     456             : #endif // ELEKTRA_HAVE_KDB_LONG_DOUBLE
     457             : 
     458             : #define ELEKTRA_SET_ARRAY_ELEMENT_VALUE(VALUE_TO_STRING, KDB_TYPE, elektra, keyname, index, value, error)                                  \
     459             :         CHECK_ERROR (elektra, error);                                                                                                      \
     460             :         char * string = VALUE_TO_STRING (value);                                                                                           \
     461             :         if (string == 0)                                                                                                                   \
     462             :         {                                                                                                                                  \
     463             :                 *error = elektraErrorConversionToString (KDB_TYPE, keyname);                                                               \
     464             :                 return;                                                                                                                    \
     465             :         }                                                                                                                                  \
     466             :         elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE, error);                                                \
     467             :         elektraFree (string);
     468             : 
     469             : /**
     470             :  * Sets a string value array element.
     471             :  *
     472             :  * @param elektra The elektra instance to use.
     473             :  * @param keyname The (relative) name of the array to write to.
     474             :  * @param index   The index of the array element to write to.
     475             :  * @param value   The new string value.
     476             :  * @param error   Pass a reference to an ElektraError pointer.
     477             :  *                Will only be set in case of an error.
     478             :  */
     479           8 : void elektraSetStringArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, const char * value,
     480             :                                    ElektraError ** error)
     481             : {
     482           8 :         CHECK_ERROR (elektra, error);
     483           8 :         elektraSetRawStringArrayElement (elektra, keyname, index, value, KDB_TYPE_STRING, error);
     484             : }
     485             : 
     486             : /**
     487             :  * Sets a boolean value array element.
     488             :  *
     489             :  * @param elektra The elektra instance to use.
     490             :  * @param keyname The (relative) name of the array to write to.
     491             :  * @param index   The index of the array element to write to.
     492             :  * @param value   The new boolean value.
     493             :  * @param error   Pass a reference to an ElektraError pointer.
     494             :  *                Will only be set in case of an error.
     495             :  */
     496           8 : void elektraSetBooleanArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_boolean_t value,
     497             :                                     ElektraError ** error)
     498             : {
     499           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraBooleanToString, KDB_TYPE_BOOLEAN, elektra, keyname, index, value, error);
     500             : }
     501             : 
     502             : /**
     503             :  * Sets a char value array element.
     504             :  *
     505             :  * @param elektra The elektra instance to use.
     506             :  * @param keyname The (relative) name of the array to write to.
     507             :  * @param index   The index of the array element to write to.
     508             :  * @param value   The new char value.
     509             :  * @param error   Pass a reference to an ElektraError pointer.
     510             :  *                Will only be set in case of an error.
     511             :  */
     512           8 : void elektraSetCharArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_char_t value, ElektraError ** error)
     513             : {
     514           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraCharToString, KDB_TYPE_CHAR, elektra, keyname, index, value, error);
     515             : }
     516             : 
     517             : /**
     518             :  * Sets an octet value array element.
     519             :  *
     520             :  * @param elektra The elektra instance to use.
     521             :  * @param keyname The (relative) name of the array to write to.
     522             :  * @param index   The index of the array element to write to.
     523             :  * @param value   The new octet value.
     524             :  * @param error   Pass a reference to an ElektraError pointer.
     525             :  *                Will only be set in case of an error.
     526             :  */
     527           8 : void elektraSetOctetArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_octet_t value, ElektraError ** error)
     528             : {
     529           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraOctetToString, KDB_TYPE_OCTET, elektra, keyname, index, value, error);
     530             : }
     531             : 
     532             : /**
     533             :  * Sets a short value array element.
     534             :  *
     535             :  * @param elektra The elektra instance to use.
     536             :  * @param keyname The (relative) name of the array to write to.
     537             :  * @param index   The index of the array element to write to.
     538             :  * @param value   The new short value.
     539             :  * @param error   Pass a reference to an ElektraError pointer.
     540             :  *                Will only be set in case of an error.
     541             :  */
     542           8 : void elektraSetShortArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_short_t value, ElektraError ** error)
     543             : {
     544           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraShortToString, KDB_TYPE_SHORT, elektra, keyname, index, value, error);
     545             : }
     546             : 
     547             : /**
     548             :  * Sets a unsigned short value array element.
     549             :  *
     550             :  * @param elektra The elektra instance to use.
     551             :  * @param keyname The (relative) name of the array to write to.
     552             :  * @param index   The index of the array element to write to.
     553             :  * @param value   The new unsigned short value.
     554             :  * @param error   Pass a reference to an ElektraError pointer.
     555             :  *                Will only be set in case of an error.
     556             :  */
     557           8 : void elektraSetUnsignedShortArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_unsigned_short_t value,
     558             :                                           ElektraError ** error)
     559             : {
     560           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraUnsignedShortToString, KDB_TYPE_UNSIGNED_SHORT, elektra, keyname, index, value, error);
     561             : }
     562             : 
     563             : /**
     564             :  * Sets a long value array element.
     565             :  *
     566             :  * @param elektra The elektra instance to use.
     567             :  * @param keyname The (relative) name of the array to write to.
     568             :  * @param index   The index of the array element to write to.
     569             :  * @param value   The new long value.
     570             :  * @param error   Pass a reference to an ElektraError pointer.
     571             :  *                Will only be set in case of an error.
     572             :  */
     573          24 : void elektraSetLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_long_t value, ElektraError ** error)
     574             : {
     575          24 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraLongToString, KDB_TYPE_LONG, elektra, keyname, index, value, error);
     576             : }
     577             : 
     578             : /**
     579             :  * Sets a unsigned long value array element.
     580             :  *
     581             :  * @param elektra The elektra instance to use.
     582             :  * @param keyname The (relative) name of the array to write to.
     583             :  * @param index   The index of the array element to write to.
     584             :  * @param value   The new unsigned long value.
     585             :  * @param error   Pass a reference to an ElektraError pointer.
     586             :  *                Will only be set in case of an error.
     587             :  */
     588          16 : void elektraSetUnsignedLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_unsigned_long_t value,
     589             :                                          ElektraError ** error)
     590             : {
     591          16 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraUnsignedLongToString, KDB_TYPE_UNSIGNED_LONG, elektra, keyname, index, value, error);
     592             : }
     593             : 
     594             : /**
     595             :  * Sets a long long value array element.
     596             :  *
     597             :  * @param elektra The elektra instance to use.
     598             :  * @param keyname The (relative) name of the array to write to.
     599             :  * @param index   The index of the array element to write to.
     600             :  * @param value   The new long long value.
     601             :  * @param error   Pass a reference to an ElektraError pointer.
     602             :  *                Will only be set in case of an error.
     603             :  */
     604           8 : void elektraSetLongLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_long_long_t value,
     605             :                                      ElektraError ** error)
     606             : {
     607           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraLongLongToString, KDB_TYPE_LONG_LONG, elektra, keyname, index, value, error);
     608             : }
     609             : 
     610             : /**
     611             :  * Sets a unsigned long long value array element.
     612             :  *
     613             :  * @param elektra The elektra instance to use.
     614             :  * @param keyname The (relative) name of the array to write to.
     615             :  * @param index   The index of the array element to write to.
     616             :  * @param value   The new unsigned long long value.
     617             :  * @param error   Pass a reference to an ElektraError pointer.
     618             :  *                Will only be set in case of an error.
     619             :  */
     620           8 : void elektraSetUnsignedLongLongArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_unsigned_long_long_t value,
     621             :                                              ElektraError ** error)
     622             : {
     623           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraUnsignedLongLongToString, KDB_TYPE_UNSIGNED_LONG_LONG, elektra, keyname, index, value,
     624             :                                          error);
     625             : }
     626             : 
     627             : /**
     628             :  * Sets a float value array element.
     629             :  *
     630             :  * @param elektra The elektra instance to use.
     631             :  * @param keyname The (relative) name of the array to write to.
     632             :  * @param index   The index of the array element to write to.
     633             :  * @param value   The new float value.
     634             :  * @param error   Pass a reference to an ElektraError pointer.
     635             :  *                Will only be set in case of an error.
     636             :  */
     637           8 : void elektraSetFloatArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_float_t value, ElektraError ** error)
     638             : {
     639           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraFloatToString, KDB_TYPE_FLOAT, elektra, keyname, index, value, error);
     640             : }
     641             : 
     642             : /**
     643             :  * Sets a double value array element.
     644             :  *
     645             :  * @param elektra The elektra instance to use.
     646             :  * @param keyname The (relative) name of the array to write to.
     647             :  * @param index   The index of the array element to write to.
     648             :  * @param value   The new double value.
     649             :  * @param error   Pass a reference to an ElektraError pointer.
     650             :  *                Will only be set in case of an error.
     651             :  */
     652           8 : void elektraSetDoubleArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_double_t value,
     653             :                                    ElektraError ** error)
     654             : {
     655           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraDoubleToString, KDB_TYPE_DOUBLE, elektra, keyname, index, value, error);
     656             : }
     657             : 
     658             : #ifdef ELEKTRA_HAVE_KDB_LONG_DOUBLE
     659             : 
     660             : /**
     661             :  * Sets a long double value array element.
     662             :  *
     663             :  * @param elektra The elektra instance to use.
     664             :  * @param keyname The (relative) name of the array to write to.
     665             :  * @param index   The index of the array element to write to.
     666             :  * @param value   The new long double value.
     667             :  * @param error   Pass a reference to an ElektraError pointer.
     668             :  *                Will only be set in case of an error.
     669             :  */
     670           8 : void elektraSetLongDoubleArrayElement (Elektra * elektra, const char * keyname, kdb_long_long_t index, kdb_long_double_t value,
     671             :                                        ElektraError ** error)
     672             : {
     673           8 :         ELEKTRA_SET_ARRAY_ELEMENT_VALUE (elektraLongDoubleToString, KDB_TYPE_LONG_DOUBLE, elektra, keyname, index, value, error);
     674             : }
     675             : 
     676             : #endif // ELEKTRA_HAVE_KDB_LONG_DOUBLE
     677             : 
     678             : /**
     679             :  * @}
     680             :  */
     681             : 
     682             : #ifdef __cplusplus
     683             : };
     684             : #endif

Generated by: LCOV version 1.13