/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
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
#ifndef __H_BOX__
#define __H_BOX__
#include "defs.h"
#include "baseobject.h"
#include "Func.h"

BEGIN_DECLS

/** @file
 * @defgroup SBox SBox
 * @addtogroup SBox
 * @{
 * An SBox is a boxed type.
 */


/** @brief
 * A reference counted box sitting on top of an SObject.
 */
typedef struct SBox SBox;

typedef struct SBoxClass SBoxClass;

typedef struct SBoxPrivate SBoxPrivate;

struct SBox {
  SObject parent;
  SBoxPrivate * priv;
};

struct SBoxClass {
  SObjectClass parent_class;
  FreeFunc free_func;
};

#define S_BOX(o) (SBox *)(o);
#define S_BOX_CLASS(k) (SBoxClass *)(k);

/**
 * Creates a new SBox object.
 * 
 * @param object The object to be boxed.
 * @param freefunc The Function to be used when freeing the boxed object.
 *
 * @return A new SBox object.
 */
SBox * s_box_new_pointer (spointer object);

SBox * s_box_new_sobject (SObject * object);

SBox * s_box_new_int (int i);

SBox * s_box_new_long (long l);

SBox * s_box_new_short (short s);

SBox * s_box_new_char (char c);

SBox * s_box_new_wchar (wchar_t wc);

SBox * s_box_new_uint (unsigned int ui);

SBox * s_box_new_ulong (long l);

SBox * s_box_new_ushort (short s);

SBox * s_box_new_string (char * s);

SBox * s_box_new_wstring (wchar_t * ws);

/**
 * Free the an SBox.
 *
 * @param box The SBox to be freed.
 */
void s_box_free (SBox * box);

/**
 * Get the object that is contained inside the SBox.
 *
 * @param box The SBox to get the object from.
 *
 * @return a pointer to the object.
 */
spointer s_box_get_object (SBox * box);

/**
 * Gets the SType of the object that is stored in the SBox.
 */
SType s_box_get_type (SBox * box);

/**
 * Gets the type name of the object.
 *
 * @param box The SBox to get the type name from.
 * @return A String containing the name of the type.
 * 
 * @note caller must free the string.
 */
char * s_box_get_type_name (SBox * box);

void s_box_set_free_func (SBox * box, FreeFunc free_func);

/**
 * 
 */
void s_box_set_free_data_on_free (SBox * self, sboolean free_data);


/** @} */

END_DECLS

#endif