From 06c4d6cc017eb7bcb5df548422baa8dea1b286db Mon Sep 17 00:00:00 2001 From: Attila Kovacs Date: Mon, 9 Sep 2024 21:16:27 +0200 Subject: [PATCH] Revert moving SMA-X specific conveninece methods here. --- include/xchange.h | 6 ---- src/xstruct.c | 88 ----------------------------------------------- 2 files changed, 94 deletions(-) diff --git a/include/xchange.h b/include/xchange.h index 03bd0a2..dcb67a9 100644 --- a/include/xchange.h +++ b/include/xchange.h @@ -210,12 +210,6 @@ XField *xSetSubstruct(XStructure *s, const char *name, XStructure *substruct); int xReduceDims(int *ndim, int *sizes); int xReduceAllDims(XStructure *s); -// Convenience method for structure fields ---------------> -boolean xGetBooleanField(const XStructure *s, const char *name, boolean defaultValue); -long long xGetLongField(const XStructure *s, const char *name, long long defaultValue); -double xGetDoubleField(const XStructure *s, const char *name, double defaultValue); -char *xGetRawField(const XStructure *s, const char *name, char *defaultValue); - // Sorting, ordering int xSortFields(XStructure *s, int (*cmp)(const XField **f1, const XField **f2), boolean recursive); int xSortFieldsByName(XStructure *s, boolean recursive); diff --git a/src/xstruct.c b/src/xstruct.c index 88a50f6..4b2e680 100644 --- a/src/xstruct.c +++ b/src/xstruct.c @@ -226,94 +226,6 @@ XField *xGetField(const XStructure *s, const char *id) { return NULL; } -/** - * Returns the first value in a structure's field as an integer, or the specified default - * value if there is no such fiield in the structure, or the content cannot be parse into an integer. - * - * @param s Pointer to the XStructure. - * @param name Field name - * @param defaultValue Value to return if no corresponding integer field value. - * @return The (first) field value as a long long, or the default value if there is no such field. - * - * @sa xGetField() - */ -boolean xGetBooleanField(const XStructure *s, const char *name, boolean defaultValue) { - boolean b; - const XField *f = xGetField(s, name); - - if(!f) return defaultValue; - - b = xParseBoolean(f->value, NULL); - if(b < 0) return defaultValue; - return b; -} - -/** - * Returns the first value in a structure's field as an integer, or the specified default - * value if there is no such fiield in the structure, or the content cannot be parse into an integer. - * - * @param s Pointer to the XStructure. - * @param name Field name - * @param defaultValue Value to return if no corresponding integer field value. - * @return The (first) field value as a long long, or the default value if there is no such field. - * - * @sa xGetField() - */ -long long xGetLongField(const XStructure *s, const char *name, long long defaultValue) { - int i; - char *end; - const XField *f = xGetField(s, name); - - if(!f) return defaultValue; - - i = strtol(f->value, &end, 0); - if(end == f->value) return defaultValue; - if(errno == ERANGE) return defaultValue; - return i; -} - - -/** - * Returns the first value in a structure's field as a double precision float, or the specified - * default value if there is no such fiield in the structure, or the content cannot be parse into an double. - * - * @param s Pointer to the XStructure. - * @param name Field name - * @param defaultValue Value to return if no corresponding integer field value. - * @return The (first) field value as a double, or the specified default if there is no such field. - * - * @sa xGetField() - */ -double xGetDoubleField(const XStructure *s, const char *name, double defaultValue) { - double d; - char *end; - const XField *f = xGetField(s, name); - - if(!f) return defaultValue; - - d = strtod(f->value, &end); - if(end == f->value) return defaultValue; - if(errno == ERANGE) return defaultValue; - return d; -} - -/** - * Returns the string value in a structure's field, or the specified default value if there is no - * such fiield in the structure. - * - * @param s Pointer to the XStructure. - * @param name Field name - * @param defaultValue Value to return if no corresponding integer field value. - * @return The field's string (raw) value, or the specified default if there is no such field. - * - * @sa xGetField() - */ -char *xGetRawField(const XStructure *s, const char *name, char *defaultValue) { - const XField *f = xGetField(s, name); - if(!f) return defaultValue; - return f->value; -} - /** * Returns a substructure by the specified name, or NULL if no such sub-structure exists. *