61
61
/* note: as a start to move away from the stupid IDP_New function, this type
62
62
* has it's own allocation function.*/
63
IDProperty *IDP_NewIDPArray(const char *name);
64
IDProperty *IDP_CopyIDPArray(IDProperty *array);
63
IDProperty *IDP_NewIDPArray(const char *name)
65
__attribute__((warn_unused_result))
66
__attribute__((nonnull))
69
IDProperty *IDP_CopyIDPArray(IDProperty *array)
71
__attribute__((warn_unused_result))
72
__attribute__((nonnull))
66
76
void IDP_FreeIDPArray(IDProperty *prop);
68
78
/* shallow copies item */
69
79
void IDP_SetIndexArray(struct IDProperty *prop, int index, struct IDProperty *item);
70
struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index);
71
struct IDProperty *IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
81
__attribute__((nonnull))
83
struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index)
85
__attribute__((warn_unused_result))
86
__attribute__((nonnull))
89
void IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
72
90
void IDP_ResizeIDPArray(struct IDProperty *prop, int len);
74
92
/* ----------- Numeric Array Type ----------- */
77
95
void IDP_FreeArray(struct IDProperty *prop);
79
97
/* ---------- String Type ------------ */
80
IDProperty *IDP_NewString(const char *st, const char *name, int maxlen);/* maxlen excludes '\0' */
81
void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen); /* maxlen excludes '\0' */
82
void IDP_ConcatStringC(struct IDProperty *prop, const char *st);
83
void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append);
84
void IDP_FreeString(struct IDProperty *prop);
98
IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) /* maxlen excludes '\0' */
100
__attribute__((warn_unused_result))
101
__attribute__((nonnull (2))) /* 'name' arg */
105
void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen) /* maxlen excludes '\0' */
107
__attribute__((nonnull))
110
void IDP_ConcatStringC(struct IDProperty *prop, const char *st)
112
__attribute__((nonnull))
115
void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append)
117
__attribute__((nonnull))
120
void IDP_FreeString(struct IDProperty *prop)
122
__attribute__((nonnull))
86
126
/*-------- ID Type -------*/
87
127
void IDP_LinkID(struct IDProperty *prop, ID *id);
90
130
/*-------- Group Functions -------*/
92
132
/** Sync values from one group to another, only where they match */
93
void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src);
133
void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src)
135
__attribute__((nonnull))
96
140
* replaces all properties with the same name in a destination group from a source group.
98
void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src);
142
void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src)
144
__attribute__((nonnull))
101
149
* Checks if a property with the same name as prop exists, and if so replaces it.
102
150
* Use this to preserve order!*/
103
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop);
151
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop)
153
__attribute__((nonnull))
157
void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite)
159
__attribute__((nonnull))
106
164
* This function has a sanity check to make sure ID properties with the same name don't
117
175
* struct. In the future this will just be IDP_FreeProperty and the code will
118
176
* be reorganized to work properly.
120
int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop);
178
int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop)
180
__attribute__((nonnull))
122
184
/** this is the same as IDP_AddToGroup, only you pass an item
123
185
* in the group list to be inserted after. */
124
186
int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
125
struct IDProperty *pnew);
187
struct IDProperty *pnew)
189
__attribute__((nonnull (1, 3))) /* 'group', 'pnew' */
127
193
/** \note this does not free the property!!
130
196
* IDP_FreeProperty(prop); //free all subdata
131
197
* MEM_freeN(prop); //free property struct itself
133
void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop);
199
void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop)
201
__attribute__((nonnull))
135
IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name);
205
IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name)
207
__attribute__((warn_unused_result))
208
__attribute__((nonnull))
136
211
/** same as above but ensure type match */
137
IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type);
212
IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type)
214
__attribute__((warn_unused_result))
215
__attribute__((nonnull))
140
220
* Get an iterator to iterate over the members of an id property group.
141
221
* Note that this will automatically free the iterator once iteration is complete;
142
222
* if you stop the iteration before hitting the end, make sure to call
143
223
* IDP_FreeIterBeforeEnd(). */
144
void *IDP_GetGroupIterator(struct IDProperty *prop);
224
void *IDP_GetGroupIterator(struct IDProperty *prop)
226
__attribute__((warn_unused_result))
147
231
* Returns the next item in the iteration. To use, simple for a loop like the following:
152
IDProperty *IDP_GroupIterNext(void *vself);
236
IDProperty *IDP_GroupIterNext(void *vself)
238
__attribute__((warn_unused_result))
239
__attribute__((nonnull))
155
244
* Frees the iterator pointed to at vself, only use this if iteration is stopped early;
156
245
* when the iterator hits the end of the list it'll automatically free itself.*/
157
void IDP_FreeIterBeforeEnd(void *vself);
246
void IDP_FreeIterBeforeEnd(void *vself)
248
__attribute__((nonnull))
159
252
/*-------- Main Functions --------*/
160
253
/** Get the Group property that contains the id properties for ID id. Set create_if_needed
161
254
* to create the Group property and attach it to id if it doesn't exist; otherwise
162
255
* the function will return NULL if there's no Group property attached to the ID.*/
163
struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed);
164
struct IDProperty *IDP_CopyProperty(struct IDProperty *prop);
166
int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2);
256
struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed)
258
__attribute__((warn_unused_result))
259
__attribute__((nonnull))
262
struct IDProperty *IDP_CopyProperty(struct IDProperty *prop)
264
__attribute__((warn_unused_result))
265
__attribute__((nonnull))
269
int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict)
271
__attribute__((warn_unused_result))
275
int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2)
277
__attribute__((warn_unused_result))
169
282
* Allocate a new ID.
190
303
* IDP_AddToGroup or MEM_freeN the property, doing anything else might result in
193
struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name);
306
struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
308
__attribute__((warn_unused_result))
309
__attribute__((nonnull))
195
313
/** \note this will free all child properties of list arrays and groups!
196
314
* Also, note that this does NOT unlink anything! Plus it doesn't free
197
315
* the actual struct IDProperty struct either.*/
198
316
void IDP_FreeProperty(struct IDProperty *prop);
318
void IDP_ClearProperty(IDProperty *prop);
200
320
/** Unlinks any struct IDProperty<->ID linkage that might be going on.*/
201
321
void IDP_UnlinkProperty(struct IDProperty *prop);
203
#define IDP_Int(prop) ((prop)->data.val)
204
#define IDP_Float(prop) (*(float*)&(prop)->data.val)
205
#define IDP_String(prop) ((char*)(prop)->data.pointer)
206
#define IDP_Array(prop) ((prop)->data.pointer)
207
#define IDP_IDPArray(prop) ((IDProperty*)(prop)->data.pointer)
208
#define IDP_Double(prop) (*(double*)&(prop)->data.val)
323
#define IDP_Int(prop) ((prop)->data.val)
324
#define IDP_Float(prop) (*(float *)&(prop)->data.val)
325
#define IDP_Double(prop) (*(double *)&(prop)->data.val)
326
#define IDP_String(prop) ((char *) (prop)->data.pointer)
327
#define IDP_Array(prop) ((prop)->data.pointer)
328
#define IDP_IDPArray(prop) ((IDProperty *) (prop)->data.pointer)
331
/* for printout only */
332
void IDP_spit(IDProperty *prop);
210
335
#endif /* __BKE_IDPROP_H__ */