1 /*
2 linphone
3 Copyright (C) 2013 Belledonne Communications SARL
4 Simon Morlat (simon.morlat@linphone.org)
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20 
21 #ifndef generator_hh
22 #define generator_hh
23 
24 #include <fstream>
25 
26 #include "software-desc.hh"
27 
28 class OutputGenerator{
29 public:
30 	virtual void generate(Project *proj)=0;
31 };
32 
33 class CplusplusGenerator : public OutputGenerator{
34 public:
35 	CplusplusGenerator();
36 	virtual void generate(Project *proj);
37 private:
38 	void writeClass(Class *klass);
39 	void writeArgument(Argument *arg, bool isReturn=false);
40 	void writeTabs(int ntabs);
41 	void writeHelpComment(const std::string &comment, int ntabs);
42 	void writeMethod(Method *method);
43 	void writeEnumMember(ConstField *cf, bool isLast);
44 	ofstream mOutfile;
45 	Project *mCurProj;
46 	Class *mCurClass;
47 };
48 
49 class JavascriptGenerator : public OutputGenerator{
50 public:
51 	JavascriptGenerator();
52 	virtual void generate(Project *proj);
53 private:
54 	void writeClass(Class *klass);
55 	void writeEnum(Class *klass);
56 	void writeType(Type *type);
57 	enum ArgKind { Normal, Return, PropertyArg};
58 	void writeArgument(Argument *arg, ArgKind kind=Normal);
59 	void writeTabs(int ntabs);
60 	void writeHelpComment(const std::string &comment, int ntabs);
61 	void writeProperty(Property *prop);
62 	void writeMethod(Method *method);
63 	void writeEvent(Method *event);
64 	string getEventHelp(const string &ref);
65 	string getEnumName(Class *klass);
66 	ofstream mOutfile;
67 	Project *mCurProj;
68 	Class *mCurClass;
69 };
70 
71 string to_lower(const string &str);
72 
73 #endif
74