kdelirc
prototype.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <QRegExp>
00014
00015 #include "prototype.h"
00016
00017 Prototype::Prototype()
00018 {
00019 original = "";
00020 }
00021
00022 Prototype::Prototype(const QString &source)
00023 {
00024 original = source;
00025 parse();
00026 }
00027
00028 Prototype::~Prototype()
00029 {
00030 }
00031
00032 const QString Prototype::argumentList() const
00033 {
00034 QString ret = "";
00035 for(int i = 0; i < theTypes.count(); i++)
00036 ret += (i ? ", " : "") + theTypes[i] + " " + theNames[i];
00037 return ret;
00038 }
00039
00040 const QString Prototype::argumentListNN() const
00041 {
00042 QString ret = "";
00043 for(int i = 0; i < theTypes.count(); i++)
00044 ret += (i ? ", " : "") + theTypes[i];
00045 return ret;
00046 }
00047
00048 void Prototype::parse()
00049 {
00050 theNames.clear();
00051 theTypes.clear();
00052
00053 QRegExp main("^(.*) (\\w[\\d\\w]*)\\((.*)\\)");
00054 QRegExp parameters("^\\s*([^,\\s]+)(\\s+(\\w[\\d\\w]*))?(,(.*))?$");
00055
00056 if(main.search(original) == -1) return;
00057 theReturn = main.cap(1);
00058 theName = main.cap(2);
00059
00060 QString args = main.cap(3);
00061 while(parameters.search(args) != -1)
00062 { theTypes += parameters.cap(1);
00063 theNames += parameters.cap(3);
00064 args = parameters.cap(5);
00065 }
00066 }
00067