libt2n: (gerd) reformat codegen with new codestyle (preparation for new stuff)
[libt2n] / codegen / main.cpp
1 /*
2     Copyright (C) 2006-2008
3     intra2net.com
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20 #include <libxml++/libxml++.h>
21 #include <cassert>
22 #include <iostream>
23 #include <set>
24 #include <fstream>
25 #include <list>
26 #include <stdexcept>
27 #include <boost/lexical_cast.hpp>
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32
33 //! map group to class name
34 std::string groupClass(const std::string &group)
35 {
36     return std::string("cmd_group_")+group;
37 }
38
39 //! convert string to upper case
40 std::string toupper(std::string s)
41 {
42     for (unsigned i=0; i<s.length(); ++i) s[i]=toupper(s[i]);
43     return s;
44 }
45
46 //! replace all characters f by r in string s
47 std::string replace(std::string s, char f, char r)
48 {
49     for (unsigned i=0; i<s.length(); ++i) if (s[i]==f) s[i]=r;
50     return s;
51 }
52
53 //! strip prefix from string s
54 /*!
55   \return string s without prefix or an empty string on error
56  */
57 std::string strip(std::string s, std::string prefix)
58 {
59     std::string error;
60     if ( (prefix.length()>s.length() ) || ( std::string(s,0,prefix.length())!=prefix ) ) return error;
61     return std::string(s, prefix.length(), s.length()-prefix.length());
62 }
63
64 //! get child element by id
65 /*!
66   \return pointer to element having id or null on error
67   \todo find libxmlpp pendant
68 */
69 const xmlpp::Element* get_element_by_id(const xmlpp::Element* element, const std::string &id)
70 {
71     const xmlpp::Attribute* cid = element->get_attribute("id");
72     if ( cid && ( cid->get_value() == id)) return element;
73
74     //Recurse through child nodes:
75     xmlpp::Node::NodeList list = element->get_children();
76     for (xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
77     {
78         const xmlpp::Element* element = dynamic_cast<const xmlpp::Element*>(*iter);
79         if (element)
80         {
81             const xmlpp::Element* match = get_element_by_id(element, id);
82             if (match) return match;
83         }
84     }
85     return NULL;
86 }
87
88 std::string get_file(const xmlpp::Element* root, const std::string &file_id)
89 {
90     std::string error;
91     const xmlpp::Element* e=get_element_by_id(root, file_id);
92     if ((!e)||(!e->get_attribute("name"))) return error;
93     return e->get_attribute("name")->get_value();
94 }
95
96 //! get namespace by id
97 /*!
98   \return namespace name or empty string on error
99 */
100 std::string get_namespace(const xmlpp::Element* root, const std::string &id)
101 {
102     std::string error;
103     const xmlpp::Element* element(get_element_by_id(root, id));
104     // [RP:20071024]: use "demangled" attribute instead of "name" to cover nested namespaces:
105     if ((!element)||(!element->get_attribute("demangled"))) return error;
106     return element->get_attribute("demangled")->get_value();
107 }
108
109 //! procedure marked for export?
110 bool is_marked(const std::string &attrs)
111 {
112     // todo: improve this
113     std::string to_match("gccxml(libt2n-");
114     std::string::size_type p(attrs.find(to_match));
115     return (p!=std::string::npos);
116 }
117
118 struct type_info
119 {
120     std::string name;
121     std::string noref_name;
122     bool operator==(const type_info& o) {return (name==o.name) && (noref_name == o.noref_name);}
123     std::string noref() const {return noref_name.empty() ? name : noref_name;}
124     bool isVoid() const {return name=="void";}
125 };
126
127 std::ostream &operator<<(std::ostream &o, const type_info &t)
128 {
129     o << t.name;
130     return o;
131 }
132
133 struct parse_error : public std::runtime_error
134 {
135     parse_error(const std::string &file, unsigned line, const std::string &msg)
136             : std::runtime_error(file+":"+boost::lexical_cast<std::string>(line)+": error: "+msg)
137     {}
138 };
139
140 //! get type by id
141 /*!
142   \return type name or empty string on error
143 */
144 type_info get_type(const xmlpp::Element* root, const std::string &id)
145 {
146     type_info error;
147     const xmlpp::Element* element(get_element_by_id(root, id));
148     if (!element) return error;
149
150     // TODO: not yet complete
151     // if we recurse - when do we stop?
152     // if it is a typedef? yes? (hmm if the typedef is in the file parsed this will not work)
153
154     // TODO: const and reference types handling is a ugly hack
155
156     std::string tag(element->get_name());
157     if (tag=="ReferenceType")
158     {
159         assert(element->get_attribute("type"));
160         type_info ret(get_type(root, element->get_attribute("type")->get_value()));
161         if (ret==error) return error;
162         // at the moment we only support const &
163         // todo: nice error message!
164         if ((ret.noref_name=strip(ret.name,"const ")).empty()) return error;
165         ret.name=ret.name+"&";
166         return ret;
167     }
168     else if (tag=="CvQualifiedType")
169     {
170         assert(element->get_attribute("type"));
171         type_info ret(get_type(root, element->get_attribute("type")->get_value()));
172         if (ret==error) return error;
173         ret.name=std::string("const ")+ret.name;
174         return ret;
175     }
176     else if (tag=="PointerType")
177     {
178         // todo: nearly the same as reference type handling
179         assert(element->get_attribute("type"));
180         type_info ret(get_type(root, element->get_attribute("type")->get_value()));
181         if (ret==error) return error;
182         // at the moment we only support const &
183         // todo: nice error message!
184         if ((ret.noref_name=strip(ret.name,"const ")).empty()) return error;
185         ret.name=ret.name+"*";
186         return ret;
187     }
188
189     assert(element->get_attribute("name"));
190     type_info ret;
191     if (element->get_attribute("context"))
192     {
193         ret.name=get_namespace(root, element->get_attribute("context")->get_value());
194         if (ret.name!="::")
195             ret.name+="::";
196         else
197             // do not explicitely add ::
198             ret.name="";
199     }
200     ret.name+=element->get_attribute("name")->get_value();
201     return ret;
202 }
203
204 struct t2n_procedure
205 {
206     typedef std::list<std::pair<std::string, type_info> > Args;
207
208     type_info ret_type;
209     std::string name;
210     std::string mangled;
211     Args  args;
212
213     std::string ret_classname() const
214     {
215         return name+mangled+"_res";
216     }
217     std::string cmd_classname() const
218     {
219         return name+mangled+"_cmd";
220     }
221     bool hasReturn() const {return !ret_type.isVoid();}
222 };
223
224 std::ostream &operator<<(std::ostream &o, const t2n_procedure::Args &args)
225 {
226     for (t2n_procedure::Args::const_iterator it=args.begin();it!=args.end();++it)
227     {
228         if (it!=args.begin()) o << ", ";
229         o << it->second << " " << it->first;
230     }
231     return o;
232 }
233
234 std::ostream &operator<<(std::ostream &o, const t2n_procedure &f)
235 {
236     o << f.ret_type << " " << f.name << "(" << f.args << ")";
237     return o;
238 }
239
240 std::pair<std::string, unsigned>
241 get_file_and_line(const xmlpp::Element* root, const xmlpp::Element* element)
242 {
243     return std::pair<std::string, unsigned>(get_file(root, element->get_attribute("file")->get_value()),
244                                             boost::lexical_cast<unsigned>(element->get_attribute("line")->get_value())-1);
245 }
246
247 std::string get_file_and_line_as_string(const xmlpp::Element* root, const xmlpp::Element* element)
248 {
249     std::pair<std::string, unsigned> fl(get_file_and_line(root,element));
250     return std::string(fl.first)+":"+boost::lexical_cast<std::string>(fl.second);
251 }
252
253 class Parser
254 {
255 public:
256     Parser(const std::string &fname) : m_fname(fname) {}
257
258     std::list<t2n_procedure> get_procedures()
259     {
260         xmlpp::DomParser parser;
261         //    parser.set_validate();
262         parser.set_substitute_entities(); //We just want the text to be resolved/unescaped automatically.
263         parser.parse_file(m_fname);
264         if (parser)
265         {
266             //Walk the tree:
267             const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
268             const xmlpp::Element* root = dynamic_cast<const xmlpp::Element*>(pNode);
269             assert(root);
270             visit_node(root);
271         }
272         return m_procedures;
273     }
274 protected:
275     std::string m_fname;
276     std::list<t2n_procedure> m_procedures;
277
278     void parse_function(const xmlpp::Element* root, const xmlpp::Node* node)
279     {
280         const xmlpp::Element* element = dynamic_cast<const xmlpp::Element*>(node);
281         if (!element) return;
282
283         const xmlpp::Attribute* attributes = element->get_attribute("attributes");
284         const xmlpp::Attribute* name = element->get_attribute("name");
285         const xmlpp::Attribute* mangled = element->get_attribute("mangled");
286         const xmlpp::Attribute* returns = element->get_attribute("returns");
287         if ((!attributes)||(!name)||(!mangled)||(!returns)) return;
288
289         // check wether the procedure is marked (TODO: improve)
290         // attributes are speparated by spaces?
291
292         t2n_procedure f;
293         if (!is_marked(attributes->get_value())) return;
294
295         // we need the return type
296         f.ret_type=get_type(root, returns->get_value());
297         f.name=name->get_value();
298         f.mangled=mangled->get_value();
299
300         xmlpp::Node::NodeList list = node->get_children("Argument");
301         for (xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
302         {
303             const xmlpp::Element* arg = dynamic_cast<const xmlpp::Element*>(*iter);
304             if ( arg )
305             {
306                 assert(arg->get_name() == "Argument");
307                 assert(arg->get_attribute("name"));
308                 assert(arg->get_attribute("type"));
309                 f.args.push_back(std::pair<std::string, type_info>(arg->get_attribute("name")->get_value(), get_type(root, arg->get_attribute("type")->get_value())));
310                 // todo: ugly - could be any other error
311                 if (f.args.back().second.name.empty())
312                 {
313                     assert(element->get_attribute("file"));
314                     assert(element->get_attribute("line"));
315                     std::pair<std::string, unsigned> file_and_line(get_file_and_line(root, element));
316                     throw parse_error(file_and_line.first,
317                                       file_and_line.second,
318                                       std::string("type of parameter `")+f.args.back().first+"' not (yet?) supported");
319                 }
320             }
321         }
322         std::cerr << get_file_and_line_as_string(root, element) << ":\texport procedure: " << f << std::endl;
323         m_procedures.push_back(f);
324     }
325
326     void visit_node(const xmlpp::Element* root, const xmlpp::Node* node = NULL, unsigned int indentation = 0)
327     {
328         if (!node) node=root;
329
330         const xmlpp::ContentNode* nodeContent = dynamic_cast<const xmlpp::ContentNode*>(node);
331         const xmlpp::TextNode* nodeText = dynamic_cast<const xmlpp::TextNode*>(node);
332         const xmlpp::CommentNode* nodeComment = dynamic_cast<const xmlpp::CommentNode*>(node);
333
334         if (nodeText && nodeText->is_white_space()) //Let's ignore the indenting - you don't always want to do this.
335             return;
336
337         std::string nodename = node->get_name();
338
339         if (!nodeText && !nodeComment && !nodename.empty()) //Let's not say "name: text".
340         {
341             if (node->get_name() == "Function") parse_function(root, node);
342         }
343         if (!nodeContent)
344         {
345             //Recurse through child nodes:
346             xmlpp::Node::NodeList list = node->get_children();
347             for (xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
348             {
349                 visit_node(root, *iter, indentation + 2); //recursive
350             }
351         }
352     }
353 };
354
355 void output_common_hpp(std::ostream &o, const std::string &group, const std::list<t2n_procedure> &procs)
356 {
357     o << "class " << groupClass(group) << " : public libt2n::command\n"
358     << "{\n"
359     << "private:\n"
360     << " friend class boost::serialization::access;\n"
361     << " template<class Archive>\n"
362     << " void serialize(Archive & ar, const unsigned int /* version */)\n"
363     << " {ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(libt2n::command);}\n"
364     << "};\n";
365
366     for (std::list<t2n_procedure>::const_iterator it=procs.begin();it!=procs.end();++it)
367     {
368         o << "class " << it->ret_classname() << " : public libt2n::result\n"
369         << "{\n"
370         << "private:\n";
371         if (it->hasReturn())
372             o << " " << it->ret_type << " res;\n";
373         o << " friend class boost::serialization::access;\n"
374         << " template<class Archive>\n"
375         << " void serialize(Archive & ar, const unsigned int /* version */)\n"
376         << " {\n"
377         << "  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(libt2n::result);\n";
378         if (it->hasReturn())
379             o << "  ar & BOOST_SERIALIZATION_NVP(res);\n";
380         o << " }\n"
381         << "public:\n"
382         << " " << it->ret_classname() << "() {}\n";
383         if (it->hasReturn())
384         {
385             o << " " << it->ret_classname() << "(const " << it->ret_type << " &_res) : res(_res) {}\n"
386             << " " << it->ret_type << " get_data() { return res; }\n";
387         }
388         o << "};\n";
389     }
390     for (std::list<t2n_procedure>::const_iterator it=procs.begin();it!=procs.end();++it)
391     {
392         o << "class " << it->cmd_classname() << " : public " << groupClass(group) << "\n"
393         << "{\n"
394         << "private:\n";
395         for (t2n_procedure::Args::const_iterator ait=it->args.begin();ait!=it->args.end();++ait)
396         {
397             o << " " << ait->second.noref() << " " << ait->first << ";\n";
398         }
399         o << " friend class boost::serialization::access;\n"
400         << " template<class Archive>\n"
401         << " void serialize(Archive & ar, const unsigned int /* version */)\n"
402         << " {\n"
403         << "  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(" << groupClass(group) << ");\n";
404         for (t2n_procedure::Args::const_iterator ait=it->args.begin();ait!=it->args.end();++ait)
405         {
406             o << "  ar & BOOST_SERIALIZATION_NVP(" << ait->first << ");\n";
407         }
408
409         // default constructor
410         o << " }\n"
411         << "\n"
412         << "public:\n"
413         << " " << it->cmd_classname() << "() {}\n";
414
415         // constructor taking all arguments
416         if (!it->args.empty())
417         {
418             o << " " << it->cmd_classname() << "(";
419             for (t2n_procedure::Args::const_iterator ait=it->args.begin();ait!=it->args.end();++ait)
420             {
421                 if (ait!=it->args.begin()) o << ", ";
422                 o << ait->second << " _" << ait->first;
423             }
424             o << ") : ";
425             for (t2n_procedure::Args::const_iterator ait=it->args.begin();ait!=it->args.end();++ait)
426             {
427                 if (ait!=it->args.begin()) o << ", ";
428                 // pointers are const pointers and must be dereferenced
429                 o << ait->first << "(" << ((ait->second.name.find_first_of('*')!=std::string::npos) ? "*" : "" ) << "_" << ait->first << ")";
430             }
431             o << " {}\n";
432         }
433         o << " libt2n::result* operator()();\n"
434         << "};\n";
435     }
436 }
437
438 void output_common_cpp(std::ostream &o, const std::string &group, const std::list<t2n_procedure> &procs, const std::string &common_hpp)
439 {
440     o << "#include \"" << common_hpp << "\"\n"
441     << "#include <boost/serialization/export.hpp>\n"
442     << "\n"
443     << "/* register types with boost serialization */\n";
444     o << "BOOST_CLASS_EXPORT(" << groupClass(group) << ")\n";
445     for (std::list<t2n_procedure>::const_iterator it=procs.begin();it!=procs.end();++it)
446     {
447         o << "BOOST_CLASS_EXPORT("<<it->ret_classname()<<")\n"
448         << "BOOST_CLASS_EXPORT("<<it->cmd_classname()<<")\n";
449     }
450 }
451
452 void output_client_hpp(std::ostream &o, const std::string &group, const std::list<t2n_procedure> &procs)
453 {
454     o << "#include <command_client.hxx>\n";
455
456     o << "class " << groupClass(group) << "_client : public libt2n::command_client\n"
457     << "{\n"
458     << "public:\n"
459     << groupClass(group) << "_client(libt2n::client_connection &_c,\n"
460     << " long long _command_timeout_usec=command_timeout_usec_default,\n"
461     << " long long _hello_timeout_usec=hello_timeout_usec_default)\n"
462     << " : libt2n::command_client(_c,_command_timeout_usec,_hello_timeout_usec)\n"
463     << " {}\n";
464     for (std::list<t2n_procedure>::const_iterator pit=procs.begin();pit!=procs.end();++pit)
465     {
466         o << " " << *pit << ";\n";
467     }
468     o << "};\n";
469 }
470
471 void output_client_cpp(std::ostream &o, const std::string &group, const std::list<t2n_procedure> &procs, const std::string &common_hpp, const std::string &common_cpp, const std::string &client_hpp)
472 {
473     o << "#include \"" << client_hpp << "\"\n"
474     << "#include \"" << common_hpp << "\"\n"
475     << "// fake\n";
476     for (std::list<t2n_procedure>::const_iterator it=procs.begin();it!=procs.end();++it)
477     {
478         o << "libt2n::result* " << it->cmd_classname() << "::operator()() { return NULL; }\n";
479     }
480
481     for (std::list<t2n_procedure>::const_iterator pit=procs.begin();pit!=procs.end();++pit)
482     {
483         o << pit->ret_type << " " << groupClass(group) << "_client::" << pit->name << "(" << pit->args << ")\n"
484         << "{\n"
485         << " libt2n::result_container rc;\n"
486         << " send_command(new " << pit->cmd_classname() << "(";
487         for (t2n_procedure::Args::const_iterator ait=pit->args.begin();ait!=pit->args.end();++ait)
488         {
489             if (ait!=pit->args.begin()) o << ", ";
490             o << ait->first;
491         }
492         o << "), rc);\n"
493         << " " << pit->ret_classname() << "* res=dynamic_cast<" << pit->ret_classname() << "*>(rc.get_result());\n"
494         << " if (!res) throw libt2n::t2n_communication_error(\"result object of wrong type\");\n";
495         if (pit->hasReturn())
496             o << " return res->get_data();\n";
497         o << "}\n";
498     }
499
500     // include in this compilation unit to ensure the compilation unit is used
501     // see also:
502     // http://www.google.de/search?q=g%2B%2B+static+initializer+in+static+library
503     o << "#include \"" << common_cpp << "\"\n";
504 }
505
506 void output_server_hpp(std::ostream &o, const std::string & /* group */, const std::list<t2n_procedure> &procs, const std::string &common_hpp)
507 {
508     o << "#include \"" << common_hpp << "\"\n";
509
510     // output function declarations
511     for (std::list<t2n_procedure>::const_iterator it=procs.begin();it!=procs.end();++it)
512         o << *it << ";\n";
513 }
514
515 void output_server_cpp(std::ostream &o, const std::string &group, const std::list<t2n_procedure> &procs, const std::string &common_hpp, const std::string &common_cpp)
516 {
517     o << "#include \"" << common_hpp << "\"\n";
518
519     for (std::list<t2n_procedure>::const_iterator it=procs.begin();it!=procs.end();++it)
520     {
521         o << *it << ";\n";
522         o << "libt2n::result* " << it->cmd_classname() << "::operator()() { ";
523
524         if (it->hasReturn())
525             o << "return new " << it->ret_classname() << "(";
526
527         // output function name and args
528         o << it->name << "(";
529         for (t2n_procedure::Args::const_iterator ait=it->args.begin();ait!=it->args.end();++ait)
530         {
531             if (ait!=it->args.begin()) o << ", ";
532             // get pointer
533             if (ait->second.name.find_first_of('*')!=std::string::npos)
534                 o << '&';
535             o << ait->first;
536         }
537
538         if (it->hasReturn())
539             o << "));";
540         else
541             o << "); return new " << it->ret_classname() << "();";
542
543         o << " }\n";
544     }
545     o << "#include \"" << common_cpp << "\"\n";
546 }
547
548 struct header_file : public std::ofstream
549 {
550     header_file(const char* fname) : std::ofstream(fname)
551     {
552         std::cerr << "create header: '" << fname << "'" << std::endl;
553         std::string macro(replace(toupper(fname),'.','_'));
554         *this << "// automatically generated code (generated by libt2n-codegen " << VERSION << ") - do not edit\n" << std::endl;
555         *this << "#ifndef " << macro << "\n"
556         << "#define " << macro << "\n";
557     }
558     ~header_file()
559     {
560         *this << "#endif" << std::endl;
561     }
562 };
563
564 struct cpp_file : public std::ofstream
565 {
566     cpp_file(const char* fname) : std::ofstream(fname)
567     {
568         std::cerr << "create cpp: '" << fname << "'" << std::endl;
569         *this << "// automatically generated code - do not edit\n" << std::endl;
570     }
571 };
572
573 int
574 main(int argc, char* argv[])
575 {
576     // todo: maybe use getopt
577     if ((argc>1)&&(std::string(argv[1])=="--version"))
578     {
579         std::cerr << VERSION << std::endl;
580         return 0;
581     }
582     if (argc < 3)
583     {
584         std::cerr << "Usage: " << argv[0] << "default-group gccxml-file1 gccxml-file2 ... " << std::endl;
585         return 1;
586     }
587
588     try
589     {
590         std::string group(argv[1]);
591         std::list<std::string> xmlfiles;
592         for (int i=2;i<argc;++i)
593             xmlfiles.push_back(argv[i]);
594
595         std::string prefix=group+"_";
596         std::list<t2n_procedure> procedures;
597         for (std::list<std::string>::iterator it=xmlfiles.begin();it!=xmlfiles.end();++it)
598         {
599             std::cerr << "Parse " << *it << std::endl;
600             Parser parser(*it);
601             const std::list<t2n_procedure> &p(parser.get_procedures());
602             std::copy(p.begin(), p.end(), std::back_inserter(procedures));
603         }
604
605         std::cerr << "All procedures:" << std::endl;
606         for (std::list<t2n_procedure>::const_iterator it=procedures.begin();it!=procedures.end();++it)
607             std::cerr << *it << ";" << std::endl;
608
609         std::string common_hpp_fname(prefix+"common.hxx");
610         std::string common_cpp_fname(prefix+"common.cpp");
611         std::string client_hpp_fname(prefix+"client.hxx");
612         std::string client_cpp_fname(prefix+"client.cpp");
613         std::string server_hpp_fname(prefix+"server.hxx");
614         std::string server_cpp_fname(prefix+"server.cpp");
615
616         header_file common_hpp(common_hpp_fname.c_str());
617         common_hpp << "// boost serialization is picky about order of include files => we have to include this one first\n"
618         << "#include \"codegen-stubhead.hxx\"\n"
619         << "#include \"" << group << ".hxx\"\n";
620
621         output_common_hpp(common_hpp, group, procedures);
622
623         cpp_file common_cpp(common_cpp_fname.c_str());
624         output_common_cpp(common_cpp, group, procedures, common_hpp_fname);
625
626         header_file client_hpp(client_hpp_fname.c_str());
627         client_hpp << "// boost serialization is picky about order of include files => we have to include this one first\n"
628         << "#include \"codegen-stubhead.hxx\"\n"
629         << "#include \"" << group << ".hxx\"\n";
630         output_client_hpp(client_hpp, group, procedures);
631
632         cpp_file client_cpp(client_cpp_fname.c_str());
633         output_client_cpp(client_cpp, group, procedures, common_hpp_fname, common_cpp_fname, client_hpp_fname);
634
635         header_file server_hpp(server_hpp_fname.c_str());
636         output_server_hpp(server_hpp, group, procedures, common_hpp_fname);
637
638         cpp_file server_cpp(server_cpp_fname.c_str());
639         output_server_cpp(server_cpp, group, procedures, common_hpp_fname, common_cpp_fname);
640     }
641     catch (const parse_error &e)
642     {
643         std::cerr << e.what() << std::endl;
644         return EXIT_FAILURE;
645     }
646     return EXIT_SUCCESS;
647 }