Commit f8bc426a authored by Simon Morlat's avatar Simon Morlat

* improved documentation

* update ms2
* javascript generator in progress
parent 643dc7f9
......@@ -535,7 +535,7 @@ LINPHONE_PUBLIC const char *linphone_call_state_to_string(LinphoneCallState cs);
LINPHONE_PUBLIC LinphoneCore *linphone_call_get_core(const LinphoneCall *call);
LINPHONE_PUBLIC LinphoneCallState linphone_call_get_state(const LinphoneCall *call);
bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call);
LINPHONE_PUBLIC const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc);
LINPHONE_PUBLIC const LinphoneAddress * linphone_core_get_current_call_remote_address(LinphoneCore *lc);
LINPHONE_PUBLIC const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call);
LINPHONE_PUBLIC char *linphone_call_get_remote_address_as_string(const LinphoneCall *call);
LINPHONE_PUBLIC LinphoneCallDir linphone_call_get_dir(const LinphoneCall *call);
......@@ -694,7 +694,7 @@ LINPHONE_PUBLIC bool_t linphone_proxy_config_register_enabled(const LinphoneProx
LINPHONE_PUBLIC void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj);
LINPHONE_PUBLIC const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj);
LINPHONE_PUBLIC void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params);
struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
LINPHONE_PUBLIC bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg);
LINPHONE_PUBLIC const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg);
......@@ -744,7 +744,7 @@ LINPHONE_PUBLIC LinphonePrivacyMask linphone_proxy_config_get_privacy(const Linp
**/
typedef struct _LinphoneAccountCreator{
struct _LinphoneCore *lc;
LinphoneCore *lc;
struct _SipSetupContext *ssctx;
char *username;
char *password;
......@@ -755,7 +755,7 @@ typedef struct _LinphoneAccountCreator{
bool_t succeeded;
}LinphoneAccountCreator;
LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
LinphoneAccountCreator *linphone_account_creator_new(LinphoneCore *core, const char *type);
void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username);
void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password);
void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain);
......@@ -920,33 +920,38 @@ typedef enum _LinphoneGlobalState{
const char *linphone_global_state_to_string(LinphoneGlobalState gs);
/**
* Global state notification callback.
* @param lc
* @param gstate the global state
* @param message informational message.
*/
typedef void (*LinphoneGlobalStateCb)(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
/**Call state notification callback prototype*/
typedef void (*LinphoneGlobalStateCb)(struct _LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
/**Call state notification callback prototype*/
typedef void (*LinphoneCallStateCb)(struct _LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
typedef void (*LinphoneCallStateCb)(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
/**Call encryption changed callback prototype*/
typedef void (*CallEncryptionChangedCb)(struct _LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
typedef void (*CallEncryptionChangedCb)(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
/** @ingroup Proxies
* Registration state notification callback prototype
* */
typedef void (*LinphoneRegistrationStateCb)(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
typedef void (*LinphoneRegistrationStateCb)(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
/** Callback prototype */
typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
typedef void (*ShowInterfaceCb)(LinphoneCore *lc);
/** Callback prototype */
typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
typedef void (*DisplayStatusCb)(LinphoneCore *lc, const char *message);
/** Callback prototype */
typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
typedef void (*DisplayMessageCb)(LinphoneCore *lc, const char *message);
/** Callback prototype */
typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
typedef void (*DisplayUrlCb)(LinphoneCore *lc, const char *message, const char *url);
/** Callback prototype */
typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
typedef void (*LinphoneCoreCbFunc)(LinphoneCore *lc,void * user_data);
/**
* Report status change for a friend previously \link linphone_core_add_friend() added \endlink to #LinphoneCore.
* @param lc #LinphoneCore object .
* @param lf Updated #LinphoneFriend .
*/
typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * lf);
typedef void (*NotifyPresenceReceivedCb)(LinphoneCore *lc, LinphoneFriend * lf);
/**
* Reports that a new subscription request has been received and wait for a decision.
* <br> Status on this subscription request is notified by \link linphone_friend_set_inc_subscribe_policy() changing policy \endlink for this friend
......@@ -955,11 +960,11 @@ typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFrien
* @param url of the subscriber
* Callback prototype
* */
typedef void (*NewSubscribtionRequestCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
typedef void (*NewSubscribtionRequestCb)(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
/** Callback prototype */
typedef void (*AuthInfoRequestedCb)(struct _LinphoneCore *lc, const char *realm, const char *username);
typedef void (*AuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username);
/** Callback prototype */
typedef void (*CallLogUpdatedCb)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
typedef void (*CallLogUpdatedCb)(LinphoneCore *lc, struct _LinphoneCallLog *newcl);
/**
* Callback prototype
* @deprecated use #MessageReceived instead.
......@@ -980,24 +985,24 @@ typedef void (*TextMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room,
typedef void (*MessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message);
/** Callback prototype */
typedef void (*DtmfReceivedCb)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf);
typedef void (*DtmfReceivedCb)(LinphoneCore* lc, LinphoneCall *call, int dtmf);
/** Callback prototype */
typedef void (*ReferReceivedCb)(struct _LinphoneCore *lc, const char *refer_to);
typedef void (*ReferReceivedCb)(LinphoneCore *lc, const char *refer_to);
/** Callback prototype */
typedef void (*BuddyInfoUpdatedCb)(struct _LinphoneCore *lc, LinphoneFriend *lf);
typedef void (*BuddyInfoUpdatedCb)(LinphoneCore *lc, LinphoneFriend *lf);
/** Callback prototype for in progress transfers. The new_call_state is the state of the call resulting of the transfer, at the other party. */
typedef void (*LinphoneTransferStateChangedCb)(struct _LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state);
typedef void (*LinphoneTransferStateChangedCb)(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state);
/** Callback prototype for receiving quality statistics for calls*/
typedef void (*CallStatsUpdatedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats);
typedef void (*CallStatsUpdatedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats);
/** Callback prototype for receiving info messages*/
typedef void (*LinphoneInfoReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
typedef void (*LinphoneInfoReceivedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
/**
* This structure holds all callbacks that the application should implement.
* None is mandatory.
**/
typedef struct _LinphoneVTable{
LinphoneGlobalStateCb global_state_changed; /**<Notifies globlal state changes*/
typedef struct _LinphoneCoreVTable{
LinphoneGlobalStateCb global_state_changed; /**<Notifies global state changes*/
LinphoneRegistrationStateCb registration_state_changed;/**<Notifies registration state changes*/
LinphoneCallStateCb call_state_changed;/**<Notifies call state changes*/
NotifyPresenceReceivedCb notify_presence_recv; /**< Notify received presence events*/
......@@ -1048,7 +1053,7 @@ typedef enum _LinphoneWaitingState{
LinphoneWaitingProgress,
LinphoneWaitingFinished
} LinphoneWaitingState;
typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
typedef void * (*LinphoneWaitingCallback)(LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
/* THE main API */
......
This diff is collapsed.
......@@ -260,11 +260,11 @@ void linphone_proxy_config_edit(LinphoneProxyConfig *obj){
}
}
void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc)
{
void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc){
obj->lc=lc;
linphone_proxy_config_done(obj);
}
LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
LinphoneAddress *ret=NULL;
LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy);
......@@ -312,38 +312,13 @@ LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
}
#endif //BUILD_UPNP
#ifndef USE_BELLESIP
if(localip == NULL) {
char localip_tmp[LINPHONE_IPADDR_SIZE] = {'\0'};
localip = localip_tmp;
linphone_core_get_local_ip(obj->lc,host,localip_tmp);
}
if(localport == -1) {
localport = linphone_core_get_sip_port(obj->lc);
}
{
LCSipTransports tr;
linphone_core_get_sip_transports(obj->lc,&tr);
if (tr.udp_port <= 0) {
if (tr.tcp_port>0) {
sal_address_set_param(contact,"transport","tcp");
} else if (tr.tls_port>0) {
sal_address_set_param(contact,"transport","tls");
}
}
}
#endif
linphone_address_set_port(contact,localport);
linphone_address_set_domain(contact,localip);
linphone_address_set_display_name(contact,NULL);
#ifndef USE_BELLESIP
ret = linphone_address_as_string(contact);
linphone_address_destroy(contact);
#else
ret=contact;
#endif /*USE_BELLESIP*/
linphone_address_destroy (proxy);
ms_free(tmp);
}
......
mediastreamer2 @ dbe58747
Subproject commit 8097db23c50a476593cf912f0c554ca4e391c7e3
Subproject commit dbe58747533b5e2b3e3c25009f483158e2b0cde9
......@@ -28,6 +28,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
string to_lower(const string &str){
string res=str;
for(string::iterator it=res.begin();it!=res.end();++it){
*it=tolower(*it);
}
return res;
}
CplusplusGenerator::CplusplusGenerator(){
}
......@@ -42,17 +50,25 @@ void CplusplusGenerator::generate(Project *proj){
for_each(classes.begin(),classes.end(),bind1st(mem_fun(&CplusplusGenerator::writeClass),this));
}
void CplusplusGenerator::writeEnumMember(ConstField *cf, bool isLast){
writeTabs(1);
mOutfile<<cf->getName();
if (!isLast) mOutfile<<",";
if (!cf->getHelp().empty()) mOutfile<<"\t/**< "<<cf->getHelp()<<" */";
mOutfile<<endl;
}
void CplusplusGenerator::writeClass(Class *klass){
ostringstream filename;
if (klass->getType()!=Type::Class) return;
filename<<mCurProj->getName()<<"/"<<klass->getName()<<".hh";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
const list<Method*> &methods=klass->getMethods();
list<Method*> methods=klass->getMethods();
list<ConstField*> constFields=klass->getConstFields();
mCurClass=klass;
mOutfile<<"/* Wrapper generated by lp-gen-wrappers, do not edit*/"<<endl;
mOutfile<<endl;
......@@ -60,10 +76,20 @@ void CplusplusGenerator::writeClass(Class *klass){
mOutfile<<endl;
if (!mCurProj->getName().empty())
mOutfile<<"namespace "<<mCurProj->getName()<<"{"<<endl<<endl;
mOutfile<<"class "<<klass->getName()<<"{"<<endl;
mOutfile<<"public:"<<endl;
for_each(methods.begin(),methods.end(),bind1st(mem_fun(&CplusplusGenerator::writeMethod),this));
mOutfile<<"}"<<endl<<endl;
if (klass->getType()==Type::Enum){
mOutfile<<"enum "<<klass->getName()<<"{"<<endl;
list<ConstField*>::iterator cfit,next;
for (cfit=constFields.begin();cfit!=constFields.end();){
ConstField *cf=*cfit;
writeEnumMember(cf,++cfit==constFields.end());
}
}else{
mOutfile<<"class "<<klass->getName()<<"{"<<endl;
mOutfile<<"public:"<<endl;
for_each(methods.begin(),methods.end(),bind1st(mem_fun(&CplusplusGenerator::writeMethod),this));
}
mOutfile<<"};"<<endl<<endl;
if (!mCurProj->getName().empty())
mOutfile<<"} //end of namespace "<<mCurProj->getName()<<endl;
mOutfile<<endl;
......@@ -154,29 +180,102 @@ void JavascriptGenerator::generate(Project *proj){
list<Class*> classes=proj->getClasses();
mCurProj=proj;
#ifndef WIN32
unlink(proj->getName().c_str());
mkdir(proj->getName().c_str(),S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH);
remove(to_lower(proj->getName()).c_str());
mkdir(to_lower(proj->getName()).c_str(),S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH);
#else
_mkdir(proj->getName().c_str());
_mkdir(to_lower(proj->getName()).c_str());
#endif
ostringstream filename;
/*write a file for the namespace*/
filename<<to_lower(mCurProj->getName())<<"/"<<to_lower(mCurProj->getName())<<".js";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
mOutfile<<"/**"<<endl;
mOutfile<<" * Namespace for non-external variables and objects."<<endl;
mOutfile<<" * @namespace "<<mCurProj->getName()<<endl;
mOutfile<<"**/"<<endl;
mOutfile<<"var "<<proj->getName()<<" = {};"<<endl;
mOutfile.close();
for_each(classes.begin(),classes.end(),bind1st(mem_fun(&JavascriptGenerator::writeEnum),this));
for_each(classes.begin(),classes.end(),bind1st(mem_fun(&JavascriptGenerator::writeClass),this));
}
void JavascriptGenerator::writeEnum(Class *klass){
if (klass->getType()!=Type::Enum) return;
ostringstream filename;
list<ConstField*> members=klass->getConstFields();
list<ConstField*>::iterator it;
string enum_name=klass->getName();
int value=0;
if (strncasecmp(enum_name.c_str(),mCurProj->getName().c_str(),mCurProj->getName().size())==0){
//since enum is part of the namespace, drop the namespace part of the enum if any.
enum_name.erase(0,mCurProj->getName().size());
}
filename<<to_lower(mCurProj->getName())<<"/"<<to_lower(enum_name)<<".js";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
mOutfile<<"/* Wrapper generated by lp-gen-wrappers, do not edit*/"<<endl<<endl;
mOutfile<<"var "<<mCurProj->getName()<<" = "<<mCurProj->getName()<<" || {};"<<endl;
mOutfile<<"/**"<<endl;
writeHelpComment(klass->getHelp(),0);
mOutfile<<endl;
mOutfile<<" * "<<"@readonly"<<endl;
mOutfile<<" * "<<"@enum {number}"<<endl;
mOutfile<<"**/"<<endl;
mOutfile<<mCurProj->getName()<<"."<<enum_name<<" = {"<<endl;
string prefix=ConstField::getCommonPrefix(members);
size_t prefix_size=prefix.size();
for(it=members.begin();it!=members.end();value++){
ConstField *cf=(*it);
if (!cf->getHelp().empty()){
writeTabs(1);
mOutfile<<"/**"<<endl;
writeHelpComment(cf->getHelp(),1);
mOutfile<<endl;
writeTabs(1);
mOutfile<<"*/"<<endl;
}
writeTabs(1);
mOutfile<<cf->getName().substr(prefix_size,string::npos)<<" : "<<value;
if (++it!=members.end()) mOutfile<<",";
mOutfile<<endl;
}
mOutfile<<"};"<<endl;
mOutfile.close();
}
void JavascriptGenerator::writeClass(Class *klass){
ostringstream filename;
if (klass->getType()!=Type::Class) return;
filename<<mCurProj->getName()<<"/"<<klass->getName()<<".js";
if (klass->getType()==Type::Enum) {
return;
}
filename<<to_lower(mCurProj->getName())<<"/"<<to_lower(klass->getName())<<".js";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
const list<Method*> &methods=klass->getMethods();
mCurClass=klass;
mOutfile<<"/* Wrapper generated by lp-gen-wrappers, do not edit*/"<<endl;
mOutfile<<endl;
const list<Method*> &methods=klass->getMethods();
//if (!mCurProj->getName().empty())
// mOutfile<<"namespace "<<mCurProj->getName()<<"{"<<endl<<endl;
mOutfile<<"/**"<<endl;
......@@ -239,11 +338,12 @@ void JavascriptGenerator::writeTabs(int ntabs){
void JavascriptGenerator::writeHelpComment(const std::string &comment, int ntabs){
size_t i;
int curindex=0;
writeTabs(ntabs);
mOutfile<<" * ";
for(i=0;i<comment.size();i++,curindex++){
if (comment[i]=='\n' || (curindex>100 && comment[i]==' ')){
mOutfile<<endl;
writeTabs(ntabs);
mOutfile<<" * ";
curindex=0;
}else mOutfile<<comment[i];
......@@ -251,6 +351,7 @@ void JavascriptGenerator::writeHelpComment(const std::string &comment, int ntabs
}
void JavascriptGenerator::writeProperty(Property *prop){
if (prop->getName()=="userData" || prop->getName()=="userPointer") return;
mOutfile<<"/**"<<endl;
writeHelpComment(prop->getHelp(),0);
mOutfile<<endl;
......
......@@ -40,6 +40,7 @@ private:
void writeTabs(int ntabs);
void writeHelpComment(const std::string &comment, int ntabs);
void writeMethod(Method *method);
void writeEnumMember(ConstField *cf, bool isLast);
ofstream mOutfile;
Project *mCurProj;
Class *mCurClass;
......@@ -51,6 +52,7 @@ public:
virtual void generate(Project *proj);
private:
void writeClass(Class *klass);
void writeEnum(Class *klass);
void writeType(Type *type);
void writeArgument(Argument *arg, bool isReturn=false);
void writeTabs(int ntabs);
......@@ -62,5 +64,6 @@ private:
Class *mCurClass;
};
string to_lower(const string &str);
#endif
......@@ -250,6 +250,22 @@ static void parseFunction(Project *proj, xmlNode *node){
}
}
static void parseEnum(Project *proj, XmlNode node){
string name=node.getChild("name").getText();
if (name[0]=='_') name.erase(0,1);
Class *klass=proj->getClass(name);
klass->setHelp(node.getChild("detaileddescription").getChild("para").getText());
list<XmlNode> enumValues=node.getChildren("enumvalue");
list<XmlNode>::iterator it;
for (it=enumValues.begin();it!=enumValues.end();++it){
ConstField *cf=new ConstField(Type::getType("int"),(*it).getChild("name").getText());
cf->setHelp((*it).getChild("detaileddescription").getChild("para").getText());
klass->addConstField(cf);
}
}
static void parseTypedef(Project *proj, xmlNode *node){
XmlNode tdef(node);
string typecontent=tdef.getChild("type").getText();
......@@ -278,6 +294,8 @@ static void parseMemberDef(Project *proj, xmlNode *node){
parseFunction(proj,node);
}else if (kind=="typedef"){
parseTypedef(proj,node);
}else if (kind=="enum"){
parseEnum(proj,node);
}
}
......@@ -321,7 +339,7 @@ static int parse_file(Project *proj, const char *filename){
int main(int argc, char *argv[]){
int i;
Project *proj=new Project();
string projectName="wrapper";
OutputGenerator *gen=NULL;
list<string> files;
list<string>::iterator it;
......@@ -330,15 +348,18 @@ int main(int argc, char *argv[]){
for(i=1;i<argc;i++){
if (strcmp(argv[i],"--help")==0){
fprintf(stderr,"%s: [--help] --output (c++) file1 file2...\nParses xml files generated by doxygen to output wrappers in a specified language.\n",argv[0]);
fprintf(stderr,"%s: [--help] --output (c++, javascript) --project <project name> file1 file2...\nParses xml files generated by doxygen to output wrappers in a specified language.\n",argv[0]);
return -1;
}if (strcmp(argv[i],"--output")==0){
}else if (strcmp(argv[i],"--output")==0){
i++;
if (strcmp(argv[i],"c++")==0){
gen=new CplusplusGenerator();
}else if (strcmp(argv[i],"javascript")==0){
gen=new JavascriptGenerator();
}
}else if (strcmp(argv[i],"--project")==0){
i++;
projectName=argv[i];
}else{
files.push_back(argv[i]);
}
......@@ -348,7 +369,7 @@ int main(int argc, char *argv[]){
cerr<<"No output generator selected !"<<endl;
return -1;
}
Project *proj=new Project(projectName);
for(it=files.begin();it!=files.end();it++){
if (parse_file(proj,(*it).c_str())==-1){
cerr<<"Parsing aborted."<<endl;
......
......@@ -270,6 +270,65 @@ private:
string mHelp;
};
class ConstField{
public:
ConstField(Type *type, const string &name, const string &value="") : mType(type), mName(name), mValue(value){
}
void setHelp(const string & help){
mHelp=help;
}
const string &getHelp()const{
return mHelp;
}
const string & getName()const{
return mName;
}
Type *getType()const{
return mType;
}
const string &getValue()const{
return mValue;
}
static string getCommonPrefix(list<ConstField *> fields){
if (fields.size()<2) return "";
list<ConstField*>::iterator it;
string prefix=fields.front()->getName();
int prefixsize;
for (prefixsize=prefix.size();prefixsize>0;prefixsize--){
bool isMatching=true;
prefix=prefix.substr(0,prefixsize);
for(it=fields.begin();it!=fields.end();++it){
ConstField *cf=*it;
if (prefix != cf->getName().substr(0,prefixsize)){
isMatching=false;
break;
}
}
if (isMatching){
cout<<"enum prefix: "<<prefix<<endl;
return prefix;
}
}
return "";
}
private:
Type *mType;
string mName;
string mValue;
string mHelp;
};
template <typename _type>
struct name_matcher{
name_matcher(const string &name) : mName(name){}
bool operator()(_type *cf){
return cf->getName()==mName;
}
string mName;
};
/*actually a class or an enum*/
class Class{
public:
......@@ -282,10 +341,15 @@ public:
if (mMethods.find(method->getName())==mMethods.end())
mMethods.insert(make_pair(method->getName(),method));
}
void addConstField(ConstField *field){
list<ConstField*>::iterator it=find_if(mConstFields.begin(),mConstFields.end(),name_matcher<ConstField>(field->getName()));
if (it==mConstFields.end())
mConstFields.push_back(field);
}
void setHelp(const std::string &help){
mHelp=help;
}
const list<Method*> getMethods()const{
list<Method*> getMethods()const{
list<Method*> ret;
map<string,Method*>::const_iterator it;
for(it=mMethods.begin();it!=mMethods.end();++it){
......@@ -293,13 +357,16 @@ public:
}
return ret;
}
const list<ConstField*> &getConstFields()const{
return mConstFields;
}
const string &getName()const{
return mName;
}
const string &getHelp()const{
return mHelp;
}
const list<Property*> getProperties(){
list<Property*> getProperties(){
list<Property*> ret;
map<string,Property*>::const_iterator it;
for(it=mProperties.begin();it!=mProperties.end();++it){
......@@ -333,6 +400,7 @@ public:
private:
map<string,Method*> mMethods;
map<string,Property*> mProperties;
list<ConstField*> mConstFields;
string mName;
string mHelp;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment