2222#include < tuple>
2323#include " qconfig.h"
2424#include " qconfig_helpers.h"
25+ #include " qconfig_internal_helpers.h"
2526
2627// Create config instances
2728#define QCONFIG_PARSER_CXX
2829#define QCONFIG_INSTANCE
29- #include " qconfig .h"
30+ #include " qconfig_internal .h"
3031#undef QCONFIG_INSTANCE
3132
3233namespace qConfig
3334{
34- #define QCONFIG_SETTING (name, type ) \
35- struct qon_mxcat3 (q, name, _t) { \
36- type v; \
37- constexpr qon_mxcat3 (q, name, _t)(type s) : v (s) {} \
38- }; \
39- constexpr qon_mxcat3 (q, name, _t) name(type v) { return (qon_mxcat3 (q, name, _t)(v)); }
40-
41- #define QCONFIG_SETTING_TEMPLATE (name ) \
42- template <typename T> \
43- struct qon_mxcat3 (q, name, _t) { \
44- T v; \
45- constexpr qon_mxcat3 (q, name, _t)(const T& s) : v (s) {} \
46- }; \
47- template <typename T> \
48- constexpr qon_mxcat3 (q, name, _t)<T> name(T v) \
49- { \
50- return (qon_mxcat3 (q, name, _t) < T > (v)); \
51- }
52-
53- QCONFIG_SETTING (message, const char *)
54- QCONFIG_SETTING_TEMPLATE (min)
55- QCONFIG_SETTING_TEMPLATE (max)
56- QCONFIG_SETTING_TEMPLATE (set)
57- QCONFIG_SETTING_TEMPLATE (def)
5835
5936static inline const char * getOptName (const char ** argv, int32_t i)
6037{
@@ -477,22 +454,22 @@ static inline void qConfigHelp(const char* subConfig = nullptr, int32_t followSu
477454 printf (" Usage Info:" );
478455 }
479456#define QCONFIG_HELP
480- #include " qconfig .h"
457+ #include " qconfig_internal .h"
481458#undef QCONFIG_HELP
482459 if (followSub < 2 ) {
483460 printf (" \n " );
484461 }
485462}
486463
487464// Create parser for configuration
488- static inline int32_t qConfigParse (int argc, const char ** argv, const char * /* filename*/ )
465+ int32_t qConfigParse (int argc, const char ** argv, const char * /* filename*/ )
489466{
490467 for (int32_t i = 1 ; i < argc; i++) {
491468 const char * thisoption = argv[i];
492469 repeat:
493470 bool found = false ;
494471#define QCONFIG_PARSE
495- #include " qconfig .h"
472+ #include " qconfig_internal .h"
496473#undef QCONFIG_PARSE
497474 if (found == false ) {
498475 printf (" Invalid argument: %s\n " , argv[i]);
@@ -505,16 +482,13 @@ static inline int32_t qConfigParse(int argc, const char** argv, const char* /*fi
505482
506483std::vector<std::function<void ()>> qprint_global;
507484#define QCONFIG_PRINT
508- #include " qconfig .h"
485+ #include " qconfig_internal .h"
509486#undef QCONFIG_PRINT
510- } // end namespace qConfig
511-
512- // Main parse function called from outside
513- int32_t qConfigParse (int argc, const char ** argv, const char * filename) { return (qConfig::qConfigParse (argc, argv, filename)); }
514487
515488void qConfigPrint ()
516489{
517- for (auto & f : qConfig:: qprint_global) {
490+ for (auto & f : qprint_global) {
518491 f ();
519492 }
520493}
494+ } // end namespace qConfig
0 commit comments