32 #ifndef _QORE_QOREGETOPT_H
34 #define _QORE_QOREGETOPT_H
37 #include <qore/safe_dslist>
42 #define QGO_ERR_DUP_SHORT_OPT -1
43 #define QGO_ERR_DUP_LONG_OPT -2
44 #define QGO_ERR_DUP_NAME -3
45 #define QGO_ERR_NO_NAME -4
46 #define QGO_ERR_NO_OPTION -5
48 #define QGO_OPT_NONE 0
49 #define QGO_OPT_ADDITIVE 1
50 #define QGO_OPT_LIST 2
51 #define QGO_OPT_MANDATORY 4
53 #define QGO_OPT_LIST_OR_ADD (QGO_OPT_ADDITIVE|QGO_OPT_LIST)
55 class QoreGetOptNode {
63 DLLLOCAL QoreGetOptNode(
const char* n,
char so,
const char* lo,
qore_type_t at = -1,
int o = QGO_OPT_NONE) :
64 name(n ? n :
""), short_opt(so), long_opt(lo ? lo :
""), argtype(at), option(o) {
67 DLLLOCAL ~QoreGetOptNode() {
71 typedef std::map<const char*, QoreGetOptNode*, ltstr> getopt_long_map_t;
72 typedef std::map<char, QoreGetOptNode*, ltchar> getopt_short_map_t;
73 typedef safe_dslist<QoreGetOptNode*> getopt_node_list_t;
77 getopt_long_map_t long_map;
78 getopt_short_map_t short_map;
79 getopt_node_list_t node_list;
81 DLLLOCAL
static DateTimeNode* parseDate(
const char* val);
84 DLLLOCAL QoreGetOptNode* find(
const char* opt)
const;
85 DLLLOCAL QoreGetOptNode* find(
char opt)
const;
86 DLLLOCAL
void doOption(QoreGetOptNode* n,
QoreHashNode* h,
const char* val);
90 DLLLOCAL QoreGetOpt() {
93 DLLLOCAL ~QoreGetOpt();
95 DLLLOCAL
int add(
const char* name,
char short_opt,
const char* long_opt,
qore_type_t argtype = -1,
int option = QGO_OPT_NONE);
Qore's parse tree/value type for date-time values, reference-counted, dynamically-allocated only.
Definition: DateTimeNode.h:45
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition: common.h:70