ArgumentsParser.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon May 10 19:10:37 CEST 2004 ArgumentsParser.cxx
3 
4  ArgumentsParser.cxx - description
5  -------------------
6  begin : Mon May 10 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 #include "parser-debug.hpp"
39 #ifdef ORO_PRAGMA_INTERFACE
40 #pragma implementation
41 #endif
42 #include "ArgumentsParser.hpp"
43 
44 #include <boost/bind.hpp>
45 #include <boost/lexical_cast.hpp>
46 
47 #include "ExpressionParser.hpp"
48 #include "../TaskContext.hpp"
49 
50 
51 namespace RTT
52 {
53  using namespace detail;
54  using boost::bind;
55 
56  namespace {
57  boost::spirit::classic::assertion<std::string> expect_open("Open brace expected.");
58  boost::spirit::classic::assertion<std::string> expect_close("Closing brace expected ( or could not find out what this line means ).");
59  boost::spirit::classic::assertion<std::string> expect_arg("No argument given after comma.");
60  }
61 
63  ExpressionParser& p, TaskContext* peer, Service::shared_ptr tobject, const std::string& o,
64  const std::string& m )
65  : mparsed( false ), expressionparser( p ),
66  mobject( o ), mmethod( m ), _peer(peer), mtobject(tobject)
67  {
68  BOOST_SPIRIT_DEBUG_RULE( argument );
69  BOOST_SPIRIT_DEBUG_RULE( arguments );
70 
71  // a series of arguments; a command-separated list of arguments
72  // between parentheses..
73  arguments = (
74  ch_p('(')
75  >> !( argument >> *( ch_p( ',' ) >> expect_arg( argument ) ) )
76  >> expect_close(ch_p(')')) )[
77  bind( &ArgumentsParser::seenarguments, this ) ];
78 
79  // a single argument is just a normal expression..
80  argument =
82  bind( &ArgumentsParser::seen_arg, this ) ];
83  }
84 
86  {
87  margs.push_back( expressionparser.getResult() );
89  }
90 
92  {
93  mparsed = true;
94  }
95 
97  {
98  margs.clear();
99  }
100 }
std::vector< base::DataSourceBase::shared_ptr > margs
ArgumentsParser(ExpressionParser &p, TaskContext *peer, Service::shared_ptr tobject, const std::string &object, const std::string &method)
boost::shared_ptr< Service > shared_ptr
Definition: Service.hpp:101
base::DataSourceBase::shared_ptr getResult()
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:19