Source

mpi3-fortran / ompi / contrib / vt / vt / extlib / otf / otflib / OTF_KeyValue.h

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
/*
 This is part of the OTF library. Copyright by ZIH, TU Dresden 2005-2012.
 Authors: Andreas Knuepfer, Holger Brunst, Ronny Brendel, Thomas Kriebitzsch, Johannes Spazier
*/

/** 
 *  @file OTF_KeyValue.h
 *
 *  @brief Provides an additional list of key value pairs that can be added to records.
 *
 * \ingroup keyvalue
 */


/** 
 * \defgroup keyvalue KeyValueList Interface
 *
 * Provides an additional list of key-value pairs that can be added to records.
 * 
 *  \section keyvalue_write_example A short Example of writing a KeyValueList
 *
 * You can append key-value pairs to an OTF_KeyValueList instance that can be added to any record.
 *
 * After one call to OTF_Writer_writeXxxKV() the given KeyValueList instance will be empty.
 *
 *  \code
 *  #include <assert.h>
 *  #include "otf.h"
 *
 *  int main( int argc, char** argv ) {
 *
 * 	OTF_FileManager* manager;
 * 	OTF_Writer* writer;
 *	OTF_KeyValueList* KeyValueList;
 *
 * 	manager= OTF_FileManager_open( 100 );
 * 	assert( manager );
 *
 * 	writer = OTF_Writer_open( "mytrace", 1, manager );
 * 	assert( writer );
 *  \endcode
 *
 *  Initialize the prior declared OTF_KeyValueList.
 *
 *  \code
 * 	KeyValueList = OTF_KeyValueList_new();
 *  \endcode
 *
 * Write a DefKeyValue record that assigns key=1 to name="first_arg" with description="first argument of function" and type=OTF_INT32.
 *      \code   
 * 	OTF_Writer_writeDefKeyValue( writer, 0, 1, OTF_INT32, "first_arg", "first argument of function" );
 *      \endcode
 *
 * Append a signed integer for key=1 to the initialized KeyValueList.
 *      \code      
 * 	OTF_KeyValueList_appendInt32( KeyValueList, 1, 25);
 *      \endcode
 *
 * Write the entries of the KeyValueList together with the enter record.
 *	Afterwards the KeyValueList will be empty!
 *      \code
 * 	OTF_Writer_writeEnterKV( writer, 10000, 100, 1, 0, KeyValueList );
 *      \endcode
 *
 *  Clean up before exiting the program. Close the OTF_KeyValueList.
 *      \code
 *	OTF_KeyValueList_close( KeyValueList );
 * 	OTF_Writer_close( writer );
 * 	OTF_FileManager_close( manager );
 *
 * 	return 0;
 * }
 * \endcode
 *
 * Compile this using $ gcc -o write write.c `otfconfig --libs`.
 *
 *
 *  \section keyvalue_read_example A short Example of reading from a KeyValueList
 *
 *  \code
 *  #include <assert.h>
 *  #include <stdio.h>
 *  #include <string.h>
 *  #include "otf.h"
 *
 *  int global_key = 0;
 *
 * \endcode
 *
 * Define a callback to read all DefKeyValue records. 
 * \code
 * int handleDefKeyValue( void* userData, uint32_t stream, uint32_t key, OTF_Type type, const char* name, const char *description ) {
 * \endcode
 *
 * Find out which key you are looking for.
 * 	\code
 * 	if( strcmp( name, "first_arg") == 0 ) {
 *		global_key = key;
 * 	}
 *
 * 	return OTF_RETURN_OK;
 * }
 * \endcode
 *
 * Define a callback to read all enter records. 
 * \code
 * int handleEnter (void *userData, uint64_t time, uint32_t function, uint32_t process, uint32_t source, OTF_KeyValueList *list) {
 *
 * 	int value;
 *
 * \endcode
 * 
 * Ask for a key value pair with key=global_key. Save the value in variable "value".
 * \code
 * 	switch( OTF_KeyValueList_getInt32( list, global_key, &value) ) {
 * 	  case 0:
 * 		 printf("We entered function %u with argument %d\n", function, value);
 * 		 break;
 * 	  case 1:
 *		 printf("We entered function %u with no argument.\n", function);
 * 		 break;
 * 	  default: 
 * 		 printf("An error occurred while asking for key value pair.\n");
 * 	}
 *
 * 	return OTF_RETURN_OK;
 * }
 *
 * \endcode
 *
 * main() includes the common instructions to read an .otf-file.
 * \code
 *  int main( int argc, char** argv ) {
 *
 *  	OTF_FileManager* manager;
 * 	OTF_Reader* reader;
 * 	OTF_HandlerArray* handlers;
 *
 * 	manager= OTF_FileManager_open( 100 );
 * 	assert( manager );
 *
 *	handlers = OTF_HandlerArray_open();
 *	assert( handlers );
 *
 *	reader = OTF_Reader_open( "mytrace", manager );
 *	assert( reader );
 *
 *	OTF_HandlerArray_setHandler( handlers, (OTF_FunctionPointer*) handleDefKeyValue, OTF_DEFKEYVALUE_RECORD );
 *	OTF_HandlerArray_setHandler( handlers, (OTF_FunctionPointer*) handleEnter, OTF_ENTER_RECORD );
 *
 *	OTF_Reader_readDefinitions( reader, handlers );
 *	OTF_Reader_readEvents( reader, handlers );
 * 
 * 	OTF_Reader_close( reader );
 *	OTF_HandlerArray_close( handlers );
 * 	OTF_FileManager_close( manager );
 *
 * 	return 0;
 * }
 * \endcode
 *
 * Compile this using $ gcc -o read read.c `otfconfig --libs`.
 *
 */

