Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kArray1.h
Go to the documentation of this file.
1
10 #ifndef K_API_ARRAY_1_H
11 #define K_API_ARRAY_1_H
12
13 #include <kApi/kApiDef.h>
14 #include <kApi/Data/kArray1.x.h>
15
34 //typedef kObject kArray1; --forward-declared in kApiDef.x.h
35
46 kFx(kStatus) kArray1_Construct(kArray1* array, kType itemType, kSize length, kAlloc allocator);
47
59 kFx(kStatus) kArray1_ConstructEx(kArray1* array, kType itemType, kSize length, kAlloc allocator, kAlloc dataAllocator);
60
70 kFx(kStatus) kArray1_Allocate(kArray1 array, kType itemType, kSize length);
71
83 kInlineFx(kStatus) kArray1_Resize(kArray1 array, kSize length)
84 {
85 return kArray1_Allocate(array, kArray1_ItemType(array), length);
86 }
87
100 kFx(kStatus) kArray1_Attach(kArray1 array, void* items, kType itemType, kSize length);
101
117 #define kArray1_AttachT(kArray1_array, TPtr_items, kType_itemType, kSize_length) \
118 xkArray1_AttachT(kArray1_array, TPtr_items, kType_itemType, kSize_length, sizeof(*TPtr_items))
119
131 kFx(kStatus) kArray1_Assign(kArray1 array, kArray1 source);
132
140 kFx(kStatus) kArray1_Zero(kArray1 array);
141
151 kFx(kStatus) kArray1_SetItem(kArray1 array, kSize index, const void* item);
152
165 #define kArray1_SetItemT(kArray1_array, kSize_index, TPtr_item) \
166 xkArray1_SetItemT(kArray1_array, kSize_index, TPtr_item, sizeof(*TPtr_item))
167
177 kFx(kStatus) kArray1_Item(kArray1 array, kSize index, void* item);
178
191 #define kArray1_ItemT(kArray1_array, kSize_index, TPtr_item) \
192 xkArray1_ItemT(kArray1_array, kSize_index, TPtr_item, sizeof(*TPtr_item))
193
207 #define kArray1_SetAsT(kArray1_array, kSize_index, T_value, T) \
208 (kPointer_WriteAs(xkArray1_AsT(kArray1_array, kSize_index, sizeof(T)), T_value, T), (void)0)
209
223 #define kArray1_AsT(kArray1_array, kSize_index, T) \
224 kPointer_ReadAs(xkArray1_AsT(kArray1_array, kSize_index, sizeof(T)), T)
225
233 kInlineFx(void*) kArray1_Data(kArray1 array)
234 {
235 kObj(kArray1, array);
236
237 return obj->items;
238 }
239
251 #define kArray1_DataT(kArray1_array, T) \
252 kCast(T*, xkArray1_DataT(kArray1_array, sizeof(T)))
253
264 kInlineFx(void*) kArray1_DataAt(kArray1 array, kSSize index)
265 {
266 kObj(kArray1, array);
267
268 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
269 }
270
285 #define kArray1_DataAtT(kArray1_array, kSSize_index, T) \
286 kCast(T*, xkArray1_DataAtT(kArray1_array, kSSize_index, sizeof(T)))
287
295 kInlineFx(kSize) kArray1_DataSize(kArray1 array)
296 {
297 kObj(kArray1, array);
298
299 return obj->length * obj->itemSize;
300 }
301
313 kInlineFx(void*) kArray1_At(kArray1 array, kSize index)
314 {
315 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
316 {
317 kAssert(index < kArray1_Length(array));
318 }
319 # endif
320
321 return kArray1_DataAt(array, (kSSize)index);
322 }
323
337 #define kArray1_AtT(kArray1_array, kSize_index, T) \
338 kCast(T*, xkArray1_AtT(kArray1_array, kSize_index, sizeof(T)))
339
347 kInlineFx(kType) kArray1_ItemType(kArray1 array)
348 {
349 kObj(kArray1, array);
350
351 return obj->itemType;
352 }
353
361 kInlineFx(kSize) kArray1_ItemSize(kArray1 array)
362 {
363 kObj(kArray1, array);
364
365 return obj->itemSize;
366 }
367
375 kInlineFx(kSize) kArray1_Length(kArray1 array)
376 {
377 kObj(kArray1, array);
378
379 return obj->length;
380 }
381
392 kInlineFx(kSize) kArray1_Count(kArray1 array)
393 {
394 kObj(kArray1, array);
395
396 return obj->length;
397 }
398
406 kInlineFx(kAlloc) kArray1_DataAlloc(kArray1 array)
407 {
408 kObj(kArray1, array);
409
410 return obj->dataAlloc;
411 }
412
413 #endif
kArray1
Represents a 1D array.
kArray1::kArray1_Zero
kStatus kArray1_Zero(kArray1 array)
Sets all array element bits to zero.
kArray1::kArray1_ItemType
kType kArray1_ItemType(kArray1 array)
Returns the array item type.
Definition: kArray1.h:347
kArray1::kArray1_DataAlloc
kAlloc kArray1_DataAlloc(kArray1 array)
Reports the data allocator that was optionally provided at construction time.
Definition: kArray1.h:406
kSize
Represents an unsigned integer that can store a pointer address.
kArray1::kArray1_Allocate
kStatus kArray1_Allocate(kArray1 array, kType itemType, kSize length)
Reallocates the internal array item buffer.
kAlloc
Abstract base class for memory allocator types.
kArray1::kArray1_Data
void * kArray1_Data(kArray1 array)
Returns a pointer to the array item buffer.
Definition: kArray1.h:233
kPointer::kPointer_ItemOffset
void * kPointer_ItemOffset(const void *pointer, kSSize itemIndex, kSize itemSize)
Gets a pointer to the Nth element of an array.
Definition: kApiDef.h:294
kInlineFx
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kArray1::kArray1_DataAt
void * kArray1_DataAt(kArray1 array, kSSize index)
Calculates an address relative to the start of the buffer.
Definition: kArray1.h:264
kSSize
Represents a signed integer that can store a pointer address.
kArray1::kArray1_ItemSize
kSize kArray1_ItemSize(kArray1 array)
Returns the array item size.
Definition: kArray1.h:361
kArray1::kArray1_At
void * kArray1_At(kArray1 array, kSize index)
Returns a pointer to the specified item in the array.
Definition: kArray1.h:313
kArray1::kArray1_Construct
kStatus kArray1_Construct(kArray1 *array, kType itemType, kSize length, kAlloc allocator)
Constructs a kArray1 object.
kObj
#define kObj(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from a type-checked object handle...
Definition: kApiDef.h:2923
kApiDef.h
Core Zen type declarations.
kArray1::kArray1_Item
kStatus kArray1_Item(kArray1 array, kSize index, void *item)
Gets the value of an item.
kArray1::kArray1_ConstructEx
kStatus kArray1_ConstructEx(kArray1 *array, kType itemType, kSize length, kAlloc allocator, kAlloc dataAllocator)
Constructs a kArray1 object using a separate allocator for data array memory.
kType
Represents metadata about a type (class, interface, or value).
kArray1::kArray1_DataSize
kSize kArray1_DataSize(kArray1 array)
Reports the size, in bytes, of the array item buffer.
Definition: kArray1.h:295
kArray1::kArray1_Resize
kStatus kArray1_Resize(kArray1 array, kSize length)
Resizes the internal array item buffer.
Definition: kArray1.h:83
kAssert
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:751
kArray1::kArray1_Count
kSize kArray1_Count(kArray1 array)
Returns the array item count, in elements.
Definition: kArray1.h:392
kStatus
Represents an error code.
kArray1::kArray1_SetItem
kStatus kArray1_SetItem(kArray1 array, kSize index, const void *item)
Sets the value of an item.
kArray1::kArray1_Assign
kStatus kArray1_Assign(kArray1 array, kArray1 source)
Performs a shallow copy of the source array.
kArray1::kArray1_Attach
kStatus kArray1_Attach(kArray1 array, void *items, kType itemType, kSize length)
Attaches the array to an external item buffer.
kArray1::kArray1_Length
kSize kArray1_Length(kArray1 array)
Returns the array length, in elements.
Definition: kArray1.h:375