1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 class Py2yacsException: std::exception
29 Py2yacsException(const std::string& what);
30 virtual ~Py2yacsException()throw ();
31 virtual const char *what() const throw ();
44 struct FunctionProperties
48 std::list<std::string> _input_ports;
49 std::list<std::string> _output_ports;
50 std::list<std::string> _errors;
51 std::list<std::string> _imports;
54 /*! \brief Converter of a python script to a yacs schema.
55 * This class converts a string containing a python script to a yacs schema
56 * containing a python script node.
64 * This constructor can be used if you want to define your own python parser.
65 * The parser function should be a python function and return a tuple of
67 * The first list contains the properties of all the functions in the script
68 * and the second one contains global errors.
69 * \param python_parser_module: name of the parser module
70 * \param python_parser_function: name of the parser function
72 Py2yacs(const std::string& python_parser_module,
73 const std::string& python_parser_function);
76 * \param python_code: contains the python code that will be converted
79 void load(const std::string& python_code);
82 * \param file_path: path to the xml file where to save the yacs schema.
83 * \param python_function: function defined in the python code that will be
84 * called in the yacs node.
86 void save(const std::string& file_path,
87 const std::string& python_function)const;
90 * A new schema is created.
91 * \param python_function: function defined in the python code that will be
92 * called in the yacs node.
94 YACS::ENGINE::Proc* createProc(const std::string& python_function)const;
96 const std::list<std::string>& getGlobalErrors() const;
97 const std::list<FunctionProperties>& getFunctionProperties()const;
100 std::string _python_parser_module;
101 std::string _python_parser_function;
102 std::list<FunctionProperties> _functions;
103 std::list<std::string> _global_errors;
104 std::string _python_code;