31 #include "../Attribute.hpp"    33 #include "../TaskContext.hpp"    34 #include "../Service.hpp"    35 #include "../types/GlobalsRepository.hpp"    37 #include <boost/bind.hpp>    38 #include <boost/lexical_cast.hpp>    46     using namespace detail;
    49         : commonparser(cp), peerparser(tc,cp), propparser(cp)
    51     BOOST_SPIRIT_DEBUG_RULE( constant );
    52     BOOST_SPIRIT_DEBUG_RULE( const_float );
    53     BOOST_SPIRIT_DEBUG_RULE( const_double );
    54     BOOST_SPIRIT_DEBUG_RULE( const_int );
    55     BOOST_SPIRIT_DEBUG_RULE( const_hex );
    56     BOOST_SPIRIT_DEBUG_RULE( const_uint );
    57     BOOST_SPIRIT_DEBUG_RULE( const_llong );
    58     BOOST_SPIRIT_DEBUG_RULE( const_ullong );
    59     BOOST_SPIRIT_DEBUG_RULE( const_char );
    60     BOOST_SPIRIT_DEBUG_RULE( const_bool );
    61     BOOST_SPIRIT_DEBUG_RULE( const_string );
    62     BOOST_SPIRIT_DEBUG_RULE( named_constant );
    82         boost::bind( &ValueParser::seenfloatconstant, 
this, _1 ) ] >> ch_p(
'f');
    86         boost::bind( &ValueParser::seendoubleconstant, 
this, _1 ) ];
    88     const_hex = (str_p(
"0x") | str_p(
"0X")) >>
    90         boost::bind( &ValueParser::seenhexconstant, 
this, _1 ) ];
    93       uint_parser<unsigned long long>() [
    94         boost::bind( &ValueParser::seenullongconstant, 
this, _1 ) ] >> str_p(
"ull");
    97       uint_parser<long long>() [
    98         boost::bind( &ValueParser::seenllongconstant, 
this, _1 ) ] >> str_p(
"ll");
   101       uint_parser<unsigned int>() [
   102         boost::bind( &ValueParser::seenuintconstant, 
this, _1 ) ] >> ch_p(
'u');
   106         boost::bind( &ValueParser::seenintconstant, 
this, _1 ) ];
   110         boost::bind( &ValueParser::seenboolconstant, 
this, _1, _2 ) ];
   112     const_char = (ch_p(
'\'') >> ch_p(
'\\') >> ch_p(
'0') >> ch_p(
'\''))[boost::bind( &ValueParser::seennull,
this)] |
   113         confix_p( 
"'", (c_escape_ch_p[ boost::bind( &ValueParser::seencharconstant, 
this, _1 ) ]) , 
"'" );
   115     const_string = lexeme_d[confix_p(
   116       ch_p( 
'"' ), *c_escape_ch_p[ boost::bind( &ValueParser::push_str_char, 
this, _1 ) ], 
'"' )[ boost::bind( &ValueParser::seenstring, 
this ) ]];
   119         ( 
keyword_p(
"done")[boost::bind( &ValueParser::seennamedconstant, 
this, _1, _2 ) ]
   121           ( peerparser.
locator()[boost::bind( &ValueParser::seenpeer, 
this) ]
   123             >> commonparser.
identifier[boost::bind( &ValueParser::seennamedconstant, 
this, _1, _2 ) ]) )
   127     void ValueParser::seenpeer() {
   134   void ValueParser::seenboolconstant( 
iter_t begin, 
iter_t end )
   136     std::string value( begin, end );
   137     assert( value == 
"true" || value == 
"false" );
   138     if ( value == 
"true" )
   146   void ValueParser::seennamedconstant( 
iter_t begin, 
iter_t end )
   148     std::string name( begin, end );
   154     if ( task && propparser.
bag() && propparser.
property() ) {
   156         if ( ! propparser.
bag()->
find( name ) ) {
   166     if ( task && task->hasAttribute( name ) ) {
   167       ret = task->getValue(name)->getDataSource();
   170     if ( task && task->hasProperty( name ) ) {
   171         ret = task->properties()->find(name)->getDataSource();
   181     throw_(begin, 
"Value " + name + 
" not defined in "+ task->getName()+
".");
   184     void ValueParser::seennull()
   189     void ValueParser::seencharconstant( 
iter_t c )
   194     void ValueParser::seenhexconstant( 
unsigned int i )
   199   void ValueParser::seenintconstant( 
int i )
   204   void ValueParser::seenuintconstant( 
unsigned int i ) 
   209   void ValueParser::seenllongconstant( 
long long i )
   214   void ValueParser::seenullongconstant( 
unsigned long long i )
   219   void ValueParser::seenfloatconstant( 
double i )
   224   void ValueParser::seendoubleconstant( 
double i )
   244   void ValueParser::push_str_char( 
char c )
   249   void ValueParser::seenstring()
   254     mcurstring.erase( mcurstring.end() - 1 );
 #define keyword_p(word)
Returns a rule which parses a keyword followed by a non-identifier character, newline or semicolon...
void clear()
Clears this parser, not the repository where it stores its results. 
void reset()
After reset, peer() == current context and object() == "this". 
static shared_ptr Instance()
base::PropertyBase * property() const 
parse_exception class that is used for various semantic errors for which it was not worth defining a ...
This class contains some very common parser definitions. 
rule_t & locator()
The locator tries to go as far as possible in the peer-to-object path and will never throw...
void reset()
After reset, property() == 0 and bag == 0. 
boost::shared_ptr< Service > shared_ptr
base::PropertyBase * find(const std::string &name) const 
Find the base::PropertyBase with name name. 
ServicePtr taskObject()
Returns the last matching Service or zero if not found. 
void setPropertyBag(PropertyBag *pb)
Change the bag we want to traverse. 
PropertyBag * bag() const 
A DataSource which holds a constant value and returns it in its get() method. 
rule_t & locator()
The locator tries to go as far as possible in the bag-to-property path and will never throw...
The TaskContext is the C++ representation of an Orocos component. 
const std::string & getName() const 
Get the name of the property. 
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute. 
virtual DataSourceBase::shared_ptr getDataSource() const =0
Get an assignable base::DataSource through which this PropertyBase can be manipulated.