我有这个Telerik Rad按钮
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/support_utree.hpp>
#include <iostream>
namespace qi = boost::spirit::qi;
namespace bs = boost::spirit;
struct semantic_action
{
std::vector<int> tokens;
void add_tokens(int a)
{
tokens.push_back(a);
std::cout<< "Matched integer: " << a <<'\n';
}
};
template<typename Iterator>
struct my_grammar : public qi::grammar<Iterator,semantic_action(),bs::ascii::space_type>
{
my_grammar() : my_grammar::base_type(start,"MY")
{
start = qi::int_
[
boost::phoenix::bind(
&semantic_action::add_tokens,
&this->sem_act_,// referring member variable, but want to refer Attribute
qi::_1)
] % ',';
}
qi::rule<Iterator,semantic_action(),bs::ascii::space_type> start;
// referring member variable, but want to refer Attribute
semantic_action sem_act_; /** work around **/
};
template<typename Iterator>
bool parse(Iterator & begin,Iterator end,my_grammar<Iterator> const & grammar)
{
semantic_action a;
auto r = qi::phrase_parse(begin,end,grammar,bs::ascii::space,a);
for(auto const & item : grammar.sem_act_.tokens)
std::cout<<"::parse(): grammar.sem_act_.tokens -- "<<item<<'\n';
for(auto const & item : a.tokens)
std::cout<<"::parse(): a.tokens -- "<<item<<'\n';
return r;
}
int main()
{
std::string input = "12,13,24,34";
auto it = input.begin();
my_grammar<decltype(it)> g;
if(::parse(it,input.end(),g) )
{
std::cout<<"parse success\n";
}
else
{
std::cout<<"parse failed\n";
}
std::cout<<"Unparsed input => "<< std::string{it,input.end()}<<'\n';
}
我想自定义部分文字,我不知道它是否可行。 最终结果应该是&#34;概述&#34;和&#34; 112&#34;用一些颜色突出显示。
答案 0 :(得分:0)
我带来了这个解决方案。如果有更好的那个,请告诉我
<telerik:RadButton runat="server" Text="Overview 112" Width="110px" Skin="Default">
<ContentTemplate>
<span>Overview</span>
<span style="color:red;">112</span>
</ContentTemplate>