Documentation of CSL
libcallable_data.h
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY 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
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
16  #pragma once
17 
18 #include <iostream>
19 
20 namespace csl {
21  inline void printCallableStructure(
22  std::ostream &out
23  )
24  {
25  out << "template<class ReturnType, class ParamType>\n";
26  out << "struct Callable {\n";
27  out << "\n";
28  out << " Callable(\n";
29  out << " std::string_view t_name,\n";
30  out << " ReturnType (*t_f)(ParamType const&)\n";
31  out << " )\n";
32  out << " :name(t_name),\n";
33  out << " f(t_f)\n";
34  out << " {}\n";
35  out << " Callable(\n";
36  out << " std::string_view t_name,\n";
37  out << " std::function<ReturnType(ParamType const&)> const &t_f\n";
38  out << " )\n";
39  out << " :name(t_name),\n";
40  out << " f(t_f)\n";
41  out << " {}\n";
42  out << "\n";
43  out << " inline\n";
44  out << " ReturnType operator()(ParamType const &params) const {\n";
45  out << " return f(params);\n";
46  out << " }\n";
47  out << "\n";
48  out << " std::string name;\n";
49  out << " std::function<ReturnType(ParamType)> f;\n";
50  out << "};\n";
51  }
52 }
Namespace for csl library.
Definition: abreviation.h:34