#ifndef OTF_KEYVALUE_H
#define OTF_KEYVALUE_H

#include "OTF_inttypes.h"
#include "OTF_Definitions.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


/** An enum which holds all OTF datatypes that are relevant for OTF_KeyValueList. \ingroup miscellaneous */
typedef enum OTF_Type_enum {
    OTF_UNKNOWN = -1,
	OTF_CHAR = 0,		/**< */
	OTF_INT8 = 1, 		/**< */
	OTF_UINT8 = 2, 		/**< */
	OTF_INT16 = 3, 		/**< */
	OTF_UINT16 = 4, 	/**< */
	OTF_INT32 = 5, 		/**< */
 	OTF_UINT32 = 6, 	/**< */
	OTF_INT64 = 7, 		/**< */
	OTF_UINT64 = 8,		/**< */
	OTF_FLOAT = 9, 		/**< */
	OTF_DOUBLE = 10, 	/**< */
	OTF_BYTE_ARRAY = 11 /**< */
} OTF_Type;

/** @cond OTF_KeyValue */

/** the following lines are ignored by doxygen */

typedef struct byte_array_struct {
	uint8_t array[OTF_KEYVALUE_MAX_ARRAY_LEN];
	uint32_t len;
} byte_array;

typedef union OTF_Value_union {
	char	    otf_char;
	int8_t	    otf_int8;
	uint8_t	    otf_uint8;
	int16_t	    otf_int16;
	uint16_t    otf_uint16;
	int32_t	    otf_int32;
	uint32_t    otf_uint32;
	int64_t	    otf_int64;
	uint64_t    otf_uint64;
	float       otf_float;
	double 	    otf_double;
	byte_array  otf_byte_array;
} OTF_Value;

struct OTF_KeyValuePair_struct {
	uint32_t key;
	OTF_Type type;
	OTF_Value value;
};

typedef struct OTF_KeyValuePairList_struct {
	struct OTF_KeyValuePair_struct kvPair;
	struct OTF_KeyValuePairList_struct *kvNext;
    struct OTF_KeyValuePairList_struct *kvPrev;
} OTF_KeyValuePairList;

struct OTF_KeyValueList_struct {
	uint32_t key_count;             /* number of different keys in list --> user-relevant */
	uint32_t count;                 /* total number of entries in list (treat byte arrays particular) --> internal use only */
	uint32_t size;                  /* number of allocated entries --> internal */
	OTF_KeyValuePairList *kvBegin;   /* first element of the list */
	OTF_KeyValuePairList *kvEnd;     /* last allocated element of the list, may be used or not */
	OTF_KeyValuePairList *kvCurrent; /* first unused element in the list, insert new ones here */
};

/** @endcond */

/** Object type which holds a key-value list.*/
typedef struct OTF_KeyValueList_struct OTF_KeyValueList;

/** Object type which holds a key-value pair.*/
typedef struct OTF_KeyValuePair_struct OTF_KeyValuePair;

/**     
 * Create a new OTF_KeyValueList instance.
 *
 * @return             Initialized OTF_KeyValueList instance or NULL if an error
 *                     occurred.
 *
 * \ingroup keyvalue
 */
OTF_KeyValueList *OTF_KeyValueList_new(void);


/** 
 * Close an OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 * 
 * @return	   0 if instance was closed successfully and 1 otherwise.
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_close(OTF_KeyValueList* list);


/**
 * Clone an OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object or NULL.
 *                 See also OTF_KeyValueList_new().
 * 
 * @return	   Clone of the instance @a list or NULL.
 *
 * \ingroup keyvalue
 */
OTF_KeyValueList* OTF_KeyValueList_clone(OTF_KeyValueList* list);


