Zen API

- Home
- Help Topics
- Types by Category
- All Types
- Files

All Classes Files Functions Variables Typedefs Macros Groups Pages
kBox.h
Go to the documentation of this file.
1 /**
2 * @file kBox.h
3 * @brief Declares the kBox class.
4 *
5 * @internal
6 * Copyright (C) 2005-2014 by LMI Technologies Inc.
7 * Licensed under the MIT License.
8 * Redistributed files must retain the above copyright notice.
9 */
10 #ifndef K_API_BOX_H
11 #define K_API_BOX_H
12
13 #include <kApi/kApiDef.h>
14
15 kBeginHeader()
16
17 /**
18 * @class kBox
19 * @extends kObject
20 * @ingroup kApi-Data
21 * @brief Represents an instance of a value type as an object.
22 *
23 * kBox provides a simple way to represent a single value (e.g. k32s) using a kObject-derived class instance.
24 * This approach can sometimes be used to reduce duplicated effort when both reference types and value types
25 * must be supported.
26 */
27 //typedef kObject kBox; --forward-declared in kApiDef.x.h
28
29 /**
30 * Constructs a kBox object.
31 *
32 * @public @memberof kBox
33 * @param box Receives the constructed object.
34 * @param itemType Type of box element (value types only).
35 * @param allocator Memory allocator (or kNULL for default).
36 * @return Operation status.
37 */
38 kFx(kStatus) kBox_Construct(kBox* box, kType itemType, kAlloc allocator);
39
40 /**
41 * Reallocates the internal box item buffer.
42 *
43 * @public @memberof kBox
44 * @param box Box object.
45 * @param itemType Type of array element.
46 * @return Operation status.
47 */
48 kFx(kStatus) kBox_Allocate(kBox box, kType itemType);
49
50 /**
51 * Copies the value contained within the source box into this box.
52 *
53 * @public @memberof kBox
54 * @param box Box object.
55 * @param source Source box to be copied.
56 * @return Operation status.
57 */
58 kFx(kStatus) kBox_Assign(kBox box, kBox source);
59
60 /**
61 * Sets all box element bits to zero.
62 *
63 * @public @memberof kBox
64 * @param box Box object.
65 * @return Operation status.
66 */
67 kFx(kStatus) kBox_Zero(kBox box);
68
69 /**
70 * Sets the box value.
71 *
72 * @public @memberof kBox
73 * @param box Box object.
74 * @param item Pointer to item that will be copied into the box.
75 * @return Operation status.
76 */
77 kFx(kStatus) kBox_SetItem(kBox box, const void* item);
78
79 /**
80 * Gets the box value.
81 *
82 * @public @memberof kBox
83 * @param box Box object.
84 * @param item Destination for value copied from the box.
85 * @return Operation status.
86 */
87 kFx(kStatus) kBox_Item(kBox box, void* item);
88
89 /**
90 * Returns a pointer to the box item buffer.
91 *
92 * @public @memberof kBox
93 * @param box Box object.
94 * @return Pointer to box item buffer.
95 */
96 kFx(void*) kBox_Data(kBox box);
97
98 /**
99 * Returns the box item type.
100 *
101 * @public @memberof kBox
102 * @param box Box object.
103 * @return Box item type.
104 */
105 kFx(kType) kBox_ItemType(kBox box);
106
107 /**
108 * Returns the box item size.
109 *
110 * @public @memberof kBox
111 * @param box Box object.
112 * @return Box item size.
113 */
114 kFx(kSize) kBox_ItemSize(kBox box);
115
116 #define kBox_ItemType_(BOX) kxBox_ItemType_(BOX) ///< Macro version of kBox_ItemType.
117 #define kBox_ItemSize_(BOX) kxBox_ItemSize_(BOX) ///< Macro version of kBox_ItemSize.
118 #define kBox_Data_(BOX) kxBox_Data_(BOX) ///< Macro version of kBox_Data.
119
120 /** Accesses the box value and casts the value to the specified type. */
121 #define kBox_As_(BOX, TYPE) kxBox_As_(BOX, TYPE)
122
123 kEndHeader()
124
125 #include <kApi/Data/kBox.x.h>
126
127 #endif
kBox::kBox_Assign
kStatus kBox_Assign(kBox box, kBox source)
Copies the value contained within the source box into this box.
kBox::kBox_ItemType
kType kBox_ItemType(kBox box)
Returns the box item type.
kBox::kBox_Zero
kStatus kBox_Zero(kBox box)
Sets all box element bits to zero.
kSize
Represents an unsigned integer that can store a pointer address.
kAlloc
Abstract base class for memory allocator types.
kApiDef.h
Essential API declarations.
kBox
Represents an instance of a value type as an object.
kBox::kBox_Item
kStatus kBox_Item(kBox box, void *item)
Gets the box value.
kBox::kBox_SetItem
kStatus kBox_SetItem(kBox box, const void *item)
Sets the box value.
kType
Represents metadata about a type (class, interface, or value).
kBox::kBox_Allocate
kStatus kBox_Allocate(kBox box, kType itemType)
Reallocates the internal box item buffer.
kStatus
Represents an enumeration of error codes.
kBox::kBox_Data
void * kBox_Data(kBox box)
Returns a pointer to the box item buffer.
kBox::kBox_ItemSize
kSize kBox_ItemSize(kBox box)
Returns the box item size.
kBox::kBox_Construct
kStatus kBox_Construct(kBox *box, kType itemType, kAlloc allocator)
Constructs a kBox object.