Update doxygen
[platform/core/base/bundle.git] / src / keyval.h
1 /*
2  * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __KEYVAL_H__
18 #define __KEYVAL_H__
19
20 /**
21  * keyval.h
22  *
23  * keyval object
24  */
25
26 #include <stddef.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 # endif
31
32 /* ADT: object */
33 typedef struct keyval_t keyval_t;
34
35 /* Object methods */
36 typedef struct keyval_method_collection_t keyval_method_collection_t;
37
38 typedef void (*keyval_method_free_t)(keyval_t *kv, int do_free_object);
39 typedef int (*keyval_method_compare_t) (keyval_t *kv1, keyval_t *kv2);
40 typedef size_t (*keyval_method_get_encoded_size_t)(keyval_t *kv);
41 typedef size_t (*keyval_method_encode_t)(
42                 keyval_t *,
43                 unsigned char **byte,
44                 size_t *byte_len);
45 typedef size_t (*keyval_method_decode_t)(unsigned char *byte, keyval_t **kv,
46                 size_t byte_size);
47
48 struct keyval_method_collection_t {
49         keyval_method_free_t free;
50         keyval_method_compare_t compare;
51         keyval_method_get_encoded_size_t get_encoded_size;
52         keyval_method_encode_t encode;
53         keyval_method_decode_t decode;
54 };
55
56 struct keyval_t {
57         int type;
58         char *key;      /* To be freed. */
59         void *val;      /* To be freed. */
60         size_t size;    /* Size of a single value. */
61         struct keyval_t *next;
62         keyval_method_collection_t *method;
63 };
64
65 keyval_t * keyval_new(keyval_t *kv, const char *key,
66                 const int type, const void *val, const size_t size);
67 void keyval_free(keyval_t *kv, int do_free_object);
68 int keyval_compare(keyval_t *kv1, keyval_t *kv2);
69 size_t keyval_get_encoded_size(keyval_t *kv);
70 size_t keyval_encode(keyval_t *kv, unsigned char **byte, size_t *byte_len);
71 size_t keyval_decode(unsigned char *byte, keyval_t **kv, size_t byte_size);
72 int keyval_get_data(keyval_t *kv, int *type, void **val, size_t *size);
73 int keyval_get_type_from_encoded_byte(unsigned char *byte);
74
75 #ifdef __cplusplus
76 }
77 #endif
78
79 #endif /* __KEYVAL_H__ */