本文整理汇总了C++中qi::phrase_parse方法的典型用法代码示例。如果您正苦于以下问题:C++ qi::phrase_parse方法的具体用法?C++ qi::phrase_parse怎么用?C++ qi::phrase_parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qi
的用法示例。
在下文中一共展示了qi::phrase_parse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_int_number_main
int parse_int_number_main()
{
namespace qi = boost::spirit::qi;
using qi::parse;
using qi::phrase_parse;
using qi::int_;
using qi::double_;
using qi::ascii::space;
using qi::_1;
using boost::phoenix::ref;
using boost::phoenix::push_back;
char * a = "(12e2,12223)";
char * a_end = a+strlen(a) ;
char * b = "(1233)";
char * b_end = b+strlen(b);
char * c = "1 , 2,3,4,5,6,7,8,10,13";
char * c_end = b+strlen(b) ;
int n = 0;
std::vector<int> iv;
phrase_parse(c,c_end, int_%',', space, iv);
std::ostream_iterator <int> oi(std::cout, ",");
boost::copy(iv,oi);
std::cout<<"\n";
return 0;
}
示例2: parse_dasharray
bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharray)
{
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using qi::lit;
using qi::char_;
#if BOOST_VERSION > 104200
using qi::no_skip;
#else
using qi::lexeme;
#endif
using phoenix::push_back;
// SVG
// dasharray ::= (length | percentage) (comma-wsp dasharray)?
// no support for 'percentage' as viewport is unknown at load_map
//
bool r = phrase_parse(first, last,
(double_[push_back(phoenix::ref(dasharray), _1)] %
#if BOOST_VERSION > 104200
no_skip[char_(", ")]
#else
lexeme[char_(", ")]
#endif
| lit("none")),
qi::ascii::space);
if (first != last)
{
return false;
}
return r;
}
示例3: main
int main()
{
namespace spirit = boost::spirit;
namespace qi = spirit::qi;
namespace phoenix = boost::phoenix;
namespace ascii = spirit::ascii;
using qi::rule;
using qi::int_;
using qi::_1;
using qi::_val;
using qi::phrase_parse;
using boost::shared_ptr;
using boost::make_shared;
shared_ptr<int> x = make_shared<int>(123);
std::cout << *x << std::endl;
rule<
std::string::const_iterator
, shared_ptr<int>()
, ascii::space_type
> int_rule_ = int_[_val = new int(_1)];
shared_ptr<int> subject_;
std::string text_ = "12345";
auto result_ = phrase_parse(text_.cbegin(), text_.cend(), int_rule_, ascii::space, subject_);
std::cout << (result_ ? "passed" : "failed") << *subject_ << std::endl;
}
示例4: parse_numbers
bool parse_numbers( Iterator first, Iterator last, vector<double> &v )
{
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using ascii::space;
using phoenix::push_back;
bool r( phrase_parse( first, last,
(
double_[ push_back( phoenix::ref( v ), _1 ) ] % ','
),
space ) );
return ( first == last ? r : false );
}
示例5: parse_numbers
bool parse_numbers(Iterator first, Iterator last, std::vector<double>& v)
{
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using ascii::space;
bool r = phrase_parse(first, last,
// Begin grammar
(
double_ % ','
)
,
// End grammar
space, v);
if (first != last) // fail if we did not get a full match
return false;
return r;
}
示例6: parse_IC_line
optional< p_value_test_case >
parse_IC_line( Iterator first, Iterator last )
{
using qi::double_;
using qi::_1;
using qi::uint_;
using qi::phrase_parse;
using ascii::space;
using boost::phoenix::ref;
optional< p_value_test_case > result;
/// Will look like "N=2; IC=1.57184,1.57184,1.57184,1.22985,1.22985,1.57184,1.57184,1.22985"
size_t N;
if( phrase_parse( first, last, "N=" >> uint_ >> "; IC=", space, N ) ) {
result.reset( p_value_test_case( N ) );
if( ! phrase_parse( first, last, double_ % ",", space, result->ICs ) ) {
result = optional< p_value_test_case >(); // reset
}
}
return result;
}
示例7: parse_numbers
bool parse_numbers(Iterator first, Iterator last, std::vector<double>& v)
{
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using ascii::space;
using phoenix::push_back;
using phoenix::ref;
bool r = phrase_parse(first, last,
// Begin grammar
(
double_[push_back(ref(v), _1)] % ','
)
,
// End grammar
space);
if (first != last) // fail if we did not get a full match
return false;
return r;
}