33 #include <uves_propertylist.h>
34 #include <uves_utils_wrappers.h>
35 #include <uves_error.h>
40 #include <uves_utils_wrappers.h>
41 #include <uves_deque.h>
42 #include <uves_dump.h>
47 #include <cxmessages.h>
48 #include <cxstrutils.h>
56 #include <sys/types.h>
109 switch(cpl_property_get_type(p)) {
111 uves_propertylist_append_char(plist, cpl_property_get_name(p), cpl_property_get_char(p));
114 uves_propertylist_append_bool(plist, cpl_property_get_name(p), cpl_property_get_bool(p));
117 uves_propertylist_append_int(plist, cpl_property_get_name(p), cpl_property_get_int(p));
120 uves_propertylist_append_long(plist, cpl_property_get_name(p), cpl_property_get_long(p));
123 uves_propertylist_append_float(plist, cpl_property_get_name(p), cpl_property_get_float(p));
125 case CPL_TYPE_DOUBLE:
126 uves_propertylist_append_double(plist, cpl_property_get_name(p), cpl_property_get_double(p));
128 case CPL_TYPE_STRING:
129 uves_propertylist_append_string(plist, cpl_property_get_name(p), cpl_property_get_string(p));
133 cpl_error_set(__func__, CPL_ERROR_UNSUPPORTED_MODE);
138 cpl_property_get_comment(p));
143 propertylist_prepend_property_cpl(cpl_propertylist *plist,
const cpl_property *p)
145 switch(cpl_property_get_type(p)) {
147 cpl_propertylist_prepend_char(plist, cpl_property_get_name(p), cpl_property_get_char(p));
150 cpl_propertylist_prepend_bool(plist, cpl_property_get_name(p), cpl_property_get_bool(p));
153 cpl_propertylist_prepend_int(plist, cpl_property_get_name(p), cpl_property_get_int(p));
156 cpl_propertylist_prepend_long(plist, cpl_property_get_name(p), cpl_property_get_long(p));
159 cpl_propertylist_prepend_float(plist, cpl_property_get_name(p), cpl_property_get_float(p));
161 case CPL_TYPE_DOUBLE:
162 cpl_propertylist_prepend_double(plist, cpl_property_get_name(p), cpl_property_get_double(p));
164 case CPL_TYPE_STRING:
165 cpl_propertylist_prepend_string(plist, cpl_property_get_name(p), cpl_property_get_string(p));
169 cpl_error_set(__func__, CPL_ERROR_UNSUPPORTED_MODE);
172 cpl_propertylist_set_comment(plist, cpl_property_get_name(p), cpl_property_get_comment(p));
176 static cpl_propertylist *
179 cpl_propertylist *result;
186 result = cpl_propertylist_new();
189 propertylist_prepend_property_cpl(
198 uves_propertylist_from_cpl(
uves_propertylist *
self,
const cpl_propertylist *list_cpl)
200 long N = cpl_propertylist_get_size(list_cpl);
201 cpl_propertylist *copy = cpl_propertylist_duplicate(list_cpl);
206 for (i = 0; i < N; i++) {
207 const cpl_property *p = cpl_propertylist_get(copy, 0);
208 propertylist_append_property(
self, p);
209 cpl_propertylist_erase(copy, cpl_property_get_name(p));
212 assert( cpl_propertylist_is_empty(copy));
213 cpl_propertylist_delete(copy);
219 cpl_error_code uves_vector_save(
const cpl_vector *v,
const char *f, cpl_type_bpp bpp,
222 cpl_propertylist *header_cpl = uves_propertylist_to_cpl(header);
223 cpl_vector_save(v, f, bpp, header_cpl, mode);
224 cpl_propertylist_delete(header_cpl);
226 return cpl_error_get_code();
229 uves_image_save(
const cpl_image *image,
const char *f, cpl_type_bpp bpp,
232 cpl_propertylist *header_cpl = NULL;
233 check_nomsg(header_cpl=uves_propertylist_to_cpl(header));
234 check_nomsg(cpl_image_save(image, f, bpp, header_cpl, mode));
236 cpl_propertylist_delete(header_cpl);
238 return cpl_error_get_code();
240 cpl_error_code uves_imagelist_save(
const cpl_imagelist *imagelist,
const char *f, cpl_type_bpp bpp,
243 cpl_propertylist *header_cpl = uves_propertylist_to_cpl(header);
244 cpl_imagelist_save(imagelist, f, bpp, header_cpl, mode);
245 cpl_propertylist_delete(header_cpl);
247 return cpl_error_get_code();
249 cpl_error_code uves_table_save(
const cpl_table *table,
const uves_propertylist *header,
253 cpl_propertylist *header_cpl = uves_propertylist_to_cpl(header);
254 cpl_propertylist *ext_header_cpl = uves_propertylist_to_cpl(ext_header);
255 cpl_table_save(table, header_cpl, ext_header_cpl, filename, mode);
256 cpl_propertylist_delete(header_cpl);
257 cpl_propertylist_delete(ext_header_cpl);
259 return cpl_error_get_code();
263 const cpl_frame *product_frame,
264 const cpl_frameset *framelist,
265 const cpl_parameterlist *parlist,
267 const char *pipeline_id,
268 const char *dictionary_id)
270 cpl_propertylist *header_cpl = uves_propertylist_to_cpl(header);
272 cpl_dfs_setup_product_header(header_cpl,
281 uves_propertylist_from_cpl(header, header_cpl);
282 cpl_propertylist_delete(header_cpl);
284 return cpl_error_get_code();
290 cpl_table_sort(t, (
const cpl_propertylist*) list);
294 cpl_propertylist *list_cpl = uves_propertylist_to_cpl(list);
295 cpl_table_sort(t, list_cpl);
296 cpl_propertylist_delete(list_cpl);
298 return cpl_error_get_code();
308 static cpl_error_code push_pop_error;
310 static void error_push(
void)
312 push_pop_error = cpl_error_get_code();
317 static void error_pop(
void)
319 if (push_pop_error != CPL_ERROR_NONE)
321 cpl_error_set(__func__, push_pop_error);
334 _uves_propertylist_filter_regexp(cxcptr key, cxcptr filter)
339 if (regexec(&_filter->re, key, (
size_t)0, NULL, 0) == REG_NOMATCH)
340 return _filter->invert == TRUE ? TRUE : FALSE;
342 return _filter->invert == TRUE ? FALSE : TRUE;
348 _uves_propertylist_compare(
const cpl_property *property,
const char *name)
350 const cxchar *key = cpl_property_get_name(property);
352 return strcmp(key, name) == 0 ? TRUE : FALSE;
373 _uves_propertylist_compare_regexp(
const cpl_property *property,
uves_regexp *re)
376 const cxchar *key = cpl_property_get_name(property);
378 return _uves_propertylist_filter_regexp(key, re);
383 static uves_deque_iterator
387 uves_deque_iterator first, last;
390 first = uves_deque_begin(self->properties);
391 last = uves_deque_end(self->properties);
393 while (first != last) {
394 p = uves_deque_get(self->properties, first);
396 if (_uves_propertylist_compare(p, name))
399 first = uves_deque_next(self->properties, first);
406 static cpl_property *
409 uves_deque_iterator pos = _uves_propertylist_find(
self, name);
411 if (pos == uves_deque_end(self->properties))
414 return uves_deque_get(self->properties, pos);
421 cxbool after,
const cxchar *name, cpl_type type,
425 uves_deque_iterator pos;
426 cpl_property *property;
433 pos = _uves_propertylist_find(
self, where);
435 if (pos == uves_deque_end(self->properties)) {
440 pos = uves_deque_next(self->properties, pos);
448 property = cpl_property_new(name, type);
460 cpl_property_set_char(property, *((cxchar *)value));
464 cpl_property_set_bool(property, *((cxint *)value));
468 cpl_property_set_int(property, *((cxint *)value));
472 cpl_property_set_long(property, *((cxlong *)value));
476 cpl_property_set_float(property, *((cxfloat *)value));
479 case CPL_TYPE_DOUBLE:
480 cpl_property_set_double(property, *((cxdouble *)value));
483 case CPL_TYPE_STRING:
484 cpl_property_set_string(property, ((
const cxchar *)value));
497 uves_deque_insert(self->properties, pos, property);
518 _uves_propertylist_decode_fits(
const qfits_header *header, cxint i,
519 cxchar *key, cxint *type, cxchar *value,
523 cxchar _key[FITS_LINESZ + 1];
524 cxchar _value[FITS_LINESZ + 1];
525 cxchar _comment[FITS_LINESZ + 1];
536 if (qfits_header_getitem((qfits_header *)header, i, _key, _value,
537 _comment, NULL) != 0) {
549 if (strncmp(s,
"END", 3) == 0 || strncmp(s,
" ", 8) == 0 ||
560 if (strncmp(s,
"HIERARCH ", 9) == 0)
563 strncpy(key, s, FITS_LINESZ);
564 key[FITS_LINESZ] =
'\0';
576 if (strncmp(_key,
"COMMENT", 7) == 0 || strncmp(_key,
"HISTORY", 7) == 0) {
577 *type = QFITS_STRING;
583 if (strlen(s) == 0) {
587 strncpy(value, s, FITS_LINESZ);
591 *type = qfits_get_type(s);
592 strncpy(value, qfits_pretty_string(s), FITS_LINESZ);
593 value[FITS_LINESZ] =
'\0';
610 strncpy(comment, s, FITS_LINESZ);
611 comment[FITS_LINESZ] =
'\0';
631 const qfits_header *header,
632 cx_compare_func filter,
639 cx_assert(
self != NULL);
640 cx_assert(header != NULL);
647 for (i = 0; i < header->n; i++) {
648 register cxint status;
655 cxchar key[FITS_LINESZ + 1];
656 cxchar value[FITS_LINESZ + 1];
657 cxchar comment[FITS_LINESZ + 1];
659 cpl_property *property;
662 status = _uves_propertylist_decode_fits(header, i, key, &type,
678 if (filter != NULL && filter(key, data) == FALSE) {
689 property = cpl_property_new(key, CPL_TYPE_BOOL);
691 ival = *value ==
'T' ? 1 : 0;
692 cpl_property_set_bool(property, ival);
693 cpl_property_set_comment(property, comment);
697 property = cpl_property_new(key, CPL_TYPE_INT);
699 sscanf(value,
"%d", &ival);
700 cpl_property_set_int(property, ival);
701 cpl_property_set_comment(property, comment);
705 property = cpl_property_new(key, CPL_TYPE_DOUBLE);
707 sscanf(value,
"%lf", &dval);
708 cpl_property_set_double(property, dval);
709 cpl_property_set_comment(property, comment);
721 property = cpl_property_new(key, CPL_TYPE_STRING);
723 cpl_property_set_string(property, value);
724 cpl_property_set_comment(property, comment);
736 uves_deque_push_back(self->properties, property);
769 self->properties = uves_deque_new();
804 const cxchar *
const _id =
"uves_propertylist_duplicate";
806 uves_deque_iterator first, last;
812 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
816 cx_assert(self->properties != NULL);
821 first = uves_deque_begin(self->properties);
822 last = uves_deque_end(self->properties);
824 while (first != last) {
825 cpl_property *tmp = uves_deque_get(self->properties, first);
827 uves_deque_push_back(copy->properties, cpl_property_duplicate(tmp));
828 first = uves_deque_next(self->properties, first);
854 uves_deque_destroy(self->properties, (cx_free_func)cpl_property_delete);
855 cx_free((
void *)
self);
893 const cxchar *
const _id =
"uves_propertylist_get_size";
897 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
901 return (
long) uves_deque_size(self->properties);
935 const cxchar *
const _id =
"uves_propertylist_is_empty";
939 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
943 return uves_deque_empty(self->properties);
986 const cxchar *
const _id =
"uves_propertylist_get_type";
988 cpl_property *property;
991 if (
self == NULL || name == NULL) {
992 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
993 return CPL_TYPE_INVALID;
996 property = _uves_propertylist_get(
self, name);
998 if (property == NULL) {
999 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1000 return CPL_TYPE_INVALID;
1003 return cpl_property_get_type(property);
1040 const cxchar *
const _id =
"uves_propertylist_contains";
1043 if (
self == NULL || name == NULL) {
1044 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1048 return _uves_propertylist_get(
self, name) != NULL ? 1 : 0;
1088 const cxchar *
const _id =
"my_uves_propertylist_contains";
1091 if (
self == NULL || name == NULL) {
1092 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1096 return cpl_propertylist_has(
self, name);
1146 const char *comment)
1149 const cxchar *
const _id =
"uves_propertylist_set_comment";
1151 cpl_property *property;
1154 if (
self == NULL || name == NULL) {
1155 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1156 return CPL_ERROR_NULL_INPUT;
1159 property = _uves_propertylist_get(
self, name);
1161 if (property == NULL) {
1162 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1163 return CPL_ERROR_DATA_NOT_FOUND;
1166 cpl_property_set_comment(property, comment);
1168 return CPL_ERROR_NONE;
1214 const cxchar *
const _id =
"uves_propertylist_set_char";
1216 cpl_property *property;
1219 if (
self == NULL || name == NULL) {
1220 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1221 return CPL_ERROR_NULL_INPUT;
1224 property = _uves_propertylist_get(
self, name);
1226 if (property == NULL) {
1227 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1228 return CPL_ERROR_DATA_NOT_FOUND;
1231 return cpl_property_set_char(property, value);
1276 const cxchar *
const _id =
"uves_propertylist_set_bool";
1278 cpl_property *property;
1281 if (
self == NULL || name == NULL) {
1282 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1283 return CPL_ERROR_NULL_INPUT;
1286 property = _uves_propertylist_get(
self, name);
1288 if (property == NULL) {
1289 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1290 return CPL_ERROR_DATA_NOT_FOUND;
1293 return cpl_property_set_bool(property, value);
1338 const cxchar *
const _id =
"uves_propertylist_set_int";
1340 cpl_property *property;
1343 if (
self == NULL || name == NULL) {
1344 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1345 return CPL_ERROR_NULL_INPUT;
1348 property = _uves_propertylist_get(
self, name);
1350 if (property == NULL) {
1351 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1352 return CPL_ERROR_DATA_NOT_FOUND;
1355 return cpl_property_set_int(property, value);
1401 const cxchar *
const _id =
"uves_propertylist_set_long";
1403 cpl_property *property;
1406 if (
self == NULL || name == NULL) {
1407 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1408 return CPL_ERROR_NULL_INPUT;
1411 property = _uves_propertylist_get(
self, name);
1413 if (property == NULL) {
1414 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1415 return CPL_ERROR_DATA_NOT_FOUND;
1418 return cpl_property_set_long(property, value);
1464 const cxchar *
const _id =
"uves_propertylist_set_float";
1466 cpl_property *property;
1469 if (
self == NULL || name == NULL) {
1470 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1471 return CPL_ERROR_NULL_INPUT;
1474 property = _uves_propertylist_get(
self, name);
1476 if (property == NULL) {
1477 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1478 return CPL_ERROR_DATA_NOT_FOUND;
1481 return cpl_property_set_float(property, value);
1527 const cxchar *
const _id =
"uves_propertylist_set_double";
1529 cpl_property *property;
1532 if (
self == NULL || name == NULL) {
1533 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1534 return CPL_ERROR_NULL_INPUT;
1537 property = _uves_propertylist_get(
self, name);
1539 if (property == NULL) {
1540 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1541 return CPL_ERROR_DATA_NOT_FOUND;
1544 return cpl_property_set_double(property, value);
1590 const cxchar *
const _id =
"uves_propertylist_set_string";
1592 cpl_property *property;
1595 if (
self == NULL || name == NULL) {
1596 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1597 return CPL_ERROR_NULL_INPUT;
1600 property = _uves_propertylist_get(
self, name);
1602 if (property == NULL) {
1603 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1604 return CPL_ERROR_DATA_NOT_FOUND;
1607 return cpl_property_set_string(property, value);
1641 const cpl_property *
1645 const cxchar *
const _id =
"uves_propertylist_get";
1649 uves_deque_iterator first, last;
1653 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1661 first = uves_deque_begin(self->properties);
1662 last = uves_deque_end(self->properties);
1669 if (first == last) {
1674 return uves_deque_get(self->properties, position);
1724 const cxchar *
const _id =
"uves_propertylist_get_comment";
1726 cpl_property *property;
1729 if (
self == NULL || name == NULL) {
1730 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1734 property = _uves_propertylist_get(
self, name);
1737 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1741 return cpl_property_get_comment(property);
1791 const cxchar *
const _id =
"uves_propertylist_get_char";
1795 cpl_property *property;
1798 if (
self == NULL || name == NULL) {
1799 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1803 property = _uves_propertylist_get(
self, name);
1806 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1813 result = cpl_property_get_char(property);
1820 if (cpl_error_get_code() != CPL_ERROR_NONE) {
1821 cpl_error_set_where(_id);
1880 const cxchar *
const _id =
"uves_propertylist_get_bool";
1884 cpl_property *property;
1887 if (
self == NULL || name == NULL) {
1888 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1892 property = _uves_propertylist_get(
self, name);
1895 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1902 result = cpl_property_get_bool(property);
1909 if (cpl_error_get_code() != CPL_ERROR_NONE) {
1910 cpl_error_set_where(_id);
1917 return result == TRUE ? 1 : 0;
1967 const cxchar *
const _id =
"uves_propertylist_get_int";
1971 cpl_property *property;
1974 if (
self == NULL || name == NULL) {
1975 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
1979 property = _uves_propertylist_get(
self, name);
1982 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
1989 result = cpl_property_get_int(property);
1996 if (cpl_error_get_code() != CPL_ERROR_NONE) {
1997 cpl_error_set_where(_id);
2054 const cxchar *
const _id =
"uves_propertylist_get_long";
2058 cpl_property *property;
2061 if (
self == NULL || name == NULL) {
2062 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2066 property = _uves_propertylist_get(
self, name);
2069 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
2076 result = cpl_property_get_long(property);
2083 if (cpl_error_get_code() != CPL_ERROR_NONE) {
2084 cpl_error_set_where(_id);
2141 const cxchar *
const _id =
"uves_propertylist_get_float";
2145 cpl_property *property;
2148 if (
self == NULL || name == NULL) {
2149 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2153 property = _uves_propertylist_get(
self, name);
2156 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
2163 result = cpl_property_get_float(property);
2170 if (cpl_error_get_code() != CPL_ERROR_NONE) {
2171 cpl_error_set_where(_id);
2228 const cxchar *
const _id =
"uves_propertylist_get_double";
2232 cpl_property *property;
2235 if (
self == NULL || name == NULL) {
2236 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2240 property = _uves_propertylist_get(
self, name);
2243 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
2250 result = cpl_property_get_double(property);
2257 if (cpl_error_get_code() != CPL_ERROR_NONE) {
2258 cpl_error_set_where(_id);
2317 const cxchar *
const _id =
"uves_propertylist_get_string";
2319 const cxchar *result;
2321 cpl_property *property;
2324 if (
self == NULL || name == NULL) {
2325 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2329 property = _uves_propertylist_get(
self, name);
2332 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
2339 result = cpl_property_get_string(property);
2346 if (cpl_error_get_code() != CPL_ERROR_NONE) {
2347 cpl_error_set_where(_id);
2398 const char *name,
char value)
2401 const cxchar *
const _id =
"uves_propertylist_insert_char";
2406 if (
self == NULL || here == NULL || name == NULL) {
2407 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2408 return CPL_ERROR_NULL_INPUT;
2411 status = _uves_propertylist_insert(
self, here, FALSE, name,
2412 CPL_TYPE_CHAR, &value);
2415 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2416 return CPL_ERROR_UNSPECIFIED;
2419 return CPL_ERROR_NONE;
2463 const char *name,
int value)
2466 const cxchar *
const _id =
"uves_propertylist_insert_bool";
2471 if (
self == NULL || here == NULL || name == NULL) {
2472 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2473 return CPL_ERROR_NULL_INPUT;
2476 status = _uves_propertylist_insert(
self, here, FALSE, name,
2477 CPL_TYPE_BOOL, &value);
2480 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2481 return CPL_ERROR_UNSPECIFIED;
2484 return CPL_ERROR_NONE;
2528 const char *name,
int value)
2531 const cxchar *
const _id =
"uves_propertylist_insert_int";
2536 if (
self == NULL || here == NULL || name == NULL) {
2537 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2538 return CPL_ERROR_NULL_INPUT;
2541 status = _uves_propertylist_insert(
self, here, FALSE, name,
2542 CPL_TYPE_INT, &value);
2545 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2546 return CPL_ERROR_UNSPECIFIED;
2549 return CPL_ERROR_NONE;
2584 const cxchar *
const _id =
"cpl_propertylist_has";
2587 if (
self == NULL || name == NULL) {
2588 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2592 return _uves_propertylist_get(
self, name) != NULL ? 1 : 0;
2636 const char *name,
long value)
2639 const cxchar *
const _id =
"uves_propertylist_insert_long";
2644 if (
self == NULL || here == NULL || name == NULL) {
2645 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2646 return CPL_ERROR_NULL_INPUT;
2649 status = _uves_propertylist_insert(
self, here, FALSE, name,
2650 CPL_TYPE_LONG, &value);
2653 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2654 return CPL_ERROR_UNSPECIFIED;
2657 return CPL_ERROR_NONE;
2701 const char *name,
float value)
2704 const cxchar *
const _id =
"uves_propertylist_insert_float";
2709 if (
self == NULL || here == NULL || name == NULL) {
2710 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2711 return CPL_ERROR_NULL_INPUT;
2714 status = _uves_propertylist_insert(
self, here, FALSE, name,
2715 CPL_TYPE_FLOAT, &value);
2718 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2719 return CPL_ERROR_UNSPECIFIED;
2722 return CPL_ERROR_NONE;
2766 const char *name,
double value)
2769 const cxchar *
const _id =
"uves_propertylist_insert_char";
2774 if (
self == NULL || here == NULL || name == NULL) {
2775 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2776 return CPL_ERROR_NULL_INPUT;
2779 status = _uves_propertylist_insert(
self, here, FALSE, name,
2780 CPL_TYPE_DOUBLE, &value);
2783 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2784 return CPL_ERROR_UNSPECIFIED;
2787 return CPL_ERROR_NONE;
2831 const char *name,
const char *value)
2834 const cxchar *
const _id =
"uves_propertylist_insert_string";
2839 if (
self == NULL || here == NULL || name == NULL) {
2840 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2841 return CPL_ERROR_NULL_INPUT;
2844 status = _uves_propertylist_insert(
self, here, FALSE, name,
2845 CPL_TYPE_STRING, (cxptr)value);
2848 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2849 return CPL_ERROR_UNSPECIFIED;
2852 return CPL_ERROR_NONE;
2896 const char *name,
char value)
2899 const cxchar *
const _id =
"uves_propertylist_insert_after_char";
2904 if (
self == NULL || after == NULL || name == NULL) {
2905 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2906 return CPL_ERROR_NULL_INPUT;
2909 status = _uves_propertylist_insert(
self, after, TRUE, name,
2910 CPL_TYPE_CHAR, &value);
2913 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2914 return CPL_ERROR_UNSPECIFIED;
2917 return CPL_ERROR_NONE;
2961 const char *name,
int value)
2964 const cxchar *
const _id =
"uves_propertylist_insert_after_bool";
2969 if (
self == NULL || after == NULL || name == NULL) {
2970 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
2971 return CPL_ERROR_NULL_INPUT;
2974 status = _uves_propertylist_insert(
self, after, TRUE, name,
2975 CPL_TYPE_BOOL, &value);
2978 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
2979 return CPL_ERROR_UNSPECIFIED;
2982 return CPL_ERROR_NONE;
3026 const char *name,
int value)
3029 const cxchar *
const _id =
"uves_propertylist_insert_after_int";
3034 if (
self == NULL || after == NULL || name == NULL) {
3035 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3036 return CPL_ERROR_NULL_INPUT;
3039 status = _uves_propertylist_insert(
self, after, TRUE, name,
3040 CPL_TYPE_INT, &value);
3043 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
3044 return CPL_ERROR_UNSPECIFIED;
3047 return CPL_ERROR_NONE;
3091 const char *name,
long value)
3094 const cxchar *
const _id =
"uves_propertylist_insert_after_long";
3099 if (
self == NULL || after == NULL || name == NULL) {
3100 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3101 return CPL_ERROR_NULL_INPUT;
3104 status = _uves_propertylist_insert(
self, after, TRUE, name,
3105 CPL_TYPE_LONG, &value);
3108 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
3109 return CPL_ERROR_UNSPECIFIED;
3112 return CPL_ERROR_NONE;
3156 const char *name,
float value)
3159 const cxchar *
const _id =
"uves_propertylist_insert_after_float";
3164 if (
self == NULL || after == NULL || name == NULL) {
3165 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3166 return CPL_ERROR_NULL_INPUT;
3169 status = _uves_propertylist_insert(
self, after, TRUE, name,
3170 CPL_TYPE_FLOAT, &value);
3173 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
3174 return CPL_ERROR_UNSPECIFIED;
3177 return CPL_ERROR_NONE;
3221 const char *after,
const char *name,
3225 const cxchar *
const _id =
"uves_propertylist_insert_after_double";
3230 if (
self == NULL || after == NULL || name == NULL) {
3231 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3232 return CPL_ERROR_NULL_INPUT;
3235 status = _uves_propertylist_insert(
self, after, TRUE, name,
3236 CPL_TYPE_DOUBLE, &value);
3239 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
3240 return CPL_ERROR_UNSPECIFIED;
3243 return CPL_ERROR_NONE;
3287 const char *after,
const char *name,
3291 const cxchar *
const _id =
"uves_propertylist_insert_after_string";
3296 if (
self == NULL || after == NULL || name == NULL) {
3297 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3298 return CPL_ERROR_NULL_INPUT;
3301 status = _uves_propertylist_insert(
self, after, TRUE, name,
3302 CPL_TYPE_STRING, (cxptr)value);
3305 cpl_error_set(_id, CPL_ERROR_UNSPECIFIED);
3306 return CPL_ERROR_UNSPECIFIED;
3309 return CPL_ERROR_NONE;
3347 const cxchar *
const _id =
"uves_propertylist_prepend_char";
3349 cpl_property *
property = NULL;
3352 if (
self == NULL || name == NULL) {
3353 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3354 return CPL_ERROR_NULL_INPUT;
3357 property = cpl_property_new(name, CPL_TYPE_CHAR);
3358 cx_assert(property != NULL);
3360 cpl_property_set_char(property, value);
3361 uves_deque_push_front(self->properties, property);
3363 return CPL_ERROR_NONE;
3401 const cxchar *
const _id =
"uves_propertylist_prepend_bool";
3403 cpl_property *
property = NULL;
3406 if (
self == NULL || name == NULL) {
3407 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3408 return CPL_ERROR_NULL_INPUT;
3411 property = cpl_property_new(name, CPL_TYPE_BOOL);
3412 cx_assert(property != NULL);
3414 cpl_property_set_bool(property, value);
3415 uves_deque_push_front(self->properties, property);
3417 return CPL_ERROR_NONE;
3455 const cxchar *
const _id =
"uves_propertylist_prepend_int";
3457 cpl_property *
property = NULL;
3460 if (
self == NULL || name == NULL) {
3461 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3462 return CPL_ERROR_NULL_INPUT;
3465 property = cpl_property_new(name, CPL_TYPE_INT);
3466 cx_assert(property != NULL);
3468 cpl_property_set_int(property, value);
3469 uves_deque_push_front(self->properties, property);
3471 return CPL_ERROR_NONE;
3509 const cxchar *
const _id =
"uves_propertylist_prepend_long";
3511 cpl_property *
property = NULL;
3514 if (
self == NULL || name == NULL) {
3515 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3516 return CPL_ERROR_NULL_INPUT;
3519 property = cpl_property_new(name, CPL_TYPE_LONG);
3520 cx_assert(property != NULL);
3522 cpl_property_set_long(property, value);
3523 uves_deque_push_front(self->properties, property);
3525 return CPL_ERROR_NONE;
3563 const cxchar *
const _id =
"uves_propertylist_prepend_float";
3565 cpl_property *
property = NULL;
3568 if (
self == NULL || name == NULL) {
3569 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3570 return CPL_ERROR_NULL_INPUT;
3573 property = cpl_property_new(name, CPL_TYPE_FLOAT);
3574 cx_assert(property != NULL);
3576 cpl_property_set_float(property, value);
3577 uves_deque_push_front(self->properties, property);
3579 return CPL_ERROR_NONE;
3617 const cxchar *
const _id =
"uves_propertylist_prepend_double";
3619 cpl_property *
property = NULL;
3622 if (
self == NULL || name == NULL) {
3623 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3624 return CPL_ERROR_NULL_INPUT;
3627 property = cpl_property_new(name, CPL_TYPE_DOUBLE);
3628 cx_assert(property != NULL);
3630 cpl_property_set_double(property, value);
3631 uves_deque_push_front(self->properties, property);
3633 return CPL_ERROR_NONE;
3671 const cxchar *
const _id =
"uves_propertylist_prepend_string";
3673 cpl_property *
property = NULL;
3676 if (
self == NULL || name == NULL) {
3677 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3678 return CPL_ERROR_NULL_INPUT;
3681 property = cpl_property_new(name, CPL_TYPE_STRING);
3682 cx_assert(property != NULL);
3684 cpl_property_set_string(property, value);
3685 uves_deque_push_front(self->properties, property);
3687 return CPL_ERROR_NONE;
3788 char value,
const char *comment)
3791 const cxchar *
const _id =
"uves_propertylist_append_char";
3793 cpl_property *
property = NULL;
3796 if (
self == NULL || name == NULL) {
3797 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3798 return CPL_ERROR_NULL_INPUT;
3801 property = cpl_property_new(name, CPL_TYPE_CHAR);
3802 cx_assert(property != NULL);
3804 if (comment != NULL) cpl_property_set_comment(property, comment);
3806 cpl_property_set_char(property, value);
3807 uves_deque_push_back(self->properties, property);
3809 return CPL_ERROR_NONE;
3844 int value,
const char *comment)
3847 const cxchar *
const _id =
"uves_propertylist_append_bool";
3849 cpl_property *
property = NULL;
3852 if (
self == NULL || name == NULL) {
3853 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3854 return CPL_ERROR_NULL_INPUT;
3857 property = cpl_property_new(name, CPL_TYPE_BOOL);
3858 cx_assert(property != NULL);
3860 if (comment != NULL) cpl_property_set_comment(property, comment);
3862 cpl_property_set_bool(property, value);
3863 uves_deque_push_back(self->properties, property);
3865 return CPL_ERROR_NONE;
3900 int value,
const char *comment)
3903 const cxchar *
const _id =
"uves_propertylist_append_int";
3905 cpl_property *
property = NULL;
3908 if (
self == NULL || name == NULL) {
3909 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3910 return CPL_ERROR_NULL_INPUT;
3913 property = cpl_property_new(name, CPL_TYPE_INT);
3914 cx_assert(property != NULL);
3916 if (comment != NULL) cpl_property_set_comment(property, comment);
3918 cpl_property_set_int(property, value);
3919 uves_deque_push_back(self->properties, property);
3921 return CPL_ERROR_NONE;
3956 long value,
const char *comment)
3959 const cxchar *
const _id =
"uves_propertylist_append_long";
3961 cpl_property *
property = NULL;
3964 if (
self == NULL || name == NULL) {
3965 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
3966 return CPL_ERROR_NULL_INPUT;
3969 property = cpl_property_new(name, CPL_TYPE_LONG);
3970 cx_assert(property != NULL);
3972 if (comment != NULL) cpl_property_set_comment(property, comment);
3974 cpl_property_set_long(property, value);
3975 uves_deque_push_back(self->properties, property);
3977 return CPL_ERROR_NONE;
4012 float value,
const char *comment)
4015 const cxchar *
const _id =
"uves_propertylist_append_float";
4017 cpl_property *
property = NULL;
4020 if (
self == NULL || name == NULL) {
4021 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4022 return CPL_ERROR_NULL_INPUT;
4025 property = cpl_property_new(name, CPL_TYPE_FLOAT);
4026 cx_assert(property != NULL);
4028 if (comment != NULL) cpl_property_set_comment(property, comment);
4030 cpl_property_set_float(property, value);
4031 uves_deque_push_back(self->properties, property);
4033 return CPL_ERROR_NONE;
4068 double value,
const char *comment)
4071 const cxchar *
const _id =
"uves_propertylist_append_double";
4073 cpl_property *
property = NULL;
4076 if (
self == NULL || name == NULL) {
4077 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4078 return CPL_ERROR_NULL_INPUT;
4081 property = cpl_property_new(name, CPL_TYPE_DOUBLE);
4082 cx_assert(property != NULL);
4084 if (comment != NULL) cpl_property_set_comment(property, comment);
4086 cpl_property_set_double(property, value);
4087 uves_deque_push_back(self->properties, property);
4089 return CPL_ERROR_NONE;
4124 const char *value,
const char *comment)
4127 const cxchar *
const _id =
"uves_propertylist_append_string";
4129 cpl_property *
property = NULL;
4132 if (
self == NULL || name == NULL) {
4133 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4134 return CPL_ERROR_NULL_INPUT;
4137 property = cpl_property_new(name, CPL_TYPE_STRING);
4138 cx_assert(property != NULL);
4140 if (comment != NULL) cpl_property_set_comment(property, comment);
4142 cpl_property_set_string(property, value);
4143 uves_deque_push_back(self->properties, property);
4145 return CPL_ERROR_NONE;
4181 const cxchar *
const _id =
"uves_propertylist_append";
4184 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4185 return CPL_ERROR_NULL_INPUT;
4188 if (other != NULL) {
4190 uves_deque_const_iterator pos = uves_deque_begin(other->properties);
4192 while (pos != uves_deque_end(other->properties)) {
4194 const cpl_property *p = uves_deque_get(other->properties, pos);
4196 uves_deque_push_back(self->properties, cpl_property_duplicate(p));
4197 pos = uves_deque_next(other->properties, pos);
4203 return CPL_ERROR_NONE;
4242 const cxchar *
const _id =
"uves_propertylist_erase";
4244 uves_deque_iterator pos;
4247 if (
self == NULL || name == NULL) {
4248 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4252 pos = _uves_propertylist_find(
self, name);
4253 if (pos == uves_deque_end(self->properties)) {
4258 uves_deque_erase(self->properties, pos, (cx_free_func)cpl_property_delete);
4304 const cxchar *
const _id =
"uves_propertylist_erase_regexp";
4309 uves_deque_iterator first, last, pos;
4316 if (
self == NULL || regexp == NULL) {
4317 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4322 status = regcomp(&filter.re, regexp, REG_EXTENDED | REG_NOSUB);
4324 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
4328 filter.invert = invert == 0 ? FALSE : TRUE;
4330 first = uves_deque_begin(self->properties);
4331 last = uves_deque_end(self->properties);
4333 while (first < uves_deque_end(self->properties)) {
4337 p = uves_deque_get(self->properties, pos);
4338 if (_uves_propertylist_compare_regexp(p, &filter) == TRUE) {
4342 uves_deque_erase(self->properties, pos,
4343 (cx_free_func)cpl_property_delete);
4347 first = uves_deque_next(self->properties, first);
4350 regfree(&filter.re);
4385 const cxchar *
const _id =
"uves_propertylist_empty";
4387 uves_deque_iterator first, last;
4391 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4395 first = uves_deque_begin(self->properties);
4396 last = uves_deque_end(self->properties);
4398 while (first < uves_deque_end(self->properties)) {
4399 uves_deque_iterator pos = first;
4403 uves_deque_erase(self->properties, pos,
4404 (cx_free_func)cpl_property_delete);
4457 const cxchar *
const _id =
"uves_propertylist_update_char";
4459 uves_deque_iterator pos;
4462 if (
self == NULL || name == NULL) {
4463 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4464 return CPL_ERROR_NULL_INPUT;
4467 pos = _uves_propertylist_find(
self, name);
4469 if (pos == uves_deque_end(self->properties)) {
4471 cpl_property *
property = cpl_property_new(name, CPL_TYPE_CHAR);
4474 cx_assert(property != NULL);
4476 cpl_property_set_char(property, value);
4477 uves_deque_push_back(self->properties, property);
4481 cpl_property *
property = uves_deque_get(self->properties, pos);
4484 cx_assert(property != NULL);
4486 if (cpl_property_get_type(property) != CPL_TYPE_CHAR) {
4487 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
4488 return CPL_ERROR_TYPE_MISMATCH;
4491 cpl_property_set_char(property, value);
4495 return CPL_ERROR_NONE;
4543 const cxchar *
const _id =
"uves_propertylist_update_bool";
4545 uves_deque_iterator pos;
4548 if (
self == NULL || name == NULL) {
4549 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4550 return CPL_ERROR_NULL_INPUT;
4553 pos = _uves_propertylist_find(
self, name);
4555 if (pos == uves_deque_end(self->properties)) {
4557 cpl_property *
property = cpl_property_new(name, CPL_TYPE_BOOL);
4560 cx_assert(property != NULL);
4562 cpl_property_set_bool(property, value);
4563 uves_deque_push_back(self->properties, property);
4567 cpl_property *
property = uves_deque_get(self->properties, pos);
4570 cx_assert(property != NULL);
4572 if (cpl_property_get_type(property) != CPL_TYPE_BOOL) {
4573 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
4574 return CPL_ERROR_TYPE_MISMATCH;
4577 cpl_property_set_bool(property, value);
4581 return CPL_ERROR_NONE;
4629 const cxchar *
const _id =
"uves_propertylist_update_int";
4631 uves_deque_iterator pos;
4634 if (
self == NULL || name == NULL) {
4635 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4636 return CPL_ERROR_NULL_INPUT;
4639 pos = _uves_propertylist_find(
self, name);
4641 if (pos == uves_deque_end(self->properties)) {
4643 cpl_property *
property = cpl_property_new(name, CPL_TYPE_INT);
4646 cx_assert(property != NULL);
4648 cpl_property_set_int(property, value);
4649 uves_deque_push_back(self->properties, property);
4653 cpl_property *
property = uves_deque_get(self->properties, pos);
4656 cx_assert(property != NULL);
4658 if (cpl_property_get_type(property) != CPL_TYPE_INT) {
4659 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
4660 return CPL_ERROR_TYPE_MISMATCH;
4663 cpl_property_set_int(property, value);
4667 return CPL_ERROR_NONE;
4715 const cxchar *
const _id =
"uves_propertylist_update_long";
4717 uves_deque_iterator pos;
4720 if (
self == NULL || name == NULL) {
4721 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4722 return CPL_ERROR_NULL_INPUT;
4725 pos = _uves_propertylist_find(
self, name);
4727 if (pos == uves_deque_end(self->properties)) {
4729 cpl_property *
property = cpl_property_new(name, CPL_TYPE_LONG);
4732 cx_assert(property != NULL);
4734 cpl_property_set_long(property, value);
4735 uves_deque_push_back(self->properties, property);
4739 cpl_property *
property = uves_deque_get(self->properties, pos);
4742 cx_assert(property != NULL);
4744 if (cpl_property_get_type(property) != CPL_TYPE_LONG) {
4745 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
4746 return CPL_ERROR_TYPE_MISMATCH;
4749 cpl_property_set_long(property, value);
4753 return CPL_ERROR_NONE;
4801 const cxchar *
const _id =
"uves_propertylist_update_float";
4803 uves_deque_iterator pos;
4806 if (
self == NULL || name == NULL) {
4807 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4808 return CPL_ERROR_NULL_INPUT;
4811 pos = _uves_propertylist_find(
self, name);
4813 if (pos == uves_deque_end(self->properties)) {
4815 cpl_property *
property = cpl_property_new(name, CPL_TYPE_FLOAT);
4818 cx_assert(property != NULL);
4820 cpl_property_set_float(property, value);
4821 uves_deque_push_back(self->properties, property);
4825 cpl_property *
property = uves_deque_get(self->properties, pos);
4828 cx_assert(property != NULL);
4830 if (cpl_property_get_type(property) != CPL_TYPE_FLOAT) {
4831 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
4832 return CPL_ERROR_TYPE_MISMATCH;
4835 cpl_property_set_float(property, value);
4839 return CPL_ERROR_NONE;
4887 const cxchar *
const _id =
"uves_propertylist_update_double";
4889 uves_deque_iterator pos;
4892 if (
self == NULL || name == NULL) {
4893 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4894 return CPL_ERROR_NULL_INPUT;
4897 pos = _uves_propertylist_find(
self, name);
4899 if (pos == uves_deque_end(self->properties)) {
4901 cpl_property *
property = cpl_property_new(name, CPL_TYPE_DOUBLE);
4904 cx_assert(property != NULL);
4906 cpl_property_set_double(property, value);
4907 uves_deque_push_back(self->properties, property);
4911 cpl_property *
property = uves_deque_get(self->properties, pos);
4914 cx_assert(property != NULL);
4916 if (cpl_property_get_type(property) != CPL_TYPE_DOUBLE) {
4917 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
4918 return CPL_ERROR_TYPE_MISMATCH;
4921 cpl_property_set_double(property, value);
4925 return CPL_ERROR_NONE;
4973 const cxchar *
const _id =
"uves_propertylist_update_string";
4975 uves_deque_iterator pos;
4978 if (
self == NULL || name == NULL) {
4979 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
4980 return CPL_ERROR_NULL_INPUT;
4983 pos = _uves_propertylist_find(
self, name);
4985 if (pos == uves_deque_end(self->properties)) {
4987 cpl_property *
property = cpl_property_new(name, CPL_TYPE_STRING);
4990 cx_assert(property != NULL);
4992 cpl_property_set_string(property, value);
4993 uves_deque_push_back(self->properties, property);
4997 cpl_property *
property = uves_deque_get(self->properties, pos);
5000 cx_assert(property != NULL);
5002 if (cpl_property_get_type(property) != CPL_TYPE_STRING) {
5003 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
5004 return CPL_ERROR_TYPE_MISMATCH;
5007 cpl_property_set_string(property, value);
5011 return CPL_ERROR_NONE;
5069 const cxchar *
const _id =
"uves_propertylist_copy_property";
5071 uves_deque_iterator spos;
5072 uves_deque_iterator tpos;
5075 if (
self == NULL || other == NULL || name == NULL) {
5076 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
5077 return CPL_ERROR_NULL_INPUT;
5080 spos = _uves_propertylist_find(other, name);
5082 if (spos == uves_deque_end(other->properties)) {
5083 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
5084 return CPL_ERROR_DATA_NOT_FOUND;
5087 tpos = _uves_propertylist_find(
self, name);
5089 if (tpos == uves_deque_end(self->properties)) {
5091 cpl_property *p = cpl_property_duplicate(uves_deque_get(other->properties,
5093 uves_deque_push_back(self->properties, p);
5098 cpl_property *p = uves_deque_get(self->properties, tpos);
5099 cpl_property *_p = uves_deque_get(self->properties, spos);
5102 if (cpl_property_get_type(p) != cpl_property_get_type(_p)) {
5103 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
5104 return CPL_ERROR_TYPE_MISMATCH;
5107 switch (cpl_property_get_type(_p)) {
5110 cpl_property_set_char(p, cpl_property_get_char(_p));
5114 cpl_property_set_bool(p, cpl_property_get_bool(_p));
5118 cpl_property_set_int(p, cpl_property_get_int(_p));
5122 cpl_property_set_long(p, cpl_property_get_long(_p));
5125 case CPL_TYPE_FLOAT:
5126 cpl_property_set_float(p, cpl_property_get_float(_p));
5129 case CPL_TYPE_DOUBLE:
5130 cpl_property_set_double(p, cpl_property_get_double(_p));
5133 case CPL_TYPE_STRING:
5134 cpl_property_set_string(p, cpl_property_get_string(_p));
5139 cx_error(
"%s: Unsupported type encountered!", CX_CODE_POS);
5144 cpl_property_set_comment(p, cpl_property_get_comment(_p));
5148 return CPL_ERROR_NONE;
5219 const cxchar *
const _id =
"uves_propertylist_copy_property_regexp";
5226 uves_deque_const_iterator first, last;
5228 typedef struct _property_pair_ {
5233 property_pair *pairs = NULL;
5238 if (
self == NULL || other == NULL || regexp == NULL) {
5239 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
5240 return CPL_ERROR_NULL_INPUT;
5243 status = regcomp(&filter.re, regexp, REG_EXTENDED | REG_NOSUB);
5245 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5246 return CPL_ERROR_ILLEGAL_INPUT;
5249 filter.invert = invert == 0 ? FALSE : TRUE;
5252 count = uves_deque_size(other->properties);
5255 regfree(&filter.re);
5256 return CPL_ERROR_NONE;
5259 pairs = cx_malloc(count *
sizeof(property_pair));
5260 cx_assert(pairs != NULL);
5265 first = uves_deque_begin(other->properties);
5266 last = uves_deque_end(other->properties);
5268 while (first != last) {
5270 cpl_property *p = uves_deque_get(other->properties, first);
5273 if (_uves_propertylist_compare_regexp(p, &filter) == TRUE) {
5275 const cxchar *name = cpl_property_get_name(p);
5277 uves_deque_const_iterator pos = _uves_propertylist_find(
self, name);
5279 cpl_property *_p = NULL;
5282 if (pos != uves_deque_end(self->properties)) {
5284 _p = uves_deque_get(self->properties, pos);
5286 if (cpl_property_get_type(p) != cpl_property_get_type(_p)) {
5288 regfree(&filter.re);
5293 cpl_error_set(_id, CPL_ERROR_TYPE_MISMATCH);
5295 return CPL_ERROR_TYPE_MISMATCH;
5302 pairs[count].t = _p;
5307 first = uves_deque_next(other->properties, first);
5311 regfree(&filter.re);
5314 for (i = 0; i < count; i++) {
5316 if (pairs[i].t == NULL) {
5318 cpl_property *p = cpl_property_duplicate(pairs[i].s);
5319 uves_deque_push_back(self->properties, p);
5324 switch (cpl_property_get_type(pairs[i].s)) {
5327 cpl_property_set_char(pairs[i].t,
5328 cpl_property_get_char(pairs[i].s));
5332 cpl_property_set_bool(pairs[i].t,
5333 cpl_property_get_bool(pairs[i].s));
5337 cpl_property_set_int(pairs[i].t,
5338 cpl_property_get_int(pairs[i].s));
5342 cpl_property_set_long(pairs[i].t,
5343 cpl_property_get_long(pairs[i].s));
5346 case CPL_TYPE_FLOAT:
5347 cpl_property_set_float(pairs[i].t,
5348 cpl_property_get_float(pairs[i].s));
5351 case CPL_TYPE_DOUBLE:
5352 cpl_property_set_double(pairs[i].t,
5353 cpl_property_get_double(pairs[i].s));
5356 case CPL_TYPE_STRING:
5357 cpl_property_set_string(pairs[i].t,
5358 cpl_property_get_string(pairs[i].s));
5364 cx_error(
"%s: Unsupported type encountered!", CX_CODE_POS);
5375 return CPL_ERROR_NONE;
5444 const cxchar *
const _id =
"uves_propertylist_load";
5446 register cxint n, status;
5448 qfits_header *header;
5454 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
5459 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5463 status = qfits_is_fits((cxchar *)name);
5465 cpl_error_set(_id, CPL_ERROR_FILE_IO);
5470 cpl_error_set(_id, CPL_ERROR_BAD_FILE_FORMAT);
5481 n = qfits_query_n_ext((cxchar *)name);
5484 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
5489 header = qfits_header_readext((cxchar *)name, position);
5491 if (header == NULL) {
5492 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5499 status = _uves_propertylist_from_fits(
self, header, NULL, NULL);
5503 qfits_header_destroy(header);
5505 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5509 qfits_header_destroy(header);
5589 const char *regexp,
int invert)
5592 const cxchar *
const _id =
"uves_propertylist_load_regexp";
5594 register cxint n, status;
5596 qfits_header *header;
5603 if (name == NULL || regexp == NULL) {
5604 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
5609 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5613 status = regcomp(&filter.re, regexp, REG_EXTENDED | REG_NOSUB);
5615 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5619 filter.invert = invert == 0 ? FALSE : TRUE;
5622 status = qfits_is_fits((cxchar *)name);
5624 cpl_error_set(_id, CPL_ERROR_FILE_IO);
5629 cpl_error_set(_id, CPL_ERROR_BAD_FILE_FORMAT);
5640 n = qfits_query_n_ext((cxchar *)name);
5643 cpl_error_set(_id, CPL_ERROR_DATA_NOT_FOUND);
5648 header = qfits_header_readext((cxchar *)name, position);
5650 if (header == NULL) {
5651 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5658 status = _uves_propertylist_from_fits(
self, header,
5659 _uves_propertylist_filter_regexp,
5664 qfits_header_destroy(header);
5666 regfree(&filter.re);
5668 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5672 qfits_header_destroy(header);
5673 regfree(&filter.re);
5700 const cxchar *
const _id =
"uves_propertylist_to_fits";
5702 qfits_header *header;
5705 cx_assert(
self != NULL);
5707 header = qfits_header_new();
5709 if (!uves_deque_empty(self->properties)) {
5710 uves_deque_iterator i = uves_deque_begin(self->properties);
5711 uves_deque_iterator last = uves_deque_end(self->properties);
5714 cxchar tmp[FITS_LINESZ + 1];
5715 cxchar key[FITS_LINESZ + 1];
5716 cxchar value[FITS_LINESZ + 1];
5719 cpl_property *property;
5721 property = uves_deque_get(self->properties, i);
5733 strncpy(tmp, cpl_property_get_name(property), FITS_LINESZ);
5734 tmp[FITS_LINESZ] =
'\0';
5736 if (!cx_strupper(tmp)) {
5737 cpl_error_set(_id, CPL_ERROR_INCOMPATIBLE_INPUT);
5739 qfits_header_destroy(header);
5746 if (strlen(tmp) > FITS_STDKEY_MAX &&
5747 strncmp(tmp,
"HIERARCH ", 9)) {
5748 strncat(key,
"HIERARCH ", 9);
5750 strncat(key, tmp, FITS_LINESZ - strlen(key));
5752 switch (cpl_property_get_type(property)) {
5754 cx_snprintf(value, FITS_LINESZ,
"'%c'",
5755 cpl_property_get_char(property));
5760 cxint pvalue = cpl_property_get_bool(property);
5762 cx_snprintf(value, FITS_LINESZ,
"%c",
5763 pvalue == 1 ?
'T' :
'F');
5768 cx_snprintf(value, FITS_LINESZ,
"%d",
5769 cpl_property_get_int(property));
5773 cx_snprintf(value, FITS_LINESZ,
"%ld",
5774 cpl_property_get_long(property));
5777 case CPL_TYPE_FLOAT:
5778 fval = cpl_property_get_float(property);
5779 cx_snprintf(value, FITS_LINESZ,
"%.7G", fval);
5781 if (!strchr(value,
'.')) {
5782 if (strchr(value,
'E'))
5783 cx_snprintf(value, FITS_LINESZ,
"%.1E", fval);
5789 case CPL_TYPE_DOUBLE:
5790 dval = cpl_property_get_double(property);
5791 cx_snprintf(value, FITS_LINESZ,
"%.15G", dval);
5793 if (!strchr(value,
'.')) {
5794 if (strchr(value,
'E'))
5795 cx_snprintf(value, FITS_LINESZ,
"%.1E", dval);
5801 case CPL_TYPE_STRING:
5802 if (!strcmp(key,
"COMMENT") || !strcmp(key,
"HISTORY")) {
5803 cx_snprintf(value, FITS_LINESZ,
"%s",
5804 cpl_property_get_string(property));
5810 n = cx_snprintf(value, FITS_SVALUE_MAX + 1,
"'%s'",
5811 cpl_property_get_string(property));
5813 if (n > FITS_SVALUE_MAX) {
5814 value[FITS_SVALUE_MAX - 1] =
'\'';
5815 value[FITS_SVALUE_MAX] =
'\0';
5822 cpl_error_set(_id, CPL_ERROR_INCOMPATIBLE_INPUT);
5824 qfits_header_destroy(header);
5830 qfits_header_append(header, key, value,
5831 (cxchar *)cpl_property_get_comment(property),
5834 i = uves_deque_next(self->properties, i);
5845 qfits_header_append(header,
"END", NULL, NULL, NULL);
5852 if (qfits_header_sort(&header) != 0) {
5853 cpl_error_set(_id, CPL_ERROR_INCOMPATIBLE_INPUT);
5855 qfits_header_destroy(header);
5888 uves_propertylist_from_fits(
const qfits_header *header)
5891 const cxchar *
const _id =
"uves_propertylist_from_fits";
5893 register cxint status;
5899 cpl_error_set(_id, CPL_ERROR_NULL_INPUT);
5904 cx_assert(
self != NULL);
5906 status = _uves_propertylist_from_fits(
self, header, NULL, NULL);
5916 cpl_error_set(_id, CPL_ERROR_ILLEGAL_INPUT);
5920 cpl_error_set(_id, CPL_ERROR_INVALID_TYPE);
const cpl_property * uves_propertylist_get_const(const uves_propertylist *self, long position)
Access property list elements by index.
cpl_error_code uves_propertylist_prepend_long(uves_propertylist *self, const char *name, long value)
Prepend a long value to a property list.
cpl_error_code uves_propertylist_insert_after_double(uves_propertylist *self, const char *after, const char *name, double value)
Insert a double value into a property list after the given position.
int uves_propertylist_get_bool(const uves_propertylist *self, const char *name)
Get the boolean value of the given property list entry.
const char * uves_propertylist_get_comment(const uves_propertylist *self, const char *name)
Get the comment of the given property list entry.
cpl_error_code uves_propertylist_prepend_string(uves_propertylist *self, const char *name, const char *value)
Prepend a string value to a property list.
cpl_error_code uves_propertylist_insert_int(uves_propertylist *self, const char *here, const char *name, int value)
Insert a integer value into a property list at the given position.
void uves_propertylist_empty(uves_propertylist *self)
Remove all properties from a property list.
int uves_propertylist_erase(uves_propertylist *self, const char *name)
Erase the given property from a property list.
cpl_error_code uves_propertylist_insert_after_char(uves_propertylist *self, const char *after, const char *name, char value)
Insert a character value into a property list after the given position.
int uves_propertylist_is_empty(const uves_propertylist *self)
Check whether a property list is empty.
double uves_propertylist_get_double(const uves_propertylist *self, const char *name)
Get the double value of the given property list entry.
cpl_error_code uves_propertylist_insert_float(uves_propertylist *self, const char *here, const char *name, float value)
Insert a float value into a property list at the given position.
cpl_error_code uves_propertylist_append_c_long(uves_propertylist *self, const char *name, long value, const char *comment)
Append a long value to a property list.
cpl_error_code uves_propertylist_update_bool(uves_propertylist *self, const char *name, int value)
Update a property list with a boolean value.
cpl_error_code uves_propertylist_update_float(uves_propertylist *self, const char *name, float value)
Update a property list with a float value.
cpl_error_code uves_propertylist_set_double(uves_propertylist *self, const char *name, double value)
Set the value of the given double property list entry.
cpl_error_code uves_propertylist_insert_bool(uves_propertylist *self, const char *here, const char *name, int value)
Insert a boolean value into a property list at the given position.
cpl_error_code uves_propertylist_insert_after_long(uves_propertylist *self, const char *after, const char *name, long value)
Insert a long value into a property list after the given position.
cpl_error_code uves_propertylist_append_c_int(uves_propertylist *self, const char *name, int value, const char *comment)
Append an integer value to a property list.
cpl_error_code uves_propertylist_insert_long(uves_propertylist *self, const char *here, const char *name, long value)
Insert a long value into a property list at the given position.
cpl_error_code uves_propertylist_prepend_char(uves_propertylist *self, const char *name, char value)
Prepend a character value to a property list.
cpl_error_code uves_propertylist_update_string(uves_propertylist *self, const char *name, const char *value)
Update a property list with a string value.
long uves_propertylist_get_long(const uves_propertylist *self, const char *name)
Get the long value of the given property list entry.
cpl_error_code uves_propertylist_prepend_float(uves_propertylist *self, const char *name, float value)
Prepend a float value to a property list.
cpl_type uves_propertylist_get_type(const uves_propertylist *self, const char *name)
Get the the type of a property list entry.
uves_propertylist * uves_propertylist_new(void)
Create an empty property list.
long uves_propertylist_get_size(const uves_propertylist *self)
Get the current size of a property list.
cpl_error_code uves_propertylist_set_comment(uves_propertylist *self, const char *name, const char *comment)
Modify the comment field of the given property list entry.
const char * uves_propertylist_get_string(const uves_propertylist *self, const char *name)
Get the string value of the given property list entry.
uves_propertylist * uves_propertylist_load(const char *name, int position)
Create a property list from a file.
cpl_error_code uves_propertylist_set_string(uves_propertylist *self, const char *name, const char *value)
Set the value of the given string property list entry.
cpl_error_code uves_propertylist_set_int(uves_propertylist *self, const char *name, int value)
Set the value of the given integer property list entry.
cpl_error_code uves_propertylist_copy_property_regexp(uves_propertylist *self, const uves_propertylist *other, const char *regexp, int invert)
Copy matching properties from another property list.
char uves_propertylist_get_char(const uves_propertylist *self, const char *name)
Get the character value of the given property list entry.
cpl_error_code uves_propertylist_append_c_float(uves_propertylist *self, const char *name, float value, const char *comment)
Append a float value to a property list.
cpl_error_code uves_propertylist_append_c_char(uves_propertylist *self, const char *name, char value, const char *comment)
Append a character value to a property list.
cpl_error_code uves_propertylist_append_c_string(uves_propertylist *self, const char *name, const char *value, const char *comment)
Append a string value to a property list.
cpl_error_code uves_propertylist_update_char(uves_propertylist *self, const char *name, char value)
Update a property list with a character value.
cpl_error_code uves_propertylist_insert_char(uves_propertylist *self, const char *here, const char *name, char value)
Insert a character value into a property list at the given position.
cpl_error_code uves_propertylist_set_float(uves_propertylist *self, const char *name, float value)
Set the value of the given float property list entry.
int my_uves_propertylist_contains(const cpl_propertylist *self, const char *name)
Check whether a property is present in a property list.
int uves_propertylist_get_int(const uves_propertylist *self, const char *name)
Get the integer value of the given property list entry.
const char * uves_tostring_cpl_type(cpl_type t)
Convert a CPL type to a string.
cpl_error_code uves_propertylist_set_char(uves_propertylist *self, const char *name, char value)
Set the value of the given character property list entry.
cpl_error_code uves_propertylist_append_c_bool(uves_propertylist *self, const char *name, int value, const char *comment)
Append a boolean value to a property list.
cpl_error_code uves_propertylist_prepend_double(uves_propertylist *self, const char *name, double value)
Prepend a double value to a property list.
cpl_error_code uves_propertylist_prepend_int(uves_propertylist *self, const char *name, int value)
Prepend a integer value to a property list.
int uves_propertylist_erase_regexp(uves_propertylist *self, const char *regexp, int invert)
Erase all properties with name matching a given regular expression.
cpl_error_code uves_propertylist_insert_double(uves_propertylist *self, const char *here, const char *name, double value)
Insert a double value into a property list at the given position.
cpl_error_code uves_propertylist_insert_after_string(uves_propertylist *self, const char *after, const char *name, const char *value)
Insert a string value into a property list after the given position.
cpl_error_code uves_propertylist_insert_after_bool(uves_propertylist *self, const char *after, const char *name, int value)
Insert a boolean value into a property list after the given position.
cpl_error_code uves_propertylist_update_long(uves_propertylist *self, const char *name, long value)
Update a property list with a long value.
cpl_error_code uves_propertylist_insert_after_int(uves_propertylist *self, const char *after, const char *name, int value)
Insert a integer value into a property list after the given position.
cpl_error_code uves_propertylist_set_long(uves_propertylist *self, const char *name, long value)
Set the value of the given long property list entry.
uves_propertylist * uves_propertylist_duplicate(const uves_propertylist *self)
Create a copy of the given property list.
int uves_propertylist_contains(const uves_propertylist *self, const char *name)
Check whether a property is present in a property list.
void uves_propertylist_delete(const uves_propertylist *self)
Destroy a property list.
cpl_error_code uves_propertylist_append_c_double(uves_propertylist *self, const char *name, double value, const char *comment)
Append a double value to a property list.
float uves_propertylist_get_float(const uves_propertylist *self, const char *name)
Get the float value of the given property list entry.
cpl_error_code uves_propertylist_update_int(uves_propertylist *self, const char *name, int value)
Update a property list with a integer value.
cpl_error_code uves_propertylist_insert_after_float(uves_propertylist *self, const char *after, const char *name, float value)
Insert a float value into a property list after the given position.
cpl_error_code uves_propertylist_set_bool(uves_propertylist *self, const char *name, int value)
Set the value of the given boolean property list entry.
cpl_error_code uves_propertylist_prepend_bool(uves_propertylist *self, const char *name, int value)
Prepend a boolean value to a property list.
cpl_error_code uves_propertylist_insert_string(uves_propertylist *self, const char *here, const char *name, const char *value)
Insert a string value into a property list at the given position.
int uves_propertylist_has(const uves_propertylist *self, const char *name)
Check whether a property is present in a property list.
uves_propertylist * uves_propertylist_load_regexp(const char *name, int position, const char *regexp, int invert)
Create a filtered property list from a file.
cpl_error_code uves_propertylist_update_double(uves_propertylist *self, const char *name, double value)
Update a property list with a double value.
cpl_error_code uves_propertylist_append(uves_propertylist *self, const uves_propertylist *other)
Append a property list..
cpl_error_code uves_propertylist_copy_property(uves_propertylist *self, const uves_propertylist *other, const char *name)
Copy a property from another property list.