tizen 2.3 release
[external/buxton.git] / src / shared / buxtondata.h
1 /*
2  * This file is part of buxton.
3  *
4  * Copyright (C) 2013 Intel Corporation
5  *
6  * buxton is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as
8  * published by the Free Software Foundation; either version 2.1
9  * of the License, or (at your option) any later version.
10  */
11
12 #pragma once
13
14 #ifdef HAVE_CONFIG_H
15     #include "config.h"
16 #endif
17
18 #include "buxton.h"
19 #include "buxtonstring.h"
20
21 /**
22  * Stores values in Buxton, may have only one value
23  */
24 typedef union BuxtonDataStore {
25         BuxtonString d_string; /**<Stores a string value */
26         int32_t d_int32; /**<Stores an int32_t value */
27         uint32_t d_uint32; /**<Stores an uint32_t value */
28         int64_t d_int64; /**<Stores a int64_t value */
29         uint64_t d_uint64; /**<Stores a uint64_t value */
30         float d_float; /**<Stores a float value */
31         double d_double; /**<Stores a double value */
32         bool d_boolean; /**<Stores a boolean value */
33 } BuxtonDataStore;
34
35 /**
36  * Represents data in Buxton
37  *
38  * In Buxton we operate on all data using BuxtonData, for both set and
39  * get operations. The type must be set to the type of value being set
40  * in the BuxtonDataStore
41  */
42 typedef struct BuxtonData {
43         BuxtonDataType type; /**<Type of data stored */
44         BuxtonDataStore store; /**<Contains one value, correlating to
45                                * type */
46 } BuxtonData;
47
48 static inline void buxton_string_to_data(BuxtonString *s, BuxtonData *d)
49 {
50         d->type = STRING;
51         d->store.d_string.value = s->value;
52         d->store.d_string.length = s->length;
53 }
54
55 /*
56  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
57  *
58  * Local variables:
59  * c-basic-offset: 8
60  * tab-width: 8
61  * indent-tabs-mode: t
62  * End:
63  *
64  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
65  * :indentSize=8:tabSize=8:noTabs=false:
66  */