|
From: <kin...@us...> - 2023-07-11 05:55:54
|
Revision: 7068
http://sourceforge.net/p/teem/code/7068
Author: kindlmann
Date: 2023-07-11 05:55:51 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
type-specific kinds 1, 2, and 3 now all finished
Modified Paths:
--------------
teem/trunk/src/hest/adders.c
teem/trunk/src/hest/hest.h
teem/trunk/src/hest/parseHest.c
teem/trunk/src/hest/test/ex6.c
Modified: teem/trunk/src/hest/adders.c
===================================================================
--- teem/trunk/src/hest/adders.c 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/adders.c 2023-07-11 05:55:51 UTC (rev 7068)
@@ -24,9 +24,9 @@
/* --------------------------------------------------------------- 1 == kind */
unsigned int
-hestOptAdd_Flag(hestOpt **optP, const char *flag, int *valueP, const char *info) {
+hestOptAdd_Flag(hestOpt **hoptP, const char *flag, int *valueP, const char *info) {
- return hestOptAdd_nva(optP, flag, NULL /* name */, airTypeInt /* actually moot */,
+ return hestOptAdd_nva(hoptP, flag, NULL /* name */, airTypeInt /* actually moot */,
0 /* min */, 0 /* max */, valueP, NULL /* default */, info, /* */
NULL, NULL, NULL);
}
@@ -33,223 +33,265 @@
/* --------------------------------------------------------------- 2 == kind */
unsigned int
-hestOptAdd_1_Bool(hestOpt **optP, const char *flag, const char *name, /* */
- int *valueP, int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%s", airEnumStr(airBool, !!dflt));
- return hestOptAdd_nva(optP, flag, name, airTypeBool, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Bool(hestOpt **hoptP, const char *flag, const char *name, /* */
+ int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeBool, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Int(hestOpt **optP, const char *flag, const char *name, /* */
- int *valueP, int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%d", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Int(hestOpt **hoptP, const char *flag, const char *name, /* */
+ int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_UInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned int *valueP, unsigned int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%u", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeUInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_UInt(hestOpt **hoptP, const char *flag, const char *name, /* */
+ unsigned int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeUInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_LongInt(hestOpt **optP, const char *flag, const char *name, /* */
- long int *valueP, long int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%ld", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeLongInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_LongInt(hestOpt **hoptP, const char *flag, const char *name, /* */
+ long int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeLongInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_ULongInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned long int *valueP, unsigned long int dflt,
- const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%lu", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeULongInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_ULongInt(hestOpt **hoptP, const char *flag, const char *name, /* */
+ unsigned long int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeULongInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Size_t(hestOpt **optP, const char *flag, const char *name, /* */
- size_t *valueP, size_t dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- airSprintSize_t(dfltStr, dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeSize_t, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Size_t(hestOpt **hoptP, const char *flag, const char *name, /* */
+ size_t *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeSize_t, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Float(hestOpt **optP, const char *flag, const char *name, /* */
- float *valueP, float dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- airSinglePrintf(NULL, dfltStr, "%g", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeFloat, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Float(hestOpt **hoptP, const char *flag, const char *name, /* */
+ float *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeFloat, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Double(hestOpt **optP, const char *flag, const char *name, /* */
- double *valueP, double dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- airSinglePrintf(NULL, dfltStr, "%lg", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeDouble, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Double(hestOpt **hoptP, const char *flag, const char *name, /* */
+ double *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeDouble, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Char(hestOpt **optP, const char *flag, const char *name, /* */
- char *valueP, char dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%c", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeChar, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Char(hestOpt **hoptP, const char *flag, const char *name, /* */
+ char *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeChar, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_String(hestOpt **optP, const char *flag, const char *name, /* */
+hestOptAdd_1_String(hestOpt **hoptP, const char *flag, const char *name, /* */
char **valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeString, 1, 1, /* */
- valueP, dflt, info, /* */
+ return hestOptAdd_nva(hoptP, flag, name, airTypeString, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Enum(hestOpt **optP, const char *flag, const char *name, /* */
- int *valueP, int dflt, const char *info, /* */
+hestOptAdd_1_Enum(hestOpt **hoptP, const char *flag, const char *name, /* */
+ int *valueP, const char *dflt, const char *info, /* */
const airEnum *enm) {
- return hestOptAdd_nva(optP, flag, name, airTypeEnum, 1, 1, /* */
- valueP, airEnumStr(enm, dflt), info, /* */
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, enm, NULL);
}
unsigned int
-hestOptAdd_1_Other(hestOpt **optP, const char *flag, const char *name, /* */
- void *valueP, const char *dflt, const char *info, /* */
+hestOptAdd_1_Other(hestOpt **hoptP, const char *flag, const char *name, /* */
+ void *valueP, const char *dflt, const char *info, /* */
const hestCB *CB) {
- return hestOptAdd_nva(optP, flag, name, airTypeOther, 1, 1, /* */
- valueP, dflt, info, /* */
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, CB);
}
-#if 0
+
/* --------------------------------------------------------------- 2 == kind */
-unsigned int
-hestOptAdd_2_Bool(hestOpt **optP, const char *flag, const char *name, /* */
- int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeBool, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
-unsigned int
-hestOptAdd_2_Int(hestOpt **optP, const char *flag, const char *name, /* */
- int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* for some reason writing out code above (and their declarations in hest.h) by hand was
+ok, but from here on out its going to use a lot of macro tricks, with these name
+conventions:
-unsigned int
-hestOptAdd_2_UInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned int valueP[3], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeUInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+M = 2, 3, or 4 = fixed # of parameters
+N = user-given fixed # of parameters
+_S = simple scalar types
+_E = airEnum
+_O = Other
-unsigned int
-hestOptAdd_2_LongInt(hestOpt **optP, const char *flag, const char *name, /* */
- long int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeLongInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+Some way of gracefully handling the 10 different simple types, plus the airEnum and
+Other, with the context of the functional-ish MAP macros, is surely possible, but it
+eludes GLK at this time */
-unsigned int
-hestOptAdd_2_ULongInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned long int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeULongInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* _S: simple scalar types */
+#define DCL_M_S(M, ATYP, CTYP) \
+ unsigned int hestOptAdd_##M##_##ATYP(hestOpt **hoptP, const char *flag, \
+ const char *name, CTYP valueP[M], \
+ const char *dflt, const char *info)
+#define BODY_M_S(M, ATYP, CTYP) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, M, M, valueP, dflt, info, \
+ NULL, NULL, NULL); \
+ }
+#define DEF_M_S(M, ATYP, CTYP) DCL_M_S(M, ATYP, CTYP) BODY_M_S(M, ATYP, CTYP)
+#define DCL_N_S(ATYP, CTYP) \
+ unsigned int hestOptAdd_N_##ATYP(hestOpt **hoptP, const char *flag, const char *name, \
+ unsigned int N, CTYP *valueP, const char *dflt, \
+ const char *info)
+#define BODY_N_S(ATYP, CTYP) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, N, N, valueP, dflt, info, \
+ NULL, NULL, NULL); \
+ }
+#define DEF_N_S(ATYP, CTYP) DCL_N_S(ATYP, CTYP) BODY_N_S(ATYP, CTYP)
-unsigned int
-hestOptAdd_2_Size_t(hestOpt **optP, const char *flag, const char *name, /* */
- size_t valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeSize_t, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* _E: Enum */
+#define DCL_M_E(M) \
+ unsigned int hestOptAdd_##M##_Enum(hestOpt **hoptP, const char *flag, \
+ const char *name, int valueP[M], const char *dflt, \
+ const char *info, const airEnum *enm)
+#define BODY_M_E(M) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, M, M, valueP, dflt, info, \
+ NULL, enm, NULL); \
+ }
+#define DEF_M_E(M) DCL_M_E(M) BODY_M_E(M)
+#define DCL_N_E \
+ unsigned int hestOptAdd_N_Enum(hestOpt **hoptP, const char *flag, const char *name, \
+ unsigned int N, int *valueP, const char *dflt, \
+ const char *info, const airEnum *enm)
+#define BODY_N_E \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, N, N, valueP, dflt, info, \
+ NULL, enm, NULL); \
+ }
+#define DEF_N_E DCL_N_E BODY_N_E
-unsigned int
-hestOptAdd_2_Float(hestOpt **optP, const char *flag, const char *name, /* */
- float valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeFloat, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* _O: Other */
+#define DCL_M_O(M) \
+ unsigned int hestOptAdd_##M##_Other(hestOpt **hoptP, const char *flag, \
+ const char *name, void *valueP, const char *dflt, \
+ const char *info, const hestCB *CB)
+#define BODY_M_O(M) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, M, M, valueP, dflt, info, \
+ NULL, NULL, CB); \
+ }
+#define DEF_M_O(M) DCL_M_O(M) BODY_M_O(M)
+#define DCL_N_O \
+ unsigned int hestOptAdd_N_Other(hestOpt **hoptP, const char *flag, const char *name, \
+ unsigned int N, void *valueP, const char *dflt, \
+ const char *info, const hestCB *CB)
+#define BODY_N_O \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, N, N, valueP, dflt, info, \
+ NULL, NULL, CB); \
+ }
+#define DEF_N_O DCL_N_O BODY_N_O
-unsigned int
-hestOptAdd_2_Double(hestOpt **optP, const char *flag, const char *name, /* */
- double valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeDouble, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* MAP_M_S takes a macro MMAC that (like DCL_M_S or DEF_M_S) takes three args
+-- M, ATYP, CTYP -- and applies it to all the simple scalar types.
+MAP_N_S takes a macro NMAC (like DCL_N_S or DEF_N_S) that takes just two args
+-- ATYP, CTYPE -- and applies to the scalar types */
+#define MAP_M_S(MMAC, M) \
+ MMAC(M, Bool, int) \
+ MMAC(M, Int, int) \
+ MMAC(M, UInt, unsigned int) \
+ MMAC(M, LongInt, long int) \
+ MMAC(M, ULongInt, unsigned long int) \
+ MMAC(M, Size_t, size_t) \
+ MMAC(M, Float, float) \
+ MMAC(M, Double, double) \
+ MMAC(M, Char, char) \
+ MMAC(M, String, char *)
+/* (yes would be nicer to avoid copy-pasta, but how?) */
+#define MAP_N_S(NMAC) \
+ NMAC(Bool, int) \
+ NMAC(Int, int) \
+ NMAC(UInt, unsigned int) \
+ NMAC(LongInt, long int) \
+ NMAC(ULongInt, unsigned long int) \
+ NMAC(Size_t, size_t) \
+ NMAC(Float, float) \
+ NMAC(Double, double) \
+ NMAC(Char, char) \
+ NMAC(String, char *)
-unsigned int
-hestOptAdd_2_Char(hestOpt **optP, const char *flag, const char *name, /* */
- char valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeChar, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* v.v.v.v.v.v.v.v.v Actual code! v.v.v.v.v.v.v.v.v */
+MAP_M_S(DEF_M_S, 2)
+DEF_M_E(2)
+DEF_M_O(2)
+MAP_M_S(DEF_M_S, 3)
+DEF_M_E(3)
+DEF_M_O(3)
+MAP_M_S(DEF_M_S, 4)
+DEF_M_E(4)
+DEF_M_O(4)
+MAP_N_S(DEF_N_S)
+DEF_N_E
+DEF_N_O
+/* ^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^ */
-unsigned int
-hestOptAdd_2_String(hestOpt **optP, const char *flag, const char *name, /* */
- char *valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeString, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* Macro for making a string out of whatever something has been #define'd to, exactly,
+ without chasing down a sequence of #includes.
+ https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html */
+#define __STR(name) #name
+#define _STR(name) __STR(name)
-unsigned int
-hestOptAdd_2_Enum(hestOpt **optP, const char *flag, const char *name, /* */
- int valueP[2], const char *dflt, const char *info, /* */
- const airEnum *enm) {
- return hestOptAdd_nva(optP, flag, name, airTypeEnum, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, enm, NULL);
-}
+/* for generating body of hestOptAddDeclsPrint;
+NOTE assuming the local FILE *ff */
+#define PRINT_M_S(M, ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_M_S(M, ATYP, CTYP)) ";\n");
+#define PRINT_M_E(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_M_E(M)) ";\n");
+#define PRINT_M_O(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_M_O(M)) ";\n");
+#define PRINT_N_S(ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_N_S(ATYP, CTYP)) ";\n");
+#define PRINT_N_E fprintf(ff, "HEST_EXPORT " _STR(DCL_N_E) ";\n");
+#define PRINT_N_O fprintf(ff, "HEST_EXPORT " _STR(DCL_N_O) ";\n");
-unsigned int
-hestOptAdd_2_Other(hestOpt **optP, const char *flag, const char *name, /* */
- void *valueP[2], const char *dflt, const char *info, /* */
- const hestCB *CB) {
- return hestOptAdd_nva(optP, flag, name, airTypeOther, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, CB);
+/* prints declarations for everything defined by macro above, which
+HEY does not includethe hestOptAdd_Flag and hestOptAdd_1_* functions */
+void
+hestOptAddDeclsPrint(FILE *ff) {
+ /* HEY copy-pasta from "Actual code" above */
+ MAP_M_S(PRINT_M_S, 2)
+ PRINT_M_E(2)
+ PRINT_M_O(2)
+ MAP_M_S(PRINT_M_S, 3)
+ PRINT_M_E(3)
+ PRINT_M_O(3)
+ MAP_M_S(PRINT_M_S, 4)
+ PRINT_M_E(4)
+ PRINT_M_O(4)
+ MAP_N_S(PRINT_N_S)
+ PRINT_N_E
+ PRINT_N_O
}
-#endif
/*
hestOptSetXX(hestOpt *opt, )
1<T>, 2<T>, 3<T>, 4<T>, N<T>
Modified: teem/trunk/src/hest/hest.h
===================================================================
--- teem/trunk/src/hest/hest.h 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/hest.h 2023-07-11 05:55:51 UTC (rev 7068)
@@ -60,9 +60,9 @@
/*
******** hestCB struct
**
-** for when the thing you want to parse from the command-line is not a simple boolean,
-** number, airEnum, or string. hestParse() will not allocate anything to store
-** individual things, though it may allocate an array in the case of a multiple
+** for when the thing you want to parse from the command-line is airTypeOther: not a
+** simple boolean, number, string, or airEnum. hestParse() will not allocate anything to
+** store individual things, though it may allocate an array in the case of a multiple
** variable parameter option. If your things are actually pointers to things, then you
** do the allocation in the parse() callback. In this case, you set destroy() to be
** your "destructor", and it will be called on the result of derefencing the argument
@@ -287,46 +287,213 @@
const hestParm *parm);
/* adders.c */
+HEST_EXPORT void hestOptAddDeclsPrint(FILE *f);
HEST_EXPORT unsigned int hestOptAdd_Flag(hestOpt **optP, const char *flag, int *valueP,
const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Bool(hestOpt **optP, const char *flag,
- const char *name, int *valueP, int dflt,
- const char *info);
+ const char *name, int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Int(hestOpt **optP, const char *flag,
- const char *name, int *valueP, int dflt,
- const char *info);
+ const char *name, int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_UInt(hestOpt **optP, const char *flag,
const char *name, unsigned int *valueP,
- unsigned int dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_LongInt(hestOpt **optP, const char *flag,
const char *name, long int *valueP,
- long int dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_ULongInt(hestOpt **optP, const char *flag,
const char *name,
unsigned long int *valueP,
- unsigned long int dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Size_t(hestOpt **optP, const char *flag,
const char *name, size_t *valueP,
- size_t dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Float(hestOpt **optP, const char *flag,
- const char *name, float *valueP, float dflt,
- const char *info);
+ const char *name, float *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Double(hestOpt **optP, const char *flag,
const char *name, double *valueP,
- double dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Char(hestOpt **optP, const char *flag,
- const char *name, char *valueP, char dflt,
- const char *info);
+ const char *name, char *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_String(hestOpt **optP, const char *flag,
const char *name, char **valueP,
const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Enum(hestOpt **optP, const char *flag,
- const char *name, int *valueP, int dflt,
- const char *info, const airEnum *enm);
+ const char *name, int *valueP,
+ const char *dflt, const char *info,
+ const airEnum *enm);
HEST_EXPORT unsigned int hestOptAdd_1_Other(hestOpt **optP, const char *flag,
const char *name, void *valueP,
const char *dflt, const char *info,
const hestCB *CB);
+/* from here on, declarations are from calling hestOptAddDeclsPrint and then
+clang-formatting */
+HEST_EXPORT unsigned int hestOptAdd_2_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Int(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, size_t valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Float(hestOpt **hoptP, const char *flag,
+ const char *name, float valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Double(hestOpt **hoptP, const char *flag,
+ const char *name, double valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Char(hestOpt **hoptP, const char *flag,
+ const char *name, char valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_String(hestOpt **hoptP, const char *flag,
+ const char *name, char *valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[2],
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_2_Other(hestOpt **hoptP, const char *flag,
+ const char *name, void *valueP,
+ const char *dflt, const char *info,
+ const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_3_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Int(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, size_t valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Float(hestOpt **hoptP, const char *flag,
+ const char *name, float valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Double(hestOpt **hoptP, const char *flag,
+ const char *name, double valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Char(hestOpt **hoptP, const char *flag,
+ const char *name, char valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_String(hestOpt **hoptP, const char *flag,
+ const char *name, char *valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[3],
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_3_Other(hestOpt **hoptP, const char *flag,
+ const char *name, void *valueP,
+ const char *dflt, const char *info,
+ const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_4_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Int(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, size_t valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Float(hestOpt **hoptP, const char *flag,
+ const char *name, float valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Double(hestOpt **hoptP, const char *flag,
+ const char *name, double valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Char(hestOpt **hoptP, const char *flag,
+ const char *name, char valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_String(hestOpt **hoptP, const char *flag,
+ const char *name, char *valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[4],
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_4_Other(hestOpt **hoptP, const char *flag,
+ const char *name, void *valueP,
+ const char *dflt, const char *info,
+ const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_N_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N, int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Int(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N, int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ unsigned int *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ long int *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ unsigned long int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ size_t *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Float(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ float *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Double(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ double *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Char(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ char *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_String(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ char **valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N, int *valueP,
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_N_Other(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ void *valueP, const char *dflt,
+ const char *info, const hestCB *CB);
#ifdef __cplusplus
}
Modified: teem/trunk/src/hest/parseHest.c
===================================================================
--- teem/trunk/src/hest/parseHest.c 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/parseHest.c 2023-07-11 05:55:51 UTC (rev 7068)
@@ -288,9 +288,9 @@
if (opt[op].CB->destroy && (sizeof(void *) != opt[op].CB->size)) {
if (err)
sprintf(err,
- "%s!!!!!! opt[%d] has a \"destroy\", but size isn't "
+ "%s!!!!!! opt[%d] has a \"destroy\", but size %lu isn't "
"sizeof(void*)",
- ME, op);
+ ME, op, (unsigned long)(opt[op].CB->size));
else
fprintf(stderr, "%s: panic 8\n", me);
return 1;
@@ -1000,7 +1000,7 @@
easy way to see (or print, for an error message) the parameter (or
concatenation of parameters) that was passed for a given option?
and it turns out that adding this was as simple as adding this one following
- line. The inscrutability of the hest code (or more acutely the self-reinforcing
+ line. The inscrutability of the hest code (or really the self-reinforcing
learned fear of working with the hest code) seems to have been the barrier. */
opt[op].parmStr = airStrdup(prms[op]);
type = opt[op].type;
Modified: teem/trunk/src/hest/test/ex6.c
===================================================================
--- teem/trunk/src/hest/test/ex6.c 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/test/ex6.c 2023-07-11 05:55:51 UTC (rev 7068)
@@ -21,8 +21,8 @@
#include "../hest.h"
-int
-parse(void *_ptr, const char *str, char *err) {
+static int
+pos_parse(void *_ptr, const char *str, char *err) {
double *ptr;
int ret;
@@ -35,8 +35,42 @@
return 0;
}
-hestCB posCB = {2 * sizeof(double), "location", parse, NULL};
+hestCB posCB = {2 * sizeof(double), "position", pos_parse, NULL};
+typedef struct {
+ char *str;
+ double val;
+} Quat;
+
+static int
+quat_parse(void *_ptr, const char *str, char *err) {
+ Quat **ptrP;
+ Quat *ptr;
+
+ ptrP = _ptr;
+ ptr = (*ptrP) = AIR_MALLOC(1, Quat);
+ /* printf("%s: ptrP = %p ---malloc--> ptr = *ptrP = %p\n", __func__, ptrP, *ptrP); */
+ ptr->str = NULL;
+ if (1 != sscanf(str, "%lf", &(ptr->val))) {
+ sprintf(err, "didn't parse a double from %s", str);
+ return 1;
+ }
+ ptr->str = airStrdup(str);
+ return 0;
+}
+
+Quat *
+quat_free(void *_ptr) {
+ Quat *ptr = _ptr;
+ if (ptr) {
+ free(ptr->str);
+ free(ptr);
+ }
+ return NULL;
+}
+
+hestCB quatCB = {sizeof(Quat *), "quatty", quat_parse, (airMopper)quat_free};
+
int
main(int argc, const char **argv) {
hestOpt *opt = NULL;
@@ -50,6 +84,8 @@
parm = hestParmNew();
parm->respFileEnable = AIR_TRUE;
parm->respectDashDashHelp = AIR_TRUE;
+ parm->noArgsIsNoProblem = AIR_TRUE;
+ parm->dieLessVerbose = AIR_TRUE;
parm->verbosity = 0;
opt = NULL;
@@ -57,67 +93,206 @@
int flag;
hestOptAdd_Flag(&opt, "f,flag", &flag, "a flag created via hestOptAdd_Flag");
int b1;
- hestOptAdd_1_Bool(&opt, "b1", "bool1", &b1, AIR_FALSE, "test of hestOptAdd_1_Bool");
+ hestOptAdd_1_Bool(&opt, "b1", "bool1", &b1, "false", "test of hestOptAdd_1_Bool");
int i1;
- hestOptAdd_1_Int(&opt, "i1", "int1", &i1, 42, "test of hestOptAdd_1_Int");
+ hestOptAdd_1_Int(&opt, "i1", "int1", &i1, "42", "test of hestOptAdd_1_Int");
unsigned int ui1;
- hestOptAdd_1_UInt(&opt, "ui1", "uint1", &ui1, 42, "test of hestOptAdd_1_UInt");
+ hestOptAdd_1_UInt(&opt, "ui1", "uint1", &ui1, "42", "test of hestOptAdd_1_UInt");
long int li1;
- hestOptAdd_1_LongInt(&opt, "li1", "lint1", &li1, 42, "test of hestOptAdd_1_LongInt");
+ hestOptAdd_1_LongInt(&opt, "li1", "lint1", &li1, "42", "test of hestOptAdd_1_LongInt");
unsigned long int uli1;
- hestOptAdd_1_ULongInt(&opt, "uli1", "ulint1", &uli1, 42,
+ hestOptAdd_1_ULongInt(&opt, "uli1", "ulint1", &uli1, "42",
"test of hestOptAdd_1_ULongInt");
size_t sz1;
- hestOptAdd_1_Size_t(&opt, "sz1", "size1", &sz1, 42, "test of hestOptAdd_1_Size_t");
+ hestOptAdd_1_Size_t(&opt, "sz1", "size1", &sz1, "42", "test of hestOptAdd_1_Size_t");
float fl1;
- hestOptAdd_1_Float(&opt, "fl1", "float1", &fl1, 4.2f, "test of hestOptAdd_1_Float");
+ hestOptAdd_1_Float(&opt, "fl1", "float1", &fl1, "4.2", "test of hestOptAdd_1_Float");
double db1;
- hestOptAdd_1_Double(&opt, "db1", "double1", &db1, 4.2, "test of hestOptAdd_1_Double");
+ hestOptAdd_1_Double(&opt, "db1", "double1", &db1, "4.2",
+ "test of hestOptAdd_1_Double");
char c1;
- hestOptAdd_1_Char(&opt, "c1", "char1", &c1, 'x', "test of hestOptAdd_1_Char");
+ hestOptAdd_1_Char(&opt, "c1", "char1", &c1, "x", "test of hestOptAdd_1_Char");
char *s1;
hestOptAdd_1_String(&opt, "s1", "string1", &s1, "bingo bob",
"test of hestOptAdd_1_String");
int e1;
- hestOptAdd_1_Enum(&opt, "e1", "enum1", &e1, airEndianLittle,
- "test of hestOptAdd_1_Enum", airEndian);
+ hestOptAdd_1_Enum(&opt, "e1", "enum1", &e1, "little", "test of hestOptAdd_1_Enum",
+ airEndian);
double p1[2];
- hestOptAdd_1_Other(&opt, "p1", "pos", &p1, "1.5,5.25", "test of hestOptAdd_1_Other",
+ hestOptAdd_1_Other(&opt, "p1", "pos", &p1, "1.5,5.25", "test of hestOptAdd_1_Other A",
&posCB);
+ Quat *q1;
+ hestOptAdd_1_Other(&opt, "q1", "quat", &q1, "12.34", "test of hestOptAdd_1_Other B",
+ &quatCB);
+ printf("----- &q1 = %p\n", &q1);
- if (1 == argc) {
- /* didn't get anything at all on command line */
- /* print program information ... */
- hestInfo(stderr, argv[0], info, parm);
- /* ... and usage information ... */
- hestUsage(stderr, opt, argv[0], parm);
- hestGlossary(stderr, opt, parm);
- /* ... and avoid memory leaks */
- opt = hestOptFree(opt);
- parm = hestParmFree(parm);
- exit(1);
- }
+ int b2[2];
+ hestOptAdd_2_Bool(&opt, "b2", "bool1 bool2", b2, "true false",
+ "test of hestOptAdd_2_Bool");
+ int i2[2];
+ hestOptAdd_2_Int(&opt, "i2", "int1 int2", i2, "42 24", "test of hestOptAdd_2_Int");
+ unsigned int ui2[2];
+ hestOptAdd_2_UInt(&opt, "ui2", "uint1 uint2", ui2, "42 24",
+ "test of hestOptAdd_2_UInt");
+ long int li2[2];
+ hestOptAdd_2_LongInt(&opt, "li2", "lint1 lint2", li2, "42 24",
+ "test of hestOptAdd_2_LongInt");
+ unsigned long int uli2[2];
+ hestOptAdd_2_ULongInt(&opt, "uli2", "ulint1 ulint2", uli2, "42 24",
+ "test of hestOptAdd_2_ULongInt");
+ size_t sz2[2];
+ hestOptAdd_2_Size_t(&opt, "sz2", "size1 size2", sz2, "42 24",
+ "test of hestOptAdd_2_Size_t");
+ float fl2[2];
+ hestOptAdd_2_Float(&opt, "fl2", "float1 float2", fl2, "4.2 2.4",
+ "test of hestOptAdd_2_Float");
+ double db2[2];
+ hestOptAdd_2_Double(&opt, "db2", "double1 double2", db2, "4.2 2.4",
+ "test of hestOptAdd_2_Double");
+ char c2[2];
+ hestOptAdd_2_Char(&opt, "c2", "char1 char2", c2, "x y", "test of hestOptAdd_2_Char");
+ char *s2[2];
+ hestOptAdd_2_String(&opt, "s2", "str1 str2", s2, "bingo bob",
+ "test of hestOptAdd_2_String");
+ int e2[2];
+ hestOptAdd_2_Enum(&opt, "e2", "enum1 enum2", e2, "little big",
+ "test of hestOptAdd_2_Enum", airEndian);
+ double p2[2][2];
+ hestOptAdd_2_Other(&opt, "p2", "pos1 pos2", p2, "1.5,5.25 2.9,9.2",
+ "test of hestOptAdd_2_Other A", &posCB);
+ Quat *q2[2];
+ hestOptAdd_2_Other(&opt, "q2", "quat1 quat2", q2, "12.34 43.21",
+ "test of hestOptAdd_2_Other B", &quatCB);
- /* else we got something, see if we can parse it */
- if (hestParse(opt, argc - 1, argv + 1, &err, parm)) {
- fprintf(stderr, "ERROR: %s\n", err);
- free(err);
- /* print usage information ... */
- hestUsage(stderr, opt, argv[0], parm);
- hestGlossary(stderr, opt, parm);
- /* ... and then avoid memory leaks */
- opt = hestOptFree(opt);
- parm = hestParmFree(parm);
- exit(1);
- } else if (opt->helpWanted) {
- hestUsage(stdout, opt, argv[0], parm);
- hestGlossary(stdout, opt, parm);
- opt = hestOptFree(opt);
- parm = hestParmFree(parm);
- exit(1);
- }
+ int b3[3];
+ hestOptAdd_3_Bool(&opt, "b3", "bool1 bool2 bool3", b3, "true false true",
+ "test of hestOptAdd_3_Bool");
+ int i3[3];
+ hestOptAdd_3_Int(&opt, "i3", "int1 int2 int3", i3, "43 3 34",
+ "test of hestOptAdd_3_Int");
+ unsigned int ui3[3];
+ hestOptAdd_3_UInt(&opt, "ui3", "uint1 uint2 uint3", ui3, "43 3 34",
+ "test of hestOptAdd_3_UInt");
+ long int li3[3];
+ hestOptAdd_3_LongInt(&opt, "li3", "lint1 lint2 lint3", li3, "43 4 34",
+ "test of hestOptAdd_3_LongInt");
+ unsigned long int uli3[3];
+ hestOptAdd_3_ULongInt(&opt, "uli3", "ulint1 ulint2 ulint3", uli3, "43 5 34",
+ "test of hestOptAdd_3_ULongInt");
+ size_t sz3[3];
+ hestOptAdd_3_Size_t(&opt, "sz3", "size1 size2 size3", sz3, "43 6 34",
+ "test of hestOptAdd_3_Size_t");
+ float fl3[3];
+ hestOptAdd_3_Float(&opt, "fl3", "float1 float2 float3", fl3, "4.3 1.1 3.4",
+ "test of hestOptAdd_3_Float");
+ double db3[3];
+ hestOptAdd_3_Double(&opt, "db3", "double1 double2 double3", db3, "4.3 2.2 3.4",
+ "test of hestOptAdd_3_Double");
+ char c3[3];
+ hestOptAdd_3_Char(&opt, "c3", "char1 char2 char3", c3, "x y z",
+ "test of hestOptAdd_3_Char");
+ char *s3[3];
+ hestOptAdd_3_String(&opt, "s3", "str1 str2 str3", s3, "bingo bob susan",
+ "test of hestOptAdd_3_String");
+ int e3[3];
+ hestOptAdd_3_Enum(&opt, "e3", "enum1 enum2 enum3", e3, "little big little",
+ "test of hestOptAdd_3_Enum", airEndian);
+ double p3[3][2];
+ hestOptAdd_3_Other(&opt, "p3", "pos1 pos2 pos3", p3, "1.5,5.35 3.9,9.3 6.7,7.6",
+ "test of hestOptAdd_3_Other A", &posCB);
+ Quat *q3[3];
+ hestOptAdd_3_Other(&opt, "q3", "quat1 quat2 quat3", q3, "13.34 43.31 66.77",
+ "test of hestOptAdd_3_Other B", &quatCB);
- {
+ int b4[4];
+ hestOptAdd_4_Bool(&opt, "b4", "bool1 bool2 bool3 bool4", b4, "true false no true",
+ "test of hestOptAdd_4_Bool");
+ int i4[4];
+ hestOptAdd_4_Int(&opt, "i4", "int1 int2 int3 int4", i4, "44 4 33 44",
+ "test of hestOptAdd_4_Int");
+ unsigned int ui4[4];
+ hestOptAdd_4_UInt(&opt, "ui4", "uint1 uint2 uint3 uint4", ui4, "44 4 33 44",
+ "test of hestOptAdd_4_UInt");
+ long int li4[4];
+ hestOptAdd_4_LongInt(&opt, "li4", "lint1 lint2 lint3 lint4", li4, "44 4 33 44",
+ "test of hestOptAdd_4_LongInt");
+ unsigned long int uli4[4];
+ hestOptAdd_4_ULongInt(&opt, "uli4", "ulint1 ulint2 ulint3 ulint4", uli4, "44 5 33 44",
+ "test of hestOptAdd_4_ULongInt");
+ size_t sz4[4];
+ hestOptAdd_4_Size_t(&opt, "sz4", "size1 size2 size3 size4", sz4, "44 6 33 44",
+ "test of hestOptAdd_4_Size_t");
+ float fl4[4];
+ hestOptAdd_4_Float(&opt, "fl4", "float1 float2 float3 float4", fl4, "4.4 1.1 3.3 4.4",
+ "test of hestOptAdd_4_Float");
+ double db4[4];
+ hestOptAdd_4_Double(&opt, "db4", "double1 double2 double3 double4", db4,
+ "4.4 2.2 3.3 4.4", "test of hestOptAdd_4_Double");
+ char c4[4];
+ hestOptAdd_4_Char(&opt, "c4", "char1 char2 char3 char4", c4, "x y z w",
+ "test of hestOptAdd_4_Char");
+ char *s4[4];
+ hestOptAdd_4_String(&opt, "s4", "str1 str2 str3 str4", s4, "bingo bob frank susan",
+ "test of hestOptAdd_4_String");
+ int e4[4];
+ hestOptAdd_4_Enum(&opt, "e4", "enum1 enum2 enum3 enum4", e4, "little big big little",
+ "test of hestOptAdd_4_Enum", airEndian);
+ double p4[4][2];
+ hestOptAdd_4_Other(&opt, "p4", "pos1 pos2 pos3 pos4", p4,
+ "1.5,5.45 4.9,9.4 6.7,7.6 63.4,97,3",
+ "test of hestOptAdd_4_Other A", &posCB);
+ Quat *q4[4];
+ hestOptAdd_4_Other(&opt, "q4", "quat1 quat2 quat3 quat4", q4,
+ "14.44 44.41 66.77 88.99", "test of hestOptAdd_4_Other B",
+ &quatCB);
+
+ int b5[5];
+ hestOptAdd_N_Bool(&opt, "b5", "bool1 bool2 bool3 bool4 bool5", 5, b5,
+ "true false no yes true", "test of hestOptAdd_N_Bool");
+ int i5[5];
+ hestOptAdd_N_Int(&opt, "i5", "int1 int2 int3 int4 int5", 5, i5, "55 5 33 500 55",
+ "test of hestOptAdd_N_Int");
+ unsigned int ui5[5];
+ hestOptAdd_N_UInt(&opt, "ui5", "uint1 uint2 uint3 uint4 uint5", 5, ui5,
+ "55 5 33 500 55", "test of hestOptAdd_N_UInt");
+ long int li5[5];
+ hestOptAdd_N_LongInt(&opt, "li5", "lint1 lint2 lint3 lint4 lint5", 5, li5,
+ "55 5 33 500 55", "test of hestOptAdd_N_LongInt");
+ unsigned long int uli5[5];
+ hestOptAdd_N_ULongInt(&opt, "uli5", "ulint1 ulint2 ulint3 ulint4 ulint5", 5, uli5,
+ "55 5 33 500 55", "test of hestOptAdd_N_ULongInt");
+ size_t sz5[5];
+ hestOptAdd_N_Size_t(&opt, "sz5", "size1 size2 size3 size5", 5, sz5, "55 6 33 500 55",
+ "test of hestOptAdd_N_Size_t");
+ float fl5[5];
+ hestOptAdd_N_Float(&opt, "fl5", "float1 float2 float3 float4 float5", 5, fl5,
+ "5.5 1.1 3.3 500 5.5", "test of hestOptAdd_N_Float");
+ double db5[5];
+ hestOptAdd_N_Double(&opt, "db5", "double1 double2 double3 double4 double5", 5, db5,
+ "5.5 2.2 3.3 4.4 5.5", "test of hestOptAdd_N_Double");
+ char c5[5];
+ hestOptAdd_N_Char(&opt, "c5", "char1 char2 char3 char4 char5", 5, c5, "x y z w v",
+ "test of hestOptAdd_N_Char");
+ char *s5[5];
+ hestOptAdd_N_String(&opt, "s5", "str1 str2 str3 str4, str5", 5, s5,
+ "bingo bob frank harry susan", "test of hestOptAdd_N_String");
+ int e5[5];
+ hestOptAdd_N_Enum(&opt, "e5", "enum1 enum2 enum3 enum4 enum5", 5, e5,
+ "little big little big little", "test of hestOptAdd_N_Enum",
+ airEndian);
+ double p5[5][2];
+ hestOptAdd_N_Other(&opt, "p5", "pos1 pos2 pos3 pos4 pos5", 5, p5,
+ "1.5,5.55 5.9,9.5 6.7,7.6 63.5,97,3 300,400",
+ "test of hestOptAdd_N_Other A", &posCB);
+ Quat *q5[5];
+ hestOptAdd_N_Other(&opt, "q5", "quat1 quat2 quat3 quat4 quat5", 5, q5,
+ "15.55 55.51 66.77 88.99 100.2", "test of hestOptAdd_N_Other B",
+ &quatCB);
+
+ hestParseOrDie(opt, argc - 1, argv + 1, parm, argv[0], info, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
+
+ if (1) {
unsigned int opi, numO;
numO = hestOptNum(opt);
for (opi = 0; opi < numO; opi++) {
@@ -130,21 +305,100 @@
printf(" parmStr=|%s|\n", opt[opi].parmStr ? opt[opi].parmStr : "(null)");
}
}
- printf("(err = %s)\n", err ? err : "(null)");
- printf("flag = %d\n", flag);
- printf("b1 = %d\n", b1);
- printf("i1 = %d\n", i1);
- printf("ui1 = %u\n", ui1);
- printf("li1 = %ld\n", li1);
- printf("uli1 = %lu\n", uli1);
- printf("sz1 = %zu\n", sz1);
- printf("fl1 = %g\n", fl1);
- printf("db1 = %g\n", db1);
- printf("c1 = %c\n", c1);
- printf("s1 = %s\n", s1);
- printf("e1 = %d\n", e1);
- printf("p1 = %g,%g\n", p1[0], p1[1]);
+ if (1) {
+ printf("(err = %s)\n", err ? err : "(null)");
+ printf("flag = %d\n", flag);
+ printf("b1 = %d\n", b1);
+ printf("i1 = %d\n", i1);
+ printf("ui1 = %u\n", ui1);
+ printf("li1 = %ld\n", li1);
+ printf("uli1 = %lu\n", uli1);
+ printf("sz1 = %zu\n", sz1);
+ printf("fl1 = %g\n", fl1);
+ printf("db1 = %g\n", db1);
+ printf("c1 = %c\n", c1);
+ printf("s1 = |%s|\n", s1);
+ printf("e1 = %d\n", e1);
+ printf("p1 = %g,%g\n", p1[0], p1[1]);
+ }
+ printf("q1 (@ %p) = %g(%s)\n", q1, q1->val, q1->str);
+ printf("\n");
+
+ if (1) {
+ printf("b2 = %d %d\n", b2[0], b2[1]);
+ printf("i2 = %d %d\n", i2[0], i2[1]);
+ printf("ui2 = %u %u\n", ui2[0], ui2[1]);
+ printf("li2 = %ld %ld\n", li2[0], li2[1]);
+ printf("uli2 = %lu %lu\n", uli2[0], uli2[1]);
+ printf("sz2 = %zu %zu\n", sz2[0], sz2[1]);
+ printf("fl2 = %g %g\n", fl2[0], fl2[1]);
+ printf("db2 = %g %g\n", db2[0], db2[1]);
+ printf("c2 = %c %c\n", c2[0], c2[1]);
+ printf("s2 = |%s| |%s|\n", s2[0], s2[1]);
+ printf("e2 = %d %d\n", e2[0], e2[1]);
+ printf("p2 = %g,%g %g,%g\n", p2[0][0], p2[0][1], p2[1][0], p2[1][1]);
+ }
+ printf(" (q2 = %p : [%p %p])\n", q2, q2[0], q2[1]);
+ printf("q2 = %g(%s) %g(%s)\n", q2[0]->val, q2[0]->str, q2[1]->val, q2[1]->str);
+
+ printf("b3 = %d %d %d\n", b3[0], b3[1], b3[2]);
+ printf("i3 = %d %d %d\n", i3[0], i3[1], i3[2]);
+ printf("ui3 = %u %u %u\n", ui3[0], ui3[1], ui3[2]);
+ printf("li3 = %ld %ld %ld\n", li3[0], li3[1], li3[2]);
+ printf("uli3 = %lu %lu %lu\n", uli3[0], uli3[1], uli3[2]);
+ printf("sz3 = %zu %zu %zu\n", sz3[0], sz3[1], sz3[2]);
+ printf("fl3 = %g %g %g\n", fl3[0], fl3[1], fl3[2]);
+ printf("db3 = %g %g %g\n", db3[0], db3[1], db3[2]);
+ printf("c3 = %c %c %c\n", c3[0], c3[1], c3[2]);
+ printf("s3 = |%s| |%s| |%s|\n", s3[0], s3[1], s3[2]);
+ printf("e3 = %d %d %d\n", e3[0], e3[1], e3[2]);
+ printf("p3 = %g,%g %g,%g %g,%g\n", p3[0][0], p3[0][1], p3[1][0], p3[1][1], p3[2][0],
+ p3[2][1]);
+ printf("q3 = %g(%s) %g(%s) %g(%s)\n", q3[0]->val, q3[0]->str, q3[1]->val, q3[1]->str,
+ q3[2]->val, q3[2]->str);
+
+ printf("b4 = %d %d %d %d\n", b4[0], b4[1], b4[2], b4[3]);
+ printf("i4 = %d %d %d %d\n", i4[0], i4[1], i4[2], i4[3]);
+ printf("ui4 = %u %u %u %u\n", ui4[0], ui4[1], ui4[2], ui4[3]);
+ printf("li4 = %ld %ld %ld %ld\n", li4[0], li4[1], li4[2], li4[3]);
+ printf("uli4 = %lu %lu %lu %lu\n", uli4[0], uli4[1], uli4[2], uli4[3]);
+ printf("sz4 = %zu %zu %zu %zu\n", sz4[0], sz4[1], sz4[2], sz4[3]);
+ printf("fl4 = %g %g %g %g\n", fl4[0], fl4[1], fl4[2], fl4[3]);
+ printf("db4 = %g %g %g %g\n", db4[0], db4[1], db4[2], db4[3]);
+ printf("c4 = %c %c %c %c\n", c4[0], c4[1], c4[2], c4[3]);
+ printf("s4 = |%s| |%s| |%s| |%s|\n", s4[0], s4[1], s4[2], s4[3]);
+ printf("e4 = %d %d %d %d\n", e4[0], e4[1], e4[2], e4[3]);
+ printf("p4 = %g,%g %g,%g %g,%g %g,%g\n", p4[0][0], p4[0][1], p4[1][0], p4[1][1],
+ p4[2][0], p4[2][1], p4[3][0], p4[3][1]);
+ printf("q4 = %g(%s) %g(%s) %g(%s) %g(%s)\n", q4[0]->val, q4[0]->str, q4[1]->val,
+ q4[1]->str, q4[2]->val, q4[2]->str, q...
[truncated message content] |