gtsam/wrap/Template.h

70 lines
1.8 KiB
C
Raw Normal View History

2014-12-01 19:43:12 +08:00
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file Template.h
* @brief Template name
* @author Frank Dellaert
* @date Nov 11, 2014
**/
#pragma once
#include <wrap/Qualified.h>
namespace wrap {
/// The template specification that goes before a method or a class
struct Template {
std::string argName;
std::vector<Qualified> argValues;
void clear() {
argName.clear();
argValues.clear();
}
};
/* ************************************************************************* */
// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html
struct TemplateGrammar: public classic::grammar<TemplateGrammar> {
Template& result_; ///< successful parse will be placed in here
2014-12-02 03:03:26 +08:00
TypeListGrammar<'{', '}'> argValues_g; ///< TypeList parser
2014-12-01 19:43:12 +08:00
/// Construct type grammar and specify where result is placed
TemplateGrammar(Template& result) :
result_(result), argValues_g(result.argValues) {
}
/// Definition of type grammar
template<typename ScannerT>
2014-12-02 03:03:26 +08:00
struct definition: BasicRules<ScannerT> {
2014-12-01 19:43:12 +08:00
2014-12-02 03:03:26 +08:00
classic::rule<ScannerT> templateArgValues_p;
2014-12-01 19:43:12 +08:00
definition(TemplateGrammar const& self) {
using namespace classic;
templateArgValues_p = (str_p("template") >> '<'
2014-12-02 03:03:26 +08:00
>> (BasicRules<ScannerT>::name_p)[assign_a(self.result_.argName)]
2014-12-01 19:43:12 +08:00
>> '=' >> self.argValues_g >> '>');
}
2014-12-02 03:03:26 +08:00
classic::rule<ScannerT> const& start() const {
2014-12-01 19:43:12 +08:00
return templateArgValues_p;
}
};
};
// TemplateGrammar
}// \namespace wrap