/** 
 * Reset an OTF_KeyValueList instance without deallocating memory.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 * 
 * @return	   0 on success, 1 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_reset(OTF_KeyValueList* list);


/** 
 * Expand an OTF_KeyValueList by allocating more memory.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param num	   Number of elements for which memory should be allocated.
 * 
 * @return	   0 on success, 1 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_realloc(OTF_KeyValueList* list, uint32_t num);


/** @cond OTF_KeyValue */

/** the following lines are ignored by doxygen */

/** 
 * Append an OTF_KeyValuePair to a given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param pair	   An initialized OTF_KeyValuePair object.
 * 
 * @return	   0 on success, 1 if pair already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendPair(OTF_KeyValueList* list, OTF_KeyValuePair pair);

/** @endcond */


/** 
 * Append a character to a given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    A character that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendChar(OTF_KeyValueList* list, uint32_t key, char value);


/** 
 * Append a signed integer of 8 bit to a OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    A signed integer of 8 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendInt8(OTF_KeyValueList* list, uint32_t key, int8_t value);


/** 
 * Append an unsigned integer of 8 bit to a OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    An unsigned integer of 8 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendUint8(OTF_KeyValueList* list, uint32_t key, uint8_t value);


/** 
 * Append a signed integer of 16 bit to a OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    A signed integer of 16 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendInt16(OTF_KeyValueList* list, uint32_t key, int16_t value);


/** 
 * Append an unsigned integer of 16 bit to a OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    An unsigned integer of 16 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendUint16(OTF_KeyValueList* list, uint32_t key, uint16_t value);


/** 
 * Append a signed integer of 32 bit to a OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    A signed integer of 32 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendInt32(OTF_KeyValueList* list, uint32_t key, int32_t value);


/** 
 * Append an unsigned integer of 32 bit to a OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    An unsigned integer of 32 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendUint32(OTF_KeyValueList* list, uint32_t key, uint32_t value);


/** 
 * Append a signed integer of 64 bit to a OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    A signed integer of 64 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendInt64(OTF_KeyValueList* list, uint32_t key, int64_t value);


/** 
 * Append an unsigned integer of 64 bit to a given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    An unsigned integer of 64 bit that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendUint64(OTF_KeyValueList* list, uint32_t key, uint64_t value);


/** 
 * Append a float to a given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    A float that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendFloat(OTF_KeyValueList* list, uint32_t key, float value);


/** 
 * Append a double to a given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    A double that should be appended to the KeyValueList.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendDouble(OTF_KeyValueList* list, uint32_t key, double value);


/** 
 * Append a byte array to a given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the KeyValueList.
 * 
 * @param value    Pointer to a byte array that should be appended to the KeyValueList.
 *
 * @param len	   Lenght of byte array.
 *
 * @return	   0 on success, 1 if key already in list and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendByteArray(OTF_KeyValueList* list, uint32_t key, uint8_t *value, uint32_t len);


/** 
 * Append an existing OTF_KeyValueList to a given OTF_KeyValueList instance.
 *
 * @param dest_list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 	also OTF_KeyValueList_new().
 *
 * @param source_list   Pointer to an initialized OTF_KeyValueList instance that shall be appended to the given KeyValueList.
 *                 	See also OTF_KeyValueList_new();
 *
 * @return	   	0 on success, 1 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_appendKeyValueList(OTF_KeyValueList* dest_list, OTF_KeyValueList *source_list);


/** 
 * Read a character from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param value    Pointer to a char array, where the result is saved.
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getChar(OTF_KeyValueList *list, uint32_t key, char *value);


/** 
 * Read a signed integer of 8 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 *
 * @param value    Pointer to a signed integer of 8 bit, where the result is saved.

 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getInt8(OTF_KeyValueList *list, uint32_t key, int8_t *value);


/** 
 * Read an unsigned integer of 8 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 * 
 * @param value    Pointer to an unsigned integer of 8 bit, where the result is saved.
 *
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getUint8(OTF_KeyValueList *list, uint32_t key, uint8_t *value);


/** 
 * Read a signed integer of 16 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 *
 * @param value    Pointer to a signed integer of 16 bit, where the result is saved.

 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getInt16(OTF_KeyValueList *list, uint32_t key, int16_t *value);


/** 
 * Read an unsigned integer of 16 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 * 
 * @param value    Pointer to an unsigned integer of 16 bit, where the result is saved.
 *
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getUint16(OTF_KeyValueList *list, uint32_t key, uint16_t *value);


/** 
 * Read a signed integer of 32 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 *
 * @param value    Pointer to a signed integer of 32 bit, where the result is saved.

 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getInt32(OTF_KeyValueList *list, uint32_t key, int32_t *value);


/** 
 * Read an unsigned integer of 32 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 * 
 * @param value    Pointer to an unsigned integer of 32 bit, where the result is saved.
 *
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getUint32(OTF_KeyValueList *list, uint32_t key, uint32_t *value);


/** 
 * Read a signed integer of 64 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 * 
 *
 * @param value    Pointer to a signed integer of 64 bit, where the result is saved.
 *
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getInt64(OTF_KeyValueList *list, uint32_t key, int64_t *value);


/** 
 * Read an unsigned integer of 64 bit from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 * 
 *
 * @param value    Pointer to an unsigned integer of 64 bit, where the result is saved.
 *
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getUint64(OTF_KeyValueList *list, uint32_t key, uint64_t *value);


/** 
 * Read a float from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 *
 * @param value    Pointer to a float, where the result is saved.
 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getFloat(OTF_KeyValueList *list, uint32_t key, float *value);


/** 
 * Read a double from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 *
 * @param value    Pointer to a double, where the result is saved.
 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getDouble(OTF_KeyValueList *list, uint32_t key, double *value);


/** 
 * Read a byte array from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the value in the OTF_KeyValueList.
 *
 * @param value    Pointer to an allocated byte array, where the result is saved.
 *
 * @param len      Input and output parameter: Musst contain the number of bytes
 *                 that can be written to the buffer pointed by the parameter \a value.
 *                 Therefore at least \a len bytes musst be allocated for this buffer before.
 *                 At the end \e len contains the number of bytes written to the buffer.
 *                 This can be less or equal to the input of parameter \a len. To get the
 *                 total number of bytes stored in the byte-array for the specific \a key you
 *                 can use the function OTF_KeyValueList_getArrayLength() before.
 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getByteArray(OTF_KeyValueList *list, uint32_t key, uint8_t *value, uint32_t *len);


/**
 * Provides the lenght of a byte array in an OTF_KeyValueList instance by given key.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the pair in the OTF_KeyValueList.
 *
 * @param len      Return value for the array length.
 * 
 * @return	   0 on success, 1 if key not found, 2 if type differs
 *  	  	   and 255 if an error occurs
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_getArrayLength(OTF_KeyValueList *list, uint32_t key, uint32_t *len);


/** 
 * Search for key in given OTF_KeyValueList instance and return its type.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   An unique id that identifies the pair in the OTF_KeyValueList.
 * 
 * @return         OTF_Type on success, OTF_UNKNOWN if key not found or an error occurred.
 *
 * \ingroup keyvalue
 */
