generator.hh 2.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
linphone
Copyright (C) 2013 Belledonne Communications SARL
Simon Morlat (simon.morlat@linphone.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
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 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
*/

#ifndef generator_hh
#define generator_hh

#include <fstream>

#include "software-desc.hh"

class OutputGenerator{
public:
	virtual void generate(Project *proj)=0;
};

class CplusplusGenerator : public OutputGenerator{
public:
	CplusplusGenerator();
	virtual void generate(Project *proj);
private:
	void writeClass(Class *klass);
	void writeArgument(Argument *arg, bool isReturn=false);
	void writeTabs(int ntabs);
	void writeHelpComment(const std::string &comment, int ntabs);
	void writeMethod(Method *method);
Simon Morlat's avatar
Simon Morlat committed
43
	void writeEnumMember(ConstField *cf, bool isLast);
44 45 46 47 48 49 50 51 52 53 54
	ofstream mOutfile;
	Project *mCurProj;
	Class *mCurClass;
};

class JavascriptGenerator : public OutputGenerator{
public:
	JavascriptGenerator();
	virtual void generate(Project *proj);
private:
	void writeClass(Class *klass);
Simon Morlat's avatar
Simon Morlat committed
55
	void writeEnum(Class *klass);
56
	void writeType(Type *type);
57 58
	enum ArgKind { Normal, Return, PropertyArg};
	void writeArgument(Argument *arg, ArgKind kind=Normal);
59 60 61 62
	void writeTabs(int ntabs);
	void writeHelpComment(const std::string &comment, int ntabs);
	void writeProperty(Property *prop);
	void writeMethod(Method *method);
63 64 65
	void writeEvent(Method *event);
	string getEventHelp(const string &ref);
	string getEnumName(Class *klass);
66 67 68 69 70
	ofstream mOutfile;
	Project *mCurProj;
	Class *mCurClass;
};

Simon Morlat's avatar
Simon Morlat committed
71
string to_lower(const string &str);
72 73

#endif