From 8a24425a16d657fae29f9744c97a8d6e1da324e6 Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Thu, 29 Sep 2016 22:13:59 +1000 Subject: [PATCH] Gmt module: generate parameter name from template. --- modules/gmt/modgmt_param.h | 6 ++---- modules/gmt/modgmt_strcomp.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/gmt/modgmt_param.h b/modules/gmt/modgmt_param.h index 7907f97..0efc02d 100644 --- a/modules/gmt/modgmt_param.h +++ b/modules/gmt/modgmt_param.h @@ -75,14 +75,12 @@ class Parameter // Class for parameter which must be in named pair template -class NamedParameter: public Parameter, public TemplateComparator +class NamedParameter: public TemplateComparator, public Parameter { public: using AcceptableObject=void; template - NamedParameter(const std::string& t, Args... args):Parameter(t,args...),TemplateComparator(t) {} - template - NamedParameter(std::pair&& t, Args... args):Parameter(std::move(t.first),args...),TemplateComparator(std::move(t.second)) {} + NamedParameter(const std::string& t, Args... args):TemplateComparator(t),Parameter(Template2Name(),args...) {} }; diff --git a/modules/gmt/modgmt_strcomp.h b/modules/gmt/modgmt_strcomp.h index 37eb36a..d075bd1 100644 --- a/modules/gmt/modgmt_strcomp.h +++ b/modules/gmt/modgmt_strcomp.h @@ -65,6 +65,34 @@ class TemplateComparator for(size_t pos=0; postype) + { + case(Block::TEXT): {res+=s.substr(b->b,b->e-b->b); break;} + case(Block::OPTIONAL): {b=b->child.get(); goto next;} + case(Block::VARIANTS): {b=b->child.get(); goto next;} + case(Block::DELIM): {b=b->parent; break;} + default: {} + } + // Go to next block + while(true) + { + if(nullptr!=b->next) {b=b->next.get(); goto next;} + if(nullptr!=b->parent) b=b->parent; + else break; + } + if(nullptr==b->next && nullptr==b->parent) break; + next: ; + } + return res; + } }; #endif