Pajdeg  0.2.2
Pajdeg
PDArray.h
Go to the documentation of this file.
1 //
2 // PDArray.h
3 //
4 // Copyright (c) 2012 - 2015 Karl-Johan Alm (http://github.com/kallewoof)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 //
24 
39 #ifndef INCLUDED_PDARRAY_H
40 #define INCLUDED_PDARRAY_H
41 
42 #include "PDDefines.h"
43 
52 
63 
72 
74 // * Create a copy of the given array.
75 // *
76 // * @param array The array to copy
77 // *
78 // * @return A new array, identical to array
79 // */
80 //extern PDArrayRef PDArrayCopy(PDArrayRef array);
81 
87 extern void PDArrayClear(PDArrayRef array);
88 
97 
106 extern void *PDArrayGetElement(PDArrayRef array, PDInteger index);
107 
117 extern void *PDArrayGetTypedElement(PDArrayRef array, PDInteger index, PDInstanceType type);
118 
119 //#define PDArrayGetNumber(a,i) PDArrayGetTypedElement(a,i,PDInstanceTypeNumber)
120 #define PDArrayGetString(a,i) PDArrayGetTypedElement(a,i,PDInstanceTypeString)
121 #define PDArrayGetArray(a,i) PDArrayGetTypedElement(a,i,PDInstanceTypeArray)
122 #define PDArrayGetDictionary(a,i) PDArrayGetTypedElement(a,i,PDInstanceTypeDict)
123 #define PDArrayGetReference(a,i) PDArrayGetTypedElement(a,i,PDInstanceTypeRef)
124 #define PDArrayGetObject(a,i) PDArrayGetTypedElement(a,i,PDInstanceTypeObj)
125 
126 #define PDArrayGetInteger(a,i) PDNumberGetInteger(PDArrayGetElement(a,i))
127 
134 extern void PDArrayAppend(PDArrayRef array, void *value);
135 
143 extern void PDArrayInsertAtIndex(PDArrayRef array, PDInteger index, void *value);
144 
153 extern PDInteger PDArrayGetIndex(PDArrayRef array, void *value);
154 
161 extern void PDArrayDeleteAtIndex(PDArrayRef array, PDInteger index);
162 
170 extern void PDArrayReplaceAtIndex(PDArrayRef array, PDInteger index, void *value);
171 
181 extern char *PDArrayToString(PDArrayRef array);
182 
183 extern PDInteger PDArrayPrinter(void *inst, char **buf, PDInteger offs, PDInteger *cap);
184 
185 extern void PDArrayPrint(PDArrayRef array);
186 
187 #define encryptable(str) (strlen(str) > 0 && str[0] == '(' && str[strlen(str)-1] == ')')
188 
189 #ifdef PD_SUPPORT_CRYPTO
190 
199 extern void PDArrayAttachCrypto(PDArrayRef array, pd_crypto crypto, PDInteger objectID, PDInteger genNumber);
200 
201 #endif // PD_SUPPORT_CRYPTO
202 
203 #endif // INCLUDED_PDARRAY_H
204 
void PDArrayAppend(PDArrayRef array, void *value)
Definition: PDArray.c:215
long PDInteger
Definition: PDDefines.h:184
void PDArrayReplaceAtIndex(PDArrayRef array, PDInteger index, void *value)
Definition: PDArray.c:278
void PDArrayAttachCrypto(PDArrayRef array, pd_crypto crypto, PDInteger objectID, PDInteger genNumber)
Definition: PDArray.c:336
void PDArrayClear(PDArrayRef array)
Definition: PDArray.c:159
PDInstanceType
Definition: PDDefines.h:557
PDArrayRef PDArrayCreateWithComplex(pd_stack stack)
Definition: PDArray.c:100
void PDArrayDeleteAtIndex(PDArrayRef array, PDInteger index)
Definition: PDArray.c:267
PDArrayRef PDArrayCreateWithStackList(pd_stack stack)
Definition: PDArray.c:65
PDArrayRef PDArrayCreateWithCapacity(PDInteger capacity)
Definition: PDArray.c:49
void * PDArrayGetTypedElement(PDArrayRef array, PDInteger index, PDInstanceType type)
Definition: PDArray.c:190
void PDArrayInsertAtIndex(PDArrayRef array, PDInteger index, void *value)
Definition: PDArray.c:220
Definition: pd_internal.h:718
Definition: pd_internal.h:544
Definition: pd_internal.h:611
PDInteger PDArrayGetIndex(PDArrayRef array, void *value)
Definition: PDArray.c:229
Definitions for the Pajdeg interface.
void * PDArrayGetElement(PDArrayRef array, PDInteger index)
Definition: PDArray.c:170
char * PDArrayToString(PDArrayRef array)
Definition: PDArray.c:293
PDInteger PDArrayGetCount(PDArrayRef array)
Definition: PDArray.c:165