OTF_Type OTF_KeyValueList_getTypeForKey(OTF_KeyValueList *list, uint32_t key);


/**
 * Search for key in the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key	   Token that shall be searched in the OTF_KeyValueList.
 * 
 * @return	   0 on success, 1 if key not found or an error occurred.
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_hasKey(OTF_KeyValueList *list, uint32_t key);


/**
 * Remove key from the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @param key      Token that shall be removed from the OTF_KeyValueList.
 * 
 * @return         0 on success, 1 if key not found or an error occurred.
 *
 * \ingroup keyvalue
 */
uint8_t OTF_KeyValueList_removeKey(OTF_KeyValueList *list, uint32_t key);


/**
 * Search for a key at the given index position.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 * @param index    Index position in the OTF_KeyValueList.
 *
 * @param key      Return value for the found key.
 *
 * @return         0 on success, 1 if index not in list
 *
 * \ingroup keyvalue
*/
uint8_t OTF_KeyValueList_getKeyByIndex(OTF_KeyValueList *list, uint32_t index, uint32_t *key);

/**
 * Search for a key-value pair at the given index position.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 * @param index    Index position in the OTF_KeyValueList.
 *
 * @param pair     Pointer to the found key-value pair.
 *
 * @return         0 on success, 1 if index not in list
 *
 * \ingroup keyvalue
*/
uint8_t OTF_KeyValueList_getPairByIndex(OTF_KeyValueList *list, uint32_t index, OTF_KeyValuePair **pair);

/**
 * Returns the number of elements in the given OTF_KeyValueList instance.
 *
 * @param list     Pointer to an initialized OTF_KeyValueList object. See 
 *                 also OTF_KeyValueList_new().
 *
 * @return         Number of elements currently in list.
 *
 * \ingroup keyvalue
*/
uint32_t OTF_KeyValueList_getCount(OTF_KeyValueList *list);


/** 
 * Convert an integer of 32 bit to a float.
 *
 * \ingroup keyvalue
 */
float OTF_Int32ToFloat(uint32_t value);


/** 
 * Convert a float to an integer of 32 bit.
 *
 * \ingroup keyvalue
 */
uint32_t OTF_FloatToInt32(float value);


/** 
 * Convert an integer of 64 bit to a double.
 *
 * \ingroup keyvalue
 */
double OTF_Int64ToDouble(uint64_t value);


/** 
 * Convert a double to a signed integer of 64 bit.
 *
 * \ingroup keyvalue
 */
uint64_t OTF_DoubleToInt64(double value);


#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* OTF_KEYVALUE_H */