23 #include "Reflection.h"
27 map<string,bool> Reflection::invalidcls;
29 Reflection::Reflection() {
30 logger = Logger::getLogger(
"Reflection");
33 Reflection::~Reflection() {
37 strVec Reflection::list(
string cwd)
42 if(chdir(cwd.c_str())!=0)
44 command = (
"find . \\( ! -name . -prune \\) \\( -type f -o -type l \\) -name '*.h' 2>/dev/null");
46 logger << (
"Searching directory " + cwd +
" for pattern .h") << endl;
47 if ((pipe_fp = popen(command.c_str(),
"r")) == NULL)
49 printf(
"pipe open error in cmd_list\n");
54 while ((t_char = fgetc(pipe_fp)) != EOF)
62 fileName.append(temp);
66 StringUtil::replaceFirst(fileName,
"*",
"");
67 StringUtil::replaceFirst(fileName,
"./",
"");
68 if(fileName.find(
"~")==string::npos)
70 fileName = cwd+
"/"+fileName;
71 StringUtil::replaceFirst(fileName,
"//",
"/");
72 files.push_back(fileName);
81 void trimSpaces(
string& str)
84 size_t startpos = str.find_first_not_of(
" \t");
85 size_t endpos = str.find_last_not_of(
" \t");
88 if(( string::npos == startpos ) || ( string::npos == endpos))
93 str = str.substr( startpos, endpos-startpos+1 );
97 void Reflection::collectInfo(
string data,
string flag)
101 this->pub.push_back(data);
102 else if(flag==
"protected")
103 this->pro.push_back(data);
104 else if(flag==
"private")
105 this->pri.push_back(data);
108 bool Reflection::generateClassInfo(
string className)
110 this->pub.clear();this->pri.clear();this->pro.clear();
111 this->classN=
"";this->baseClassN=
"";this->bcvisib=
"";
117 infile.open(className.c_str());
122 bool classdone =
false;
125 bool commstrts =
false;
131 bool classcomplete =
false;
132 while(getline(infile, data))
134 RegexUtil::replace(data,
"[\t]+",
" ");
135 RegexUtil::replace(data,
"[ ]+",
" ");
139 if((tes=data.find(
"/*"))!=string::npos)
142 if((tes=data.find(
"*/"))!=string::npos)
145 else if((tes=data.find(
"*/"))!=string::npos)
149 else if((tes=data.find(
"//"))!=string::npos)
156 if((tes=data.find(
"template"))!=string::npos)
158 if(data.find(
"friend")!=string::npos)
160 if((tes=data.find(
"class"))!=string::npos && !classdone)
163 StringUtil::replaceFirst(data,
":",
"");
164 StringUtil::replaceFirst(data,
"class ",
"");
165 if((tes=data.find(
"{"))!=string::npos)
170 StringUtil::replaceFirst(data,
"{",
"");
171 StringUtil::replaceFirst(data,
":",
"");
172 StringUtil::split(results, data, (
" "));
173 this->classN = results.at(0);
174 StringUtil::replaceAll(this->classN,
" ",
"");
175 if(results.size()==3)
177 this->bcvisib = results.at(1);
178 StringUtil::replaceAll(this->bcvisib,
" ",
"");
179 this->baseClassN = results.at(2);
180 StringUtil::replaceAll(this->baseClassN,
" ",
"");
187 else if((tes=data.find(
"{"))!=string::npos && !start)
190 StringUtil::replaceFirst(data,
"{",
"");
193 if(start && data!=
"")
195 if((tes=data.find(
"{"))!=string::npos)
199 if((tes=data.find(
"}"))!=string::npos)
207 if((tes=data.find(
"public"))!=string::npos)
209 else if((tes=data.find(
"protected"))!=string::npos)
211 else if((tes=data.find(
"private"))!=string::npos)
217 StringUtil::trim(data);
218 collectInfo(data,flag);
226 if(this->pub.size()>0 || this->pri.size()>0 || this->pro.size()>0)
233 bool Reflection::generateClassInfoFromDD(
string alldata)
239 while (getline(ss, data))
242 if ((tes = data.find(
"class")) != string::npos)
245 StringUtil::replaceFirst(data,
":",
"");
246 StringUtil::split(results, data, (
" "));
247 this->classN = results.at(1);
250 this->bcvisib = results.at(2);
251 this->baseClassN = results.at(3);
256 else if ((tes = data.find(
"}")) != string::npos)
258 else if ((tes = data.find(
"public")) != string::npos)
260 else if ((tes = data.find(
"protected")) != string::npos)
262 else if ((tes = data.find(
"private")) != string::npos)
266 if (flag ==
"" && data !=
"{")
268 collectInfo(data, flag);
272 if (this->pub.size() > 0 || this->pri.size() > 0 || this->pro.size() > 0)
278 string Reflection::updateClassDefinition(
string className,
bool file)
280 string refDef,typedefs;
281 if (file && !generateClassInfo(className))
285 else if (!file && !generateClassInfoFromDD(className))
289 typedefs =
"#include \"ClassInfo.h\"\n#include \"string\"\n#include \"Method.h\"\n#include \"Field.h\"\n";
290 typedefs +=
"#include \"" + this->classN +
".h\"\n";
291 string structinf =
"extern \"C\"\n{\nstruct struct"+this->classN+
"{\n";
292 refDef +=
"ClassInfo get" + this->classN +
"()\n{\nClassInfo classInfo;";
293 refDef += (
"\nclassInfo.setClassName(\"" + this->classN +
"\");");
294 refDef += (
"\nclassInfo.setInstance(new " + this->classN +
");");
295 refDef += (
"\nclassInfo.setBase(\"" + this->bcvisib +
" " + this->baseClassN +
"\");");
296 refDef += (
"\nvector<Method> methVec;\nvector<Field> fldVec;\nMethod me;\nField f;\nmethMap meths;\n");
297 refDef += (
"args argu;\n");
298 string publf, privf, protf ,publm, privm, protm;
301 if (this->pub.size() > 0)
303 for (
unsigned int i = 0; i < this->pub.size(); i++)
305 if((tes=this->pub.at(i).find(
"("))!=string::npos && (tes=this->pub.at(i).find(
")"))!=string::npos && this->pub.at(i).find(
"~")==string::npos)
307 refDef += (
"me.clear();\n");
308 publm += this->pub.at(i);
309 meth = this->pub.at(i);
310 StringUtil::replaceFirst(meth,
";",
"");
311 StringUtil::replaceFirst(meth,
"(",
" ");
312 StringUtil::replaceAll(meth,
",",
" ");
313 StringUtil::replaceFirst(meth,
")",
" ");
315 StringUtil::split(methp, meth, (
" "));
316 for(
unsigned int j = 0; j < methp.size(); j++)
319 methpm.push_back(methp.at(j));
321 for(
unsigned int j = 0; j < methpm.size(); j++)
325 if(methpm.at(0)==this->classN)
327 refDef += (
"me.setReturnType(\"Constructor\");\n");
328 refDef += (
"me.setMethodName(\""+methpm.at(j)+
"\");\n");
332 refDef += (
"me.setReturnType(\""+methpm.at(j)+
"\");\n");
336 else if(j==1 && methpm.at(0)!=this->classN)
338 refDef += (
"me.setMethodName(\""+methpm.at(j)+
"\");\n");
342 else if(methpm.at(j)!=
"")
344 refDef += (
"argu.push_back(\""+methpm.at(j)+
"\");\n");
352 refDef += (
"me.setArgumentTypes(argu);\n");
353 refDef += (
"if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
355 else if(this->pub.at(i).find(
"~")==string::npos)
357 refDef += (
"f.clear();\n");
358 publf += this->pub.at(i);
359 fld = this->pub.at(i);
360 StringUtil::replaceFirst(fld,
";",
"");
362 StringUtil::split(fldp, fld, (
" "));
363 for(
unsigned int j = 0; j < fldp.size(); j++)
367 refDef += (
"f.setType(\""+fldp.at(j)+
"\");\n");
371 refDef += (
"f.setFieldName(\""+fldp.at(j)+
"\");\n");
375 structinf += (fldp.at(0)+
" "+fldp.at(1)+
";\n");
376 refDef += (
"if(f.getFieldName()!=\"\")\n{\nfldVec.push_back(f);\n}\n");
380 if (this->pri.size() > 0)
382 for (
unsigned int i = 0; i < this->pri.size(); i++)
384 if((tes=this->pri.at(i).find(
"("))!=string::npos && (tes=this->pri.at(i).find(
")"))!=string::npos && this->pri.at(i).find(
"~")==string::npos)
386 refDef += (
"me.clear();\n");
387 privm += this->pri.at(i);
388 meth = this->pri.at(i);
389 StringUtil::replaceFirst(meth,
";",
"");
390 StringUtil::replaceFirst(meth,
"(",
" ");
391 StringUtil::replaceAll(meth,
",",
" ");
392 StringUtil::replaceFirst(meth,
")",
" ");
394 StringUtil::split(methp, meth, (
" "));
395 for(
unsigned int j = 0; j < methp.size(); j++)
399 if(methp.at(0)==this->classN)
401 refDef += (
"me.setReturnType(\"Constructor\");\n");
402 refDef += (
"me.setMethodName(\""+methp.at(j)+
"\");\n");
405 refDef += (
"me.setReturnType(\""+methp.at(j)+
"\");\n");
407 else if(j==1 && methp.at(0)!=this->classN)
409 refDef += (
"me.setMethodName(\""+methp.at(j)+
"\");\n");
411 else if(methp.at(j)!=
"")
413 refDef += (
"argu.push_back(\""+methp.at(j)+
"\");\n");
416 refDef += (
"me.setArgumentTypes(argu);\n");
417 refDef += (
"if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
419 else if(this->pri.at(i).find(
"~")==string::npos)
421 refDef += (
"f.clear();\n");
422 privf += this->pri.at(i);
423 fld = this->pri.at(i);
424 StringUtil::replaceFirst(fld,
";",
"");
426 StringUtil::split(fldp, fld, (
" "));
427 for(
unsigned int j = 0; j < fldp.size(); j++)
431 refDef += (
"f.setType(\""+fldp.at(j)+
"\");\n");
435 refDef += (
"f.setFieldName(\""+fldp.at(j)+
"\");\n");
439 structinf += (fldp.at(0)+
" "+fldp.at(1)+
";\n");
440 refDef += (
"if(f.getFieldName()!=\"\")\n{\nfldVec.push_back(f);\n}\n");
444 if (this->pro.size() > 0)
446 for (
unsigned int i = 0; i < this->pro.size(); i++)
448 if((tes=this->pro.at(i).find(
"("))!=string::npos && (tes=this->pro.at(i).find(
")"))!=string::npos && this->pro.at(i).find(
"~")==string::npos)
450 refDef += (
"me.clear();\n");
451 protm += this->pro.at(i);
452 meth = this->pro.at(i);
453 StringUtil::replaceFirst(meth,
";",
"");
454 StringUtil::replaceFirst(meth,
"(",
" ");
455 StringUtil::replaceAll(meth,
",",
" ");
456 StringUtil::replaceFirst(meth,
")",
" ");
458 StringUtil::split(methp, meth, (
" "));
459 for(
unsigned int j = 0; j < methp.size(); j++)
463 if(methp.at(0)==this->classN)
465 refDef += (
"me.setReturnType(\"Constructor\");\n");
466 refDef += (
"me.setMethodName(\""+methp.at(j)+
"\");\n");
469 refDef += (
"me.setReturnType(\""+methp.at(j)+
"\");\n");
471 else if(j==1 && methp.at(0)!=this->classN)
473 refDef += (
"me.setMethodName(\""+methp.at(j)+
"\");\n");
475 else if(methp.at(j)!=
"")
477 refDef += (
"argu.push_back(\""+methp.at(j)+
"\");\n");
480 refDef += (
"me.setArgumentTypes(argu);\n");
481 refDef += (
"if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
483 else if(this->pro.at(i).find(
"~")==string::npos)
485 refDef += (
"f.clear();\n");
486 protf += this->pro.at(i);
487 fld = this->pro.at(i);
488 StringUtil::replaceFirst(fld,
";",
"");
490 StringUtil::split(fldp, fld, (
" "));
491 for(
unsigned int j = 0; j < fldp.size(); j++)
495 refDef += (
"f.setType(\""+fldp.at(j)+
"\");\n");
499 refDef += (
"f.setFieldName(\""+fldp.at(j)+
"\");\n");
503 structinf += (fldp.at(0)+
" "+fldp.at(1)+
";\n");
504 refDef += (
"if(f.getFieldName()!=\"\")\n{\nfldVec.push_back(f);\n}\n");
511 refDef +=
"\nreturn classInfo;\n}\n";
514 refDef = (typedefs + structinf + refDef);
518 string Reflection::updateTemplateContextDefinition(
string className,
bool file)
521 if (file && !generateClassInfo(className))
525 else if (!file && !generateClassInfoFromDD(className))
529 refDef =
"#include \"ClassInfo.h\"\n#include \"string\"\n";
530 refDef +=
"#include \"" + this->classN +
".h\"\n\n";
531 refDef +=
"extern \"C\"\n{\nClassInfo get" + this->classN +
"()\n{\nClassInfo classInfo;";
532 refDef += (
"\nclassInfo.setInstance(new " + this->classN +
");");
533 refDef +=
"\nreturn classInfo;\n}\n}";
538 propMap Reflection::getDbTableInfo(
string file)
544 infile.open(file.c_str());
547 while(getline(infile,temp))
552 for(
unsigned int i=0;i<(all.size()/2);i++)
554 tabInfo[all.at(i)] = all.at(i+1);
560 strVec Reflection::getAfcObjectData(
string className,
bool object,strVec& privf,
bool &isOpForSet)
564 if (!generateClassInfo(className))
568 strVec publf, protf ,publm, privm, protm;
571 if (this->pub.size() > 0)
573 for (
unsigned int i = 0; i < this->pub.size(); i++)
575 if((tes=this->pub.at(i).find(
"("))!=string::npos && (tes=this->pub.at(i).find(
")"))!=string::npos)
577 publm.push_back(this->pub.at(i));
579 string meth = pub.at(i);
580 StringUtil::replaceFirst(meth,
";",
"");
581 RegexUtil::replace(meth,
"[\t]+",
" ");
582 RegexUtil::replace(meth,
"[ ]+",
" ");
583 RegexUtil::replace(meth,
"[ ?, ?]+",
",");
584 meth = meth.substr(0,meth.find(
"("));
585 if(meth.find(
"operator")!=string::npos)
587 if(meth.find(
"<")!=string::npos)
591 else if(meth.find(
">")!=string::npos)
599 publf.push_back(this->pub.at(i));
603 if (this->pri.size() > 0)
605 for (
unsigned int i = 0; i < this->pri.size(); i++)
607 if((tes=this->pri.at(i).find(
"("))!=string::npos && (tes=this->pri.at(i).find(
")"))!=string::npos)
609 privm.push_back(this->pri.at(i));
613 privf.push_back(this->pri.at(i));
617 if (this->pro.size() > 0)
619 for (
unsigned int i = 0; i < this->pro.size(); i++)
621 if((tes=this->pro.at(i).find(
"("))!=string::npos && (tes=this->pro.at(i).find(
")"))!=string::npos)
623 protm.push_back(this->pro.at(i));
637 strVec Reflection::getAfcObjectData(
string className,
bool object)
640 if (!generateClassInfo(className))
644 strVec publf, privf, protf ,publm, privm, protm;
647 if (this->pub.size() > 0)
649 for (
unsigned int i = 0; i < this->pub.size(); i++)
651 if((tes=this->pub.at(i).find(
"("))!=string::npos && (tes=this->pub.at(i).find(
")"))!=string::npos)
653 publm.push_back(this->pub.at(i));
657 publf.push_back(this->pub.at(i));
661 if (this->pri.size() > 0)
663 for (
unsigned int i = 0; i < this->pri.size(); i++)
665 if((tes=this->pri.at(i).find(
"("))!=string::npos && (tes=this->pri.at(i).find(
")"))!=string::npos)
667 privm.push_back(this->pri.at(i));
671 if (this->pro.size() > 0)
673 for (
unsigned int i = 0; i < this->pro.size(); i++)
675 if((tes=this->pro.at(i).find(
"("))!=string::npos && (tes=this->pro.at(i).find(
")"))!=string::npos)
677 protm.push_back(this->pro.at(i));
691 string Reflection::generateClassDefinitionsAll(strVec all,
string &includeRef)
696 string typedefs,classes,methods,opers;
697 string inc =
"#include \"ClassInfo.h\"\n#include \"string\"\n#include \"Method.h\"\n#include \"Field.h\"\n";
698 ret +=
"extern \"C\"\n{\n";
699 for (
unsigned int var = 0; var < all.size(); ++var)
702 ret += this->generateClassDefinitions(all.at(var),inc,typedefs,classes,methods,opers);
713 ret += methods+opers+
"\n}\n";
718 string Reflection::generateClassDefinitions(
string includeDir,
string &includesDefs,
string &typedefs,
string &classes,
string &methods,
string &opers)
720 strVec includes = list(includeDir);
721 string ret,in,ty,cl,me;
722 for (
unsigned int var = 0; var < includes.size(); ++var)
725 string includesDefs1,typedefs1,classes1,methods1,opers1;
726 string ret1 = generateClassDefinition(includes.at(var),includesDefs1,typedefs1,classes1,methods1,opers1);
730 includesDefs += includesDefs1;
731 typedefs += typedefs1;
738 invalidcls[includes.at(var)] =
true;
745 string Reflection::generateClassDefinition(
string className,
string &includesDefs,
string &typedefs,
string &classes,
string &methods,
string &opers)
748 if (!generateClassInfo(className))
752 classes +=
"\tif(className==\""+this->classN+
"\")\n\t\treturn get"+this->classN+
"();\n";
753 includesDefs +=
"#include \"" + this->classN +
".h\"\n";
755 refDef +=
"ClassInfo getReflectionCIFor" + this->classN +
"()\n{\nClassInfo classInfo;";
756 refDef += (
"\nclassInfo.setClassName(\"" + this->classN +
"\");");
758 refDef += (
"\nclassInfo.setBase(\"" + this->bcvisib +
" " + this->baseClassN +
"\");");
759 refDef += (
"\nConstructor ctor;\nMethod me;\nField f;\n");
760 refDef += (
"args argu;\n");
761 string publf, privf, protf ,publm, privm, protm;
764 bool ctorisp =
false,ddtorisp =
false;;
765 if (this->pub.size() > 0)
767 for (
unsigned int i = 0; i < this->pub.size(); i++)
769 if((tes=this->pub.at(i).find(
"("))!=string::npos && (tes=this->pub.at(i).find(
")"))!=string::npos && this->pub.at(i).find(
"~")==string::npos)
771 refDef += (
"ctor.clear();\nme.clear();\n");
772 publm += this->pub.at(i);
773 meth = this->pub.at(i);
774 StringUtil::replaceFirst(meth,
";",
"");
776 string argts = meth.substr(meth.find(
"("),meth.find(
")")-meth.find(
"("));
777 StringUtil::replaceFirst(argts,
"(",
"");
778 StringUtil::replaceAll(argts,
")",
"");
779 meth = meth.substr(0,meth.find(
"("));
781 strVec methp,methpm,argp,argpm,argpmtemp;
782 StringUtil::split(argp, argts, (
","));
783 StringUtil::split(methp, meth, (
" "));
784 for(
unsigned int j = 0; j < methp.size(); j++)
787 methpm.push_back(methp.at(j));
789 for(
unsigned int j = 0; j < argp.size(); j++)
791 if(argp.at(j)!=
"" && argp.at(j)!=
"(")
793 string argpmtemp = argp.at(j);
794 argpmtemp = argpmtemp.substr(argpmtemp.find_first_not_of(
" "));
795 argpm.push_back(argpmtemp);
798 string typdefName,methsd,valsd,valsa;
800 if(methpm.size()>0 && methpm.at(0).find(
"virtual")!=string::npos)
802 for(
unsigned int j = 0; j < methpm.size(); j++)
806 if(methpm.at(0)==this->classN)
808 refDef += (
"ctor.setName(\""+this->classN+
"\");\n");
811 methsd += (this->classN);
813 else if(meth.find(
" operator")==string::npos)
815 refDef += (
"me.setReturnType(\""+methpm.at(j)+
"\");\n");
816 typedefs += (
"typedef " + methpm.at(j) +
" ");
819 else if(j==1 && methpm.at(0)!=this->classN && meth.find(
" operator")==string::npos)
823 typedefs += (
"("+this->classN+
"::*"+this->classN +methpm.at(j));
824 methsd += (this->classN+methpm.at(j));
845 bool tmpltarg =
false;
846 for(
unsigned int j = 0; j < argpm.size(); j++)
848 if(tmpltarg && argpm.at(j).find(
">")!=string::npos)
850 string ttt = argpmtemp.at(argpmtemp.size()-1)+
","+argpm.at(j);
851 argpmtemp.at(argpmtemp.size()-1) = ttt;
853 else if(argpm.at(j).find(
"<")!=string::npos)
855 argpmtemp.push_back(argpm.at(j));
860 argpmtemp.push_back(argpm.at(j));
864 for(
unsigned int j = 0; j < argpm.size(); j++)
868 if(argpm.at(j).find(
"*")!=string::npos)
870 else if(argpm.at(j).find(
"&")!=string::npos)
872 StringUtil::split(argtn, argpm.at(j), (
" "));
874 StringUtil::replaceAll(argtn.at(0),
" ",
"");
875 if(meth.find(
" operator")==string::npos)refDef += (
"argu.push_back(\""+argtn.at(0)+
"\");\n");
876 if(argtn.at(0).find(
"*")!=string::npos || type12==
"*")
878 StringUtil::replaceAll(argtn.at(0),
"*",
"");
879 valsd +=
"\t\t"+(argtn.at(0) +
" *_" + CastUtil::lexical_cast<
string>(j)+
" = ("+argtn.at(0)+
"*)values.at("+CastUtil::lexical_cast<
string>(j)+
");");
881 else if(argtn.at(0).find(
"&")!=string::npos || type12==
"&")
883 StringUtil::replaceAll(argtn.at(0),
"&",
"");
884 valsd +=
"\t\t"+(argtn.at(0) +
" *_" + CastUtil::lexical_cast<
string>(j)+
" = ("+argtn.at(0)+
"*)values.at("+CastUtil::lexical_cast<
string>(j)+
");");
887 valsd +=
"\t\t"+(argtn.at(0) +
" *_" + CastUtil::lexical_cast<
string>(j)+
" = ("+argtn.at(0)+
"*)values.at("+CastUtil::lexical_cast<
string>(j)+
");");
889 valsa +=
"_" + CastUtil::lexical_cast<
string>(j);
891 valsa +=
"*_" + CastUtil::lexical_cast<
string>(j);
894 typedefs += argtn.at(0);
895 typdefName += argtn.at(0);
896 methsd += argtn.at(0) + (type12==
"*"?
"ptr":
"");
897 if(j!=argpm.size()-1)
904 if(meth.find(
" operator")!=string::npos)
906 if(meth.find(
"<")!=string::npos)
908 opers +=
"\nvoid* operator"+this->classN+
"LT(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
909 if(methpm.at(0)==
"void")
912 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj<"+valsa+
";";
913 opers +=
"\n\treturn returnValue;";
917 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
919 opers +=
"\n\t*_retVal = (*_obj<"+valsa+
");";
920 opers +=
"\n\treturn _retVal;";
924 else if(meth.find(
">")!=string::npos)
926 opers +=
"\nvoid* operator"+this->classN+
"GT(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
927 if(methpm.at(0)==
"void")
930 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj>"+valsa+
";";
931 opers +=
"\n\treturn returnValue;";
935 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
937 opers +=
"\n\t*_retVal = (*_obj>"+valsa+
");";
938 opers +=
"\n\treturn _retVal;";
942 else if(meth.find(
"==")!=string::npos)
944 opers +=
"\nvoid* operator"+this->classN+
"EQ(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
945 if(methpm.at(0)==
"void")
948 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj=="+valsa+
";";
949 opers +=
"\n\treturn returnValue;";
953 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
955 opers +=
"\n\t*_retVal = (*_obj=="+valsa+
");";
956 opers +=
"\n\treturn _retVal;";
960 else if(meth.find(
"!=")!=string::npos)
962 opers +=
"\nvoid* operator"+this->classN+
"NE(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
963 if(methpm.at(0)==
"void")
966 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj!="+valsa+
";";
967 opers +=
"\n\treturn returnValue;";
971 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
973 opers +=
"\n\t*_retVal = (*_obj!="+valsa+
");";
974 opers +=
"\n\treturn _retVal;";
978 else if(meth.find(
"<=")!=string::npos)
980 opers +=
"\nvoid* operator"+this->classN+
"LE(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
981 if(methpm.at(0)==
"void")
984 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj<="+valsa+
";";
985 opers +=
"\n\treturn returnValue;";
989 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
991 opers +=
"\n\t*_retVal = (*_obj<="+valsa+
");";
992 opers +=
"\n\treturn _retVal;";
996 else if(meth.find(
">=")!=string::npos)
998 opers +=
"\nvoid* operator"+this->classN+
"GT(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
999 if(methpm.at(0)==
"void")
1002 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj>="+valsa+
";";
1003 opers +=
"\n\treturn returnValue;";
1007 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
1009 opers +=
"\n\t*_retVal = (*_obj>="+valsa+
");";
1010 opers +=
"\n\treturn _retVal;";
1014 else if(meth.find(
"!")!=string::npos)
1016 opers +=
"\nvoid* operator"+this->classN+
"NT(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
1017 if(methpm.at(0)==
"void")
1020 opers +=
"\n\tvoid* returnValue=NULL;\n\t!*_obj;";
1021 opers +=
"\n\treturn returnValue;";
1025 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
1027 opers +=
"\n\t*_retVal = (!*_obj);";
1028 opers +=
"\n\treturn _retVal;";
1032 else if(meth.find(
"<<")!=string::npos)
1036 else if(meth.find(
">>")!=string::npos)
1040 else if(meth.find(
"+")!=string::npos)
1042 opers +=
"\nvoid* operator"+this->classN+
"AD(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
1043 if(methpm.at(0)==
"void")
1046 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj+"+valsa+
";";
1047 opers +=
"\n\treturn returnValue;";
1051 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
1053 opers +=
"\n\t*_retVal = (*_obj+"+valsa+
");";
1054 opers +=
"\n\treturn _retVal;";
1058 else if(meth.find(
"-")!=string::npos)
1060 opers +=
"\nvoid* operator"+this->classN+
"SU(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
1061 if(methpm.at(0)==
"void")
1064 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj-"+valsa+
";";
1065 opers +=
"\n\treturn returnValue;";
1069 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
1071 opers +=
"\n\t*_retVal = (*_obj-"+valsa+
");";
1072 opers +=
"\n\treturn _retVal;";
1076 else if(meth.find(
"/")!=string::npos)
1078 opers +=
"\nvoid* operator"+this->classN+
"DI(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
1079 if(methpm.at(0)==
"void")
1082 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj/"+valsa+
";";
1083 opers +=
"\n\treturn returnValue;";
1087 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
1089 opers +=
"\n\t*_retVal = (*_obj/"+valsa+
");";
1090 opers +=
"\n\treturn _retVal;";
1094 else if(meth.find(
"*")!=string::npos)
1096 opers +=
"\nvoid* operator"+this->classN+
"MU(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
1097 if(methpm.at(0)==
"void")
1100 opers +=
"\n\tvoid* returnValue=NULL;\n\t*_obj*"+valsa+
";";
1101 opers +=
"\n\treturn returnValue;";
1105 opers +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
1107 opers +=
"\n\t*_retVal = (*_obj*"+valsa+
");";
1108 opers +=
"\n\treturn _retVal;";
1112 else if(meth.find(
"&&")!=string::npos)
1116 else if(meth.find(
"&")!=string::npos)
1120 else if(meth.find(
"||")!=string::npos)
1124 else if(meth.find(
"|")!=string::npos)
1128 else if(meth.find(
"[")!=string::npos && meth.find(
"]")!=string::npos)
1132 else if(meth.find(
"(")!=string::npos && meth.find(
")")!=string::npos)
1139 StringUtil::replaceFirst(methsd,
"<",
"ts");
1140 StringUtil::replaceFirst(methsd,
"<",
"ts");
1141 StringUtil::replaceFirst(methsd,
">",
"te");
1142 StringUtil::replaceFirst(methsd,
",",
"");
1143 if(methsd.find(
"std::")!=string::npos)
1145 StringUtil::replaceFirst(methsd,
"std::",
"");
1147 else if(methsd.find(
"::")!=string::npos)
1149 StringUtil::replaceFirst(methsd,
"::",
"ns");
1153 if(methpm.at(0)!=this->classN)
1155 typedefs += (
") ("+typdefName+
");\n");
1156 methods +=
"\nvoid* invokeReflectionCIMethodFor"+methsd+
"(void* instance,vals values)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n";
1157 if(methpm.at(0)==
"void")
1160 methods +=
"\n\tvoid* returnValue=NULL;\n\t_obj->"+methpm.at(1)+
"("+valsa+
");";
1161 methods +=
"\n\treturn returnValue;";
1165 methods +=
"\n\t"+methpm.at(0)+
" *_retVal=new "+methpm.at(0)+
";\n";
1167 methods +=
"\n\t*_retVal = (_obj->"+methpm.at(1)+
"("+valsa+
"));";
1168 methods +=
"\n\treturn _retVal;";
1171 refDef += (
"me.setMethodName(\""+methsd+
"\");\n");
1172 methsall[methsd] =
true;
1173 refDef += (
"me.setArgumentTypes(argu);\n");
1174 refDef += (
"argu.clear();\n");
1175 refDef += (
"if(me.getMethodName()!=\"\")\n{\nclassInfo.addMethod(me);\n}\n");
1179 typedefs += (
") ("+typdefName+
");\n");
1180 methods +=
"\nvoid* invokeReflectionCICtorFor"+methsd+
"(vals values)\n{";
1181 methods +=
"\n\t"+this->classN+
" *_retVal = NULL;\n";
1183 methods +=
"\n\t_retVal = (new "+this->classN+
"("+valsa+
"));";
1184 methods +=
"\n\treturn _retVal;";
1186 refDef += (
"ctor.setName(\""+methsd+
"\");\n");
1187 refDef += (
"ctor.setArgumentTypes(argu);\n");
1188 refDef += (
"argu.clear();\n");
1189 refDef += (
"classInfo.addConstructor(ctor);\n");
1194 else if(this->pub.at(i).find(
"~")==string::npos)
1196 refDef += (
"f.clear();\n");
1197 publf += this->pub.at(i);
1198 fld = this->pub.at(i);
1199 StringUtil::replaceFirst(fld,
";",
"");
1201 StringUtil::split(fldp, fld, (
" "));
1204 for(
unsigned int j = 0; j < fldp.size(); j++)
1208 refDef += (
"f.setType(\""+fldp.at(j)+
"\");\n");
1212 refDef += (
"f.setFieldName(\""+fldp.at(j)+
"\");\n");
1217 methods +=
"\n"+fldp.at(0)+
" invokeReflectionCIFieldFor"+this->classN+fldp.at(1)+
"(void* instance)\n{\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n\treturn _obj->"+fldp.at(1)+
";\n}\n";
1218 refDef += (
"if(f.getFieldName()!=\"\")\n{\nclassInfo.addField(f);\n}\n");
1225 else if(this->pub.at(i).find(
"~")!=string::npos)
1227 methods +=
"\nvoid invokeReflectionCIDtorFor"+this->classN+
"(void* instance)\n{";
1228 methods +=
"\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n\t";
1229 methods +=
"_obj->~"+this->classN+
"();";
1236 refDef += (
"ctor.setName(\""+this->classN+
"\");\n");
1237 refDef += (
"argu.clear();\n");
1238 methods +=
"\nvoid* invokeReflectionCICtorFor"+this->classN+
"(vals values)\n{";
1239 methods +=
"\n\t"+this->classN+
" *_retVal = NULL;\n";
1240 methods +=
"\n\t_retVal = (new "+this->classN+
"());";
1241 methods +=
"\n\treturn _retVal;";
1243 refDef += (
"ctor.setArgumentTypes(argu);\n");
1244 refDef += (
"argu.clear();\n");
1245 refDef += (
"classInfo.addConstructor(ctor);\n");
1249 methods +=
"\nvoid invokeReflectionCIDtorFor"+this->classN+
"(void* instance)\n{";
1250 methods +=
"\n\t"+this->classN+
" *_obj = ("+this->classN+
"*)instance;\n\t";
1251 methods +=
"_obj->~"+this->classN+
"();";
1256 if (this->pri.size() > 0)
1258 for (
unsigned int i = 0; i < this->pri.size(); i++)
1260 if((tes=this->pri.at(i).find(
"("))!=string::npos && (tes=this->pri.at(i).find(
")"))!=string::npos && this->pri.at(i).find(
"~")==string::npos)
1263 privm += this->pri.at(i);
1264 meth = this->pri.at(i);
1265 StringUtil::replaceFirst(meth,
";",
"");
1266 StringUtil::replaceFirst(meth,
"(",
" ");
1267 StringUtil::replaceAll(meth,
",",
" ");
1268 StringUtil::replaceFirst(meth,
")",
" ");
1270 StringUtil::split(methp, meth, (
" "));
1271 for(
unsigned int j = 0; j < methp.size(); j++)
1275 if(methp.at(0)==this->classN)
1285 else if(j==1 && methp.at(0)!=this->classN)
1289 else if(methp.at(j)!=
"")
1297 else if(this->pri.at(i).find(
"~")==string::npos)
1299 refDef += (
"f.clear();\n");
1300 privf += this->pri.at(i);
1301 fld = this->pri.at(i);
1302 StringUtil::replaceFirst(fld,
";",
"");
1304 StringUtil::split(fldp, fld, (
" "));
1307 for(
unsigned int j = 0; j < fldp.size(); j++)
1311 refDef += (
"f.setType(\""+fldp.at(j)+
"\");\n");
1315 refDef += (
"f.setFieldName(\""+fldp.at(j)+
"\");\n");
1322 refDef += (
"if(f.getFieldName()!=\"\")\n{\nclassInfo.addField(f);\n}\n");
1331 if (this->pro.size() > 0)
1333 for (
unsigned int i = 0; i < this->pro.size(); i++)
1335 if((tes=this->pro.at(i).find(
"("))!=string::npos && (tes=this->pro.at(i).find(
")"))!=string::npos && this->pro.at(i).find(
"~")==string::npos)
1338 protm += this->pro.at(i);
1339 meth = this->pro.at(i);
1340 StringUtil::replaceFirst(meth,
";",
"");
1341 StringUtil::replaceFirst(meth,
"(",
" ");
1342 StringUtil::replaceAll(meth,
",",
" ");
1343 StringUtil::replaceFirst(meth,
")",
" ");
1345 StringUtil::split(methp, meth, (
" "));
1346 for(
unsigned int j = 0; j < methp.size(); j++)
1350 if(methp.at(0)==this->classN)
1360 else if(j==1 && methp.at(0)!=this->classN)
1364 else if(methp.at(j)!=
"")
1372 else if(this->pro.at(i).find(
"~")==string::npos)
1374 refDef += (
"f.clear();\n");
1375 protf += this->pro.at(i);
1376 fld = this->pro.at(i);
1377 StringUtil::replaceFirst(fld,
";",
"");
1379 StringUtil::split(fldp, fld, (
" "));
1382 for(
unsigned int j = 0; j < fldp.size(); j++)
1386 refDef += (
"f.setType(\""+fldp.at(j)+
"\");\n");
1390 refDef += (
"f.setFieldName(\""+fldp.at(j)+
"\");\n");
1397 refDef += (
"if(f.getFieldName()!=\"\")\n{\nclassInfo.addField(f);\n}\n");
1409 refDef +=
"\nreturn classInfo;\n}\n";
1410 refDef +=
"\nvoid invokeAdToVecFor"+this->classN+
"(void* _vec,void* _instance){"+this->classN+
" *_obj = ("+this->classN+
"*)_instance;vector<"+this->classN+
"> *_objvec = (vector<"+this->classN+
"> *)_vec;_objvec->push_back(*_obj);}";
1411 refDef +=
"\nvoid* invokeGetNewVecFor"+this->classN+
"(){vector<"+this->classN+
"> *_objvec = new vector<"+this->classN+
">;return _objvec;}";
1412 refDef +=
"\nint invokeGetVecSizeFor"+this->classN+
"(void* _vec){vector<"+this->classN+
"> *_objvec = (vector<"+this->classN+
">*)_vec;return (int)_objvec->size();}";
1413 refDef +=
"\nvoid* invokeGetVecElementFor"+this->classN+
"(void* _vec,int pos){vector<"+this->classN+
"> *_objvec = (vector<"+this->classN+
">*)_vec;return &(_objvec->at(pos));}";
1418 string Reflection::generateSerDefinitionAll(strVec all,
string &includeRef,
bool isBinary,
string& objs,
string& ajaxret,
string& headers,
string& typerefs)
1420 string ret =
"#include \"XmlParser.h\"\n#include \"CastUtil.h\"\n#include \"AMEFResources.h\"\n#include \"Serialize.h\"\n#include \"XMLSerialize.h\"\n";
1421 includeRef =
"#include \"Reflector.h\"\n#include \"vector\"\n#include \"list\"\n#include \"queue\"\n#include \"deque\"\n#include \"set\"\n#include \"DateFormat.h\"\n" ;
1422 includeRef =
"#include \"CastUtil.h\"\n#include \"JSONUtil.h\"\n#include \"sstream\"\n#include \"CastUtil.h\"\n#include <algorithm>\n";
1423 string typedefs,classes,methods,rert1;
1424 for (
unsigned int var = 0; var < all.size(); ++var)
1426 rert1 += this->generateSerDefinitions(all.at(var),includeRef,typedefs,classes,methods,isBinary,objs,ajaxret,headers,typerefs);
1428 includeRef += (
"extern \"C\"{\n" + classes + typedefs + methods);
1431 includeRef += typedefs;
1435 string Reflection::generateSerDefinitions(
string includeDir,
string &includesDefs,
string &typedefs,
string &classes,
string &methods,
bool isBinary,
1436 string& objs,
string &ajaxret,
string& headers,
string& typerefs)
1438 strVec includes = list(includeDir);
1440 for (
unsigned int var = 0; var < includes.size(); ++var)
1443 if(invalidcls.find(includes.at(var))==invalidcls.end())
1445 ret = generateSerDefinition(includes.at(var),includesDefs,typedefs,classes,methods);
1446 ret += generateSerDefinitionBinary(includes.at(var),includesDefs,typedefs,classes,methods);
1448 bool isOpForSet =
false;
1449 strVec minfo = getAfcObjectData(includes.at(var),
false,pinfo,isOpForSet);
1451 strVec info = getAfcObjectData(includes.at(var),
true,pinfo,isOpForSet);
1452 ajaxret += AfcUtil::generateJsObjects(info,this->classN,headers,includeDir,objs,pinfo,isOpForSet,typerefs,minfo);
1459 string Reflection::generateSerDefinition(
string className,
string &includesDefs,
string &typedefs,
string &classes,
string &methods)
1463 if (!generateClassInfo(className))
1470 includesDefs +=
"#include \"" + this->classN +
".h\"\n";
1472 classes +=
"\nstring serialize" + this->classN +
"(void* obje);\nvoid* unSerialize" + this->classN +
"(string objXml);";
1473 methods +=
"\nstring serialize" + this->classN +
"(void* obje)\n{\n"+this->classN+
" *__obj=("+this->classN+
"*)obje;\n";
1474 methods +=
"string objxml = \"<"+this->classN+
">\";\n";
1475 typedefs +=
"\nvoid* unSerialize" + this->classN +
"(string objXml)\n{\n";
1476 typedefs += this->classN+
" *__obj=new "+this->classN+
";\nXmlParser parser(\"Parser\");\nElement root = parser.getDocument(objXml).getRootElement();\nif(root.getTagName()==\"\" && root.getChildElements().size()==0)\nreturn NULL;\n";
1477 typedefs +=
"for(unsigned int i=0;i<root.getChildElements().size();i++)\n{\n";
1478 typedefs +=
"string nam=root.getChildElements().at(i).getTagName();\n";
1480 string publf, privf, protf ,publm, privm, protm;
1484 if (this->pri.size() > 0)
1486 for (
unsigned int i = 0; i < this->pri.size(); i++)
1488 if(((tes=this->pri.at(i).find(
"("))==string::npos && (tes=this->pri.at(i).find(
")"))==string::npos && this->pri.at(i).find(
"~")==string::npos))
1490 fld = this->pri.at(i);
1491 StringUtil::replaceFirst(fld,
";",
"");
1493 StringUtil::split(fldp, fld, (
" "));
1496 string nam = fldp.at(1);
1497 fldnames.push_back(fldp.at(0));
1498 fldnames.push_back(nam);
1503 if (this->pro.size() > 0)
1505 for (
unsigned int i = 0; i < this->pro.size(); i++)
1507 if(((tes=this->pro.at(i).find(
"("))==string::npos && (tes=this->pro.at(i).find(
")"))==string::npos && this->pro.at(i).find(
"~")==string::npos))
1509 fld = this->pro.at(i);
1510 StringUtil::replaceFirst(fld,
";",
"");
1512 StringUtil::split(fldp, fld, (
" "));
1515 string nam = fldp.at(1);
1516 fldnames.push_back(fldp.at(0));
1517 fldnames.push_back(nam);
1522 if (this->pub.size() > 0)
1524 for (
unsigned int i = 0; i < this->pub.size(); i++)
1526 if(((tes=this->pub.at(i).find(
"("))==string::npos && (tes=this->pub.at(i).find(
")"))==string::npos && this->pub.at(i).find(
"~")==string::npos))
1529 RegexUtil::replace(fld,
"[\t]+",
" ");
1530 RegexUtil::replace(fld,
"[ ]+",
" ");
1531 RegexUtil::replace(fld,
"[ ?, ?]+",
",");
1532 StringUtil::replaceFirst(fld,
";",
"");
1534 if(fld.find(
"*")!=string::npos)
1537 StringUtil::replaceFirst(fld,
"*",
"");
1539 vector<string> fldp;
1540 StringUtil::split(fldp, fld, (
" "));
1543 string nam = fldp.at(1);
1544 if(fldp.at(0)==
"int" || fldp.at(0)==
"long" || fldp.at(0)==
"short" || fldp.at(0)==
"float" ||
1545 fldp.at(0)==
"string" || fldp.at(0)==
"std::string" || fldp.at(0)==
"double" || fldp.at(0)==
"bool")
1549 methods += (
"objxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+CastUtil::lexical_cast<string>(__obj->"+fldp.at(1)+
")");
1550 string cam = AfcUtil::camelCased(fldp.at(1));
1551 methods += (
"+\"</"+nam+
">\";\n");
1552 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = CastUtil::lexical_cast<"+fldp.at(0)+
">(root.getChildElements().at(i).getText());\n";
1556 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)objxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+CastUtil::lexical_cast<string>(*__obj->"+fldp.at(1)+
")");
1557 string cam = AfcUtil::camelCased(fldp.at(1));
1558 methods += (
"+\"</"+nam+
">\";\n");
1559 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = new "+fldp.at(0)+
"(CastUtil::lexical_cast<"+fldp.at(0)+
">(root.getChildElements().at(i).getText()));\n";
1562 else if(fldp.at(0)==
"Date")
1566 methods += (
"DateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\nobjxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+formt"+fldp.at(1)+
".format(__obj->"+fldp.at(1)+
")");
1567 string cam = AfcUtil::camelCased(fldp.at(1));
1568 methods += (
"+\"</"+nam+
">\";\n");
1569 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n{\nDateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+fldp.at(1)+
" = *(formt"+fldp.at(1)+
".parse(root.getChildElements().at(i).getText()));\n}\n";
1573 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL){DateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\nobjxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+formt"+fldp.at(1)+
".format(*__obj->"+fldp.at(1)+
")");
1574 string cam = AfcUtil::camelCased(fldp.at(1));
1575 methods += (
"+\"</"+nam+
">\";}\n");
1576 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n{\nDateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+fldp.at(1)+
" = (formt"+fldp.at(1)+
".parse(root.getChildElements().at(i).getText()));\n}\n";
1579 else if(fldp.at(0)==
"BinaryData")
1583 methods += (
"objxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+BinaryData::serilaize(__obj->"+fldp.at(1)+
")");
1584 string cam = AfcUtil::camelCased(fldp.at(1));
1585 methods += (
"+\"</"+nam+
">\";\n");
1586 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = *(BinaryData::unSerilaize(root.getChildElements().at(i).getText()));\n";
1590 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)objxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+BinaryData::serilaize(*__obj->"+fldp.at(1)+
")");
1591 string cam = AfcUtil::camelCased(fldp.at(1));
1592 methods += (
"+\"</"+nam+
">\";\n");
1593 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = (BinaryData::unSerilaize(root.getChildElements().at(i).getText()));\n";
1596 else if(fldp.at(0).find(
"vector")!=string::npos || fldp.at(0).find(
"queue")!=string::npos || fldp.at(0).find(
"deque")!=string::npos || fldp.at(0).find(
"set")!=string::npos || fldp.at(0).find(
"list")!=string::npos)
1598 string stlcnt = fldp.at(0);
1599 string stltyp = fldp.at(0);
1601 StringUtil::replaceFirst(stltyp,
"std::",
"");
1602 StringUtil::replaceFirst(stltyp,
"<",
"::");
1603 StringUtil::replaceFirst(stltyp,
">",
"");
1604 StringUtil::replaceFirst(stltyp,
" ",
"");
1605 string stlcnttyp =
"";
1606 if(fldp.at(0).find(
"vector")!=string::npos)
1608 contType =
"std::vector<";
1611 else if(fldp.at(0).find(
"queue")!=string::npos)
1613 contType =
"std::queue<";
1616 else if(fldp.at(0).find(
"deque")!=string::npos)
1618 contType =
"std::deque<";
1621 else if(fldp.at(0).find(
"list")!=string::npos)
1623 contType =
"std::list<";
1626 else if(fldp.at(0).find(
"multiset")!=string::npos)
1628 contType =
"std::multiset<";
1629 stlcnttyp =
"MulSet";
1633 contType =
"std::set<";
1636 StringUtil::replaceFirst(stlcnt,
"std::",
"");
1637 StringUtil::replaceFirst(stlcnt,
"vector",
"");
1638 StringUtil::replaceFirst(stlcnt,
"queue",
"");
1639 StringUtil::replaceFirst(stlcnt,
"deque",
"");
1640 StringUtil::replaceFirst(stlcnt,
"multiset",
"");
1641 StringUtil::replaceFirst(stlcnt,
"set",
"");
1642 StringUtil::replaceFirst(stlcnt,
"list",
"");
1643 StringUtil::replaceFirst(stlcnt,
"<",
"");
1644 StringUtil::replaceFirst(stlcnt,
">",
"");
1645 StringUtil::replaceFirst(stlcnt,
" ",
"");
1647 contType += stlcnt +
",";
1651 methods += (fldp.at(0)+
" __temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
1652 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1653 methods += (
"objxml += \"<"+fldp.at(1)+
" type=\\\""+stltyp+
"\\\">\"+XMLSerialize::serialize<"+fldp.at(0)+
" >(__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
")");
1655 methods += (
"objxml += \"<"+fldp.at(1)+
" type=\\\""+stltyp+
"\\\">\"+serialize"+stlcnt+stlcnttyp+
"(&__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
")");
1656 string cam = AfcUtil::camelCased(fldp.at(1));
1657 methods += (
"+\"</"+nam+
">\";\n");
1658 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1659 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = XMLSerialize::unserialize<"+fldp.at(0)+
" >(root.getChildElements().at(i).renderChildren());\n";
1661 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = *("+fldp.at(0)+
"*)unSerialize"+stlcnt+stlcnttyp+
"(root.getChildElements().at(i).renderChildren());\n";
1665 methods += (fldp.at(0)+
"* __temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
1666 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1667 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)objxml += \"<"+fldp.at(1)+
" type=\\\""+stltyp+
"\\\">\"+XMLSerialize::serialize<"+fldp.at(0)+
" >(*__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
")");
1669 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)objxml += \"<"+fldp.at(1)+
" type=\\\""+stltyp+
"\\\">\"+serialize"+stlcnt+stlcnttyp+
"(__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
")");
1670 string cam = AfcUtil::camelCased(fldp.at(1));
1671 methods += (
"+\"</"+nam+
">\";\n");
1672 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1673 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = ("+fldp.at(0)+
"*)XMLSerialize::unSerializeUnknown(root.getChildElements().at(i).renderChildren(),\""+contType+
"\");\n";
1675 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = ("+fldp.at(0)+
"*)unSerialize"+stlcnt+stlcnttyp+
"(root.getChildElements().at(i).renderChildren());\n";
1682 methods += (fldp.at(0)+
" __temp_obj_ser"+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
1683 methods += (
"objxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+serialize"+fldp.at(0)+
"(&__temp_obj_ser"+fldp.at(1)+
")");
1684 string cam = AfcUtil::camelCased(fldp.at(1));
1685 methods += (
"+\"</"+nam+
">\";\n");
1686 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = *("+fldp.at(0)+
"*)unSerialize"+fldp.at(0)+
"(root.getChildElements().at(i).renderChildren());\n";
1690 methods += (fldp.at(0)+
"* __temp_obj_ser"+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
1691 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)objxml += \"<"+fldp.at(1)+
" type=\\\""+fldp.at(0)+
"\\\">\"+serialize"+fldp.at(0)+
"(__temp_obj_ser"+fldp.at(1)+
")");
1692 string cam = AfcUtil::camelCased(fldp.at(1));
1693 methods += (
"+\"</"+nam+
">\";\n");
1694 typedefs +=
"if(nam==\""+fldp.at(1)+
"\")\n__obj->"+fldp.at(1)+
" = ("+fldp.at(0)+
"*)unSerialize"+fldp.at(0)+
"(root.getChildElements().at(i).renderChildren());\n";
1700 if((tes=this->pub.at(i).find(
"("))!=string::npos && (tes=this->pub.at(i).find(
")"))!=string::npos && this->pub.at(i).find(
"~")==string::npos
1701 && fldnames.size()>0)
1704 StringUtil::replaceFirst(meth,
";",
"");
1705 RegexUtil::replace(meth,
"[\t]+",
" ");
1706 RegexUtil::replace(meth,
"[ ]+",
" ");
1707 RegexUtil::replace(meth,
"[ ?, ?]+",
",");
1709 if(meth.find(
"*")!=string::npos)
1712 StringUtil::replaceFirst(meth,
"*",
"");
1715 string argts = meth.substr(meth.find(
"("),meth.find(
")")-meth.find(
"("));
1716 StringUtil::replaceFirst(argts,
"(",
"");
1717 StringUtil::replaceAll(argts,
")",
"");
1718 meth = meth.substr(0,meth.find(
"("));
1720 if(meth.find(
"operator")!=string::npos)
1722 if(meth.find(
"<")!=string::npos)
1726 else if(meth.find(
">")!=string::npos)
1734 strVec methp,methpm,argp,argpm;
1735 StringUtil::split(argp, argts, (
","));
1736 StringUtil::split(methp, meth, (
" "));
1737 for(
unsigned int j = 0; j < methp.size(); j++)
1740 methpm.push_back(methp.at(j));
1742 for(
unsigned int j = 0; j < argp.size(); j++)
1744 if(argp.at(j)!=
"" && argp.at(j)!=
"(")
1746 string tty = argp.at(j);
1747 StringUtil::trim(tty);
1748 if(tty.find(
" ")!=string::npos)
1750 vector<string> temargt = StringUtil::split(tty,
" ");
1751 argpm.push_back(temargt.at(0));
1755 argpm.push_back(tty);
1760 if(methpm.at(0)!=this->classN)
1762 for(
unsigned int k = 0; k < fldnames.size(); k=k+2)
1764 string cam = AfcUtil::camelCased(fldnames.at(k+1));
1765 if(
"set"+cam==methpm.at(1) && argpm.size()==1 && argpm.at(0)==fldnames.at(k) && methpm.at(0)==
"void")
1767 if(argpm.at(0)==
"int" || argpm.at(0)==
"long" || argpm.at(0)==
"short" || argpm.at(0)==
"float" || argpm.at(0)==
"string" ||
1768 argpm.at(0)==
"std::string" || argpm.at(0)==
"double" || argpm.at(0)==
"bool")
1771 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->"+methpm.at(1)+
"(CastUtil::lexical_cast<"+argpm.at(0)+
">(root.getChildElements().at(i).getText()));\n";
1773 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->"+methpm.at(1)+
"(new "+argpm.at(0)+
"(CastUtil::lexical_cast<"+argpm.at(0)+
">(root.getChildElements().at(i).getText())));\n";
1775 else if(argpm.at(0)==
"Date")
1778 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n{\nDateFormat formt"+cam+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+methpm.at(1)+
"(*(formt"+cam+
".parse(root.getChildElements().at(i).getText())));\n}\n";
1780 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n{\nDateFormat formt"+cam+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+methpm.at(1)+
"((formt"+cam+
".parse(root.getChildElements().at(i).getText())));\n}\n";
1782 else if(argpm.at(0)==
"BinaryData")
1785 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->"+methpm.at(1)+
"(*(BinaryData::unSerilaize(root.getChildElements().at(i).getText())));\n";
1787 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->"+methpm.at(1)+
"((BinaryData::unSerilaize(root.getChildElements().at(i).getText())));\n";
1789 else if(argpm.at(0).find(
"vector")!=string::npos || argpm.at(0).find(
"queue")!=string::npos ||
1790 argpm.at(0).find(
"deque")!=string::npos || argpm.at(0).find(
"set")!=string::npos ||
1791 argpm.at(0).find(
"list")!=string::npos || argpm.at(0).find(
"multiset")!=string::npos)
1793 string stlcnt = argpm.at(0);
1794 string stltyp = argpm.at(0);
1796 StringUtil::replaceFirst(stltyp,
"std::",
"");
1797 StringUtil::replaceFirst(stltyp,
"<",
"::");
1798 StringUtil::replaceFirst(stltyp,
">",
"");
1799 StringUtil::replaceFirst(stltyp,
" ",
"");
1800 string stlcnttyp =
"";
1801 if(argpm.at(0).find(
"vector")!=string::npos)
1803 contType =
"std::vector<";
1806 else if(argpm.at(0).find(
"queue")!=string::npos)
1808 contType =
"std::queue<";
1811 else if(argpm.at(0).find(
"deque")!=string::npos)
1813 contType =
"std::deque<";
1816 else if(argpm.at(0).find(
"list")!=string::npos)
1818 contType =
"std::list<";
1821 else if(argpm.at(0).find(
"multiset")!=string::npos)
1823 contType =
"std::multiset<";
1824 stlcnttyp =
"MulSet";
1828 contType =
"std::set<";
1831 StringUtil::replaceFirst(stlcnt,
"std::",
"");
1832 StringUtil::replaceFirst(stlcnt,
"vector",
"");
1833 StringUtil::replaceFirst(stlcnt,
"queue",
"");
1834 StringUtil::replaceFirst(stlcnt,
"deque",
"");
1835 StringUtil::replaceFirst(stlcnt,
"multiset",
"");
1836 StringUtil::replaceFirst(stlcnt,
"set",
"");
1837 StringUtil::replaceFirst(stlcnt,
"list",
"");
1838 StringUtil::replaceFirst(stlcnt,
"<",
"");
1839 StringUtil::replaceFirst(stlcnt,
">",
"");
1840 StringUtil::replaceFirst(stlcnt,
" ",
"");
1842 contType += stlcnt +
",";
1846 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\"){";
1847 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" ||
1848 stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1849 typedefs +=
"\n__obj->set"+cam+
"(XMLSerialize::unserialize<"+argpm.at(0)+
" >(root.getChildElements().at(i).renderChildren()));\n";
1851 typedefs +=
"\n__obj->set"+cam+
"(*("+argpm.at(0)+
"*)unSerialize"+stlcnt+stlcnttyp+
"(root.getChildElements().at(i).renderChildren()));\n";
1852 typedefs +=
"\n}\n";
1856 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\"){";
1857 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" ||
1858 stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1859 typedefs +=
"\n__obj->set"+cam+
"(("+argpm.at(0)+
"*)XMLSerialize::unSerializeUnknown(root.getChildElements().at(i).renderChildren(),\""+contType+
"\"));\n";
1861 typedefs +=
"\n__obj->set"+cam+
"(("+argpm.at(0)+
"*)unSerialize"+stlcnt+stlcnttyp+
"(root.getChildElements().at(i).renderChildren()));\n";
1862 typedefs +=
"\n}\n";
1868 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->"+methpm.at(1)+
"(*("+argpm.at(0)+
"*)unSerialize"+argpm.at(0)+
"(root.getChildElements().at(i).renderChildren()));\n";
1870 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->"+methpm.at(1)+
"(("+argpm.at(0)+
"*)unSerialize"+argpm.at(0)+
"(root.getChildElements().at(i).renderChildren()));\n";
1873 else if(
"get"+cam==methpm.at(1) && argpm.size()==0 && methpm.at(0)==fldnames.at(k))
1875 if(methpm.at(0)==
"int" || methpm.at(0)==
"short" || methpm.at(0)==
"long" || methpm.at(0)==
"float" ||
1876 methpm.at(0)==
"string" || methpm.at(0)==
"std::string" || methpm.at(0)==
"double" || methpm.at(0)==
"bool")
1880 methods += (
"objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+CastUtil::lexical_cast<string>(__obj->"+methpm.at(1)+
"())");
1881 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1882 if(methsall[this->classN+
"get"+cam+methpm.at(0)])typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->set"+cam+
"(CastUtil::lexical_cast<"+methpm.at(0)+
">(root.getChildElements().at(i).getText()));\n";
1886 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+CastUtil::lexical_cast<string>(*__obj->"+methpm.at(1)+
"())");
1887 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1888 if(methsall[this->classN+
"get"+cam+methpm.at(0)])typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->set"+cam+
"(new "+methpm.at(0)+
"(CastUtil::lexical_cast<"+methpm.at(0)+
">(root.getChildElements().at(i).getText())));\n";
1891 else if(methpm.at(0)==
"Date")
1895 methods += (
"DateFormat formt"+fldnames.at(k+1)+
"(\"yyyy-mm-dd hh:mi:ss\");\nobjxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+formt"+fldnames.at(k+1)+
".format(__obj->"+methpm.at(1)+
"())");
1896 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1897 if(methsall[this->classN+
"get"+cam+methpm.at(0)])typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n{\nDateFormat formt"+fldnames.at(k+1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->set"+cam+
"(*(formt"+fldnames.at(k+1)+
".parse(root.getChildElements().at(i).getText())));\n}\n";
1901 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL){DateFormat formt"+fldnames.at(k+1)+
"(\"yyyy-mm-dd hh:mi:ss\");\nobjxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+formt"+fldnames.at(k+1)+
".format(*__obj->"+methpm.at(1)+
"())");
1902 methods += (
"+\"</"+fldnames.at(k+1)+
">\";}\n");
1903 if(methsall[this->classN+
"get"+cam+methpm.at(0)])typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n{\nDateFormat formt"+fldnames.at(k+1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->set"+cam+
"((formt"+fldnames.at(k+1)+
".parse(root.getChildElements().at(i).getText())));\n}\n";
1906 else if(methpm.at(0)==
"BinaryData")
1910 methods += (
"objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+BinaryData::serilaize(__obj->"+methpm.at(1)+
"())");
1911 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1912 if(methsall[this->classN+
"get"+cam+methpm.at(0)])typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->set"+cam+
"(*(BinaryData::unSerilaize(root.getChildElements().at(i).getText())));\n";
1916 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+BinaryData::serilaize(*__obj->"+methpm.at(1)+
"())");
1917 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1918 if(methsall[this->classN+
"get"+cam+methpm.at(0)])typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\")\n__obj->set"+cam+
"((BinaryData::unSerilaize(root.getChildElements().at(i).getText())));\n";
1921 else if(methpm.at(0).find(
"vector")!=string::npos || methpm.at(0).find(
"queue")!=string::npos ||
1922 methpm.at(0).find(
"deque")!=string::npos || methpm.at(0).find(
"set")!=string::npos ||
1923 methpm.at(0).find(
"list")!=string::npos || methpm.at(0).find(
"multiset")!=string::npos)
1925 string stlcnt = methpm.at(0);
1926 string stltyp = methpm.at(0);
1927 StringUtil::replaceFirst(stltyp,
"std::",
"");
1928 StringUtil::replaceFirst(stltyp,
"<",
"::");
1929 StringUtil::replaceFirst(stltyp,
">",
"");
1930 StringUtil::replaceFirst(stltyp,
" ",
"");
1931 string stlcnttyp =
"";
1932 if(methpm.at(0).find(
"vector")!=string::npos)
1934 else if(methpm.at(0).find(
"queue")!=string::npos)
1936 else if(methpm.at(0).find(
"deque")!=string::npos)
1938 else if(methpm.at(0).find(
"list")!=string::npos)
1940 else if(methpm.at(0).find(
"multiset")!=string::npos)
1941 stlcnttyp =
"MulSet";
1944 StringUtil::replaceFirst(stlcnt,
"std::",
"");
1945 StringUtil::replaceFirst(stlcnt,
"vector",
"");
1946 StringUtil::replaceFirst(stlcnt,
"queue",
"");
1947 StringUtil::replaceFirst(stlcnt,
"deque",
"");
1948 StringUtil::replaceFirst(stlcnt,
"multiset",
"");
1949 StringUtil::replaceFirst(stlcnt,
"set",
"");
1950 StringUtil::replaceFirst(stlcnt,
"list",
"");
1951 StringUtil::replaceFirst(stlcnt,
"<",
"");
1952 StringUtil::replaceFirst(stlcnt,
">",
"");
1953 StringUtil::replaceFirst(stlcnt,
" ",
"");
1957 methods += (methpm.at(0)+
" __temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
1958 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" ||
1959 stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1960 methods += (
"objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+stltyp+
"\\\">\"+XMLSerialize::serialize<"+methpm.at(0)+
" >(__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
")");
1962 methods += (
"objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+stltyp+
"\\\">\"+serialize"+stlcnt+stlcnttyp+
"(&__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
")");
1964 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1969 methods += (methpm.at(0)+
"* __temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
1970 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" ||
1971 stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
1972 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+stltyp+
"\\\">\"+XMLSerialize::serialize<"+methpm.at(0)+
" >(*__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
")");
1974 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+stltyp+
"\\\">\"+serialize"+stlcnt+stlcnttyp+
"(__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
")");
1976 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1984 methods += (methpm.at(0)+
" __temp_obj_ser"+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
1985 methods += (
"objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+serialize"+methpm.at(0)+
"(&__temp_obj_ser"+methpm.at(1)+
")");
1986 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
1992 methods += (methpm.at(0)+
"* __temp_obj_ser"+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
1993 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)objxml += \"<"+fldnames.at(k+1)+
" type=\\\""+methpm.at(0)+
"\\\">\"+serialize"+methpm.at(0)+
"(__temp_obj_ser"+methpm.at(1)+
")");
1994 methods += (
"+\"</"+fldnames.at(k+1)+
">\";\n");
2011 methods +=
"objxml += \"</"+this->classN+
">\";\nreturn objxml;\n}\n";
2012 methods +=
"\nstring serialize" + this->classN +
"Vec(void* obje)\n{\nvector<"+this->classN+
"> *__obj=(vector<"+this->classN+
">*)obje;\n";
2013 methods +=
"string xml=\"<vector-"+this->classN+
">\";\nfor(unsigned int i=0;i<__obj->size();i++)\n{\nxml+=serialize"+this->classN+
"(&(__obj->at(i)));\n}\nxml+=\"</vector-"+this->classN+
">\";\n";
2014 methods +=
"return xml;}\n";
2015 methods +=
"\nstring serialize"+this->classN+
"Q(void *t){std::queue<"+this->classN+
"> *_t=(std::queue<"+this->classN+
">*)t;std::queue<"+this->classN+
"> *tt = new std::queue<"+this->classN+
">; *tt = *_t; string objXml = \"<queue-"+this->classN+
">\"; for(unsigned int var=0;var<tt->size();var++) { objXml += serialize"+this->classN+
"(&(tt->front())); tt->pop(); } objXml += \"</queue-"+this->classN+
">\"; return objXml;}";
2016 methods +=
"\nstring serialize"+this->classN+
"Dq(void *_t){deque<"+this->classN+
"> *t=(deque<"+this->classN+
">*)_t;string objXml = \"<deque-"+this->classN+
">\"; for(unsigned int var=0;var<t->size();var++) { objXml += serialize"+this->classN+
"(&(t->at(var))); } objXml += \"</deque-"+this->classN+
">\"; return objXml;}";
2017 methods +=
"\nstring serialize"+this->classN+
"Lis(void *_t){ list<"+this->classN+
"> *t=(list<"+this->classN+
">*)_t;list<"+this->classN+
">::iterator it; string objXml = \"<list-"+this->classN+
">\"; for(it=t->begin();it!=t->end();++it) {"+this->classN+
" _temp=*it; objXml += serialize"+this->classN+
"(&_temp); } objXml += \"</list-"+this->classN+
">\"; return objXml;}";
2018 classes +=
"\nstring serialize" + this->classN +
"Vec(void* obje);\nstring serialize"+this->classN+
"Q(void *t);\nstring serialize"+this->classN+
"Dq(void *_t);\nstring serialize"+this->classN+
"Lis(void *_t);";
2021 methods +=
"\nstring serialize"+this->classN+
"Set(void *_t){ set<"+this->classN+
"> *t=(set<"+this->classN+
">*)_t;set<"+this->classN+
">::iterator it; string objXml = \"<set-"+this->classN+
">\"; for(it=t->begin();it!=t->end();++it) {"+this->classN+
" _temp=*it; objXml += serialize"+this->classN+
"(&_temp); } objXml += \"</set-"+this->classN+
">\"; return objXml;}";
2022 methods +=
"\nstring serialize"+this->classN+
"MulSet(void *_t){ multiset<"+this->classN+
"> *t=(multiset<"+this->classN+
">*)_t;multiset<"+this->classN+
">::iterator it; string objXml = \"<multiset-"+this->classN+
">\"; for(it=t->begin();it!=t->end();++it) {"+this->classN+
" _temp=*it; objXml += serialize"+this->classN+
"(&_temp); } objXml += \"</multiset-"+this->classN+
">\"; return objXml;}";
2023 classes +=
"\nstring serialize"+this->classN+
"Set(void *_t);\nstring serialize"+this->classN+
"MulSet(void *_t);";
2026 typedefs +=
"\n}\nreturn __obj;\n}";
2027 typedefs +=
"\nvoid* unSerialize"+this->classN+
"Dq(string objXml){deque<"+this->classN+
"> *t = new deque<"+this->classN+
">;XmlParser parser(\"Parser\");\nDocument doc = parser.getDocument(objXml);\nElement message = doc.getRootElement();\nif(message.getTagName()==\"\" && message.getChildElements().size()==0)\nreturn NULL;\nfor (int var = 0; var < (int)message.getChildElements().size(); var++){ Element ele = message.getChildElements().at(var); if(ele.getTagName()==\""+this->classN+
"\") { t->push_back(*("+this->classN+
"*)unSerialize"+this->classN+
"(ele.render())); }}return t;}";
2028 typedefs +=
"\nvoid* unSerialize"+this->classN+
"Q(string objXml){std::queue<"+this->classN+
"> *t = new std::queue<"+this->classN+
">;XmlParser parser(\"Parser\");\nDocument doc = parser.getDocument(objXml);\nElement message = doc.getRootElement();\nif(message.getTagName()==\"\" && message.getChildElements().size()==0)\nreturn NULL;\nfor (int var = 0; var < (int)message.getChildElements().size(); var++){ Element ele = message.getChildElements().at(var); if(ele.getTagName()==\""+this->classN+
"\") { t->push(*("+this->classN+
"*)unSerialize"+this->classN+
"(ele.render())); }}return t;}";
2029 typedefs +=
"\nvoid* unSerialize"+this->classN+
"Lis(string objXml){list<"+this->classN+
"> *t = new list<"+this->classN+
">;XmlParser parser(\"Parser\");\nDocument doc =parser.getDocument(objXml);\nElement message = doc.getRootElement();\nif(message.getTagName()==\"\" && message.getChildElements().size()==0)\nreturn NULL;\nfor (int var = 0; var < (int)message.getChildElements().size(); var++){ Element ele = message.getChildElements().at(var); if(ele.getTagName()==\""+this->classN+
"\") { t->push_back(*("+this->classN+
"*)unSerialize"+this->classN+
"(ele.render())); }}return t;}";
2030 classes +=
"\nvoid* unSerialize"+this->classN+
"Vec(string objXml);\nvoid* unSerialize"+this->classN+
"Q(string objXml);\nvoid* unSerialize"+this->classN+
"Dq(string objXml);\nvoid* unSerialize"+this->classN+
"Lis(string objXml);";
2033 typedefs +=
"\nvoid* unSerialize"+this->classN+
"Set(string objXml){set<"+this->classN+
"> *t = new set<"+this->classN+
">;XmlParser parser(\"Parser\");\nDocument doc = parser.getDocument(objXml);\nElement message = doc.getRootElement();\nif(message.getTagName()==\"\" && message.getChildElements().size()==0)\nreturn NULL;\nfor (int var = 0; var < (int)message.getChildElements().size(); var++){ Element ele = message.getChildElements().at(var); if(ele.getTagName()==\""+this->classN+
"\") { t->insert(*("+this->classN+
"*)unSerialize"+this->classN+
"(ele.render())); }}return t;}";
2034 typedefs +=
"\nvoid* unSerialize"+this->classN+
"MulSet(string objXml){multiset<"+this->classN+
"> *t = new multiset<"+this->classN+
">;XmlParser parser(\"Parser\");\nDocument doc = parser.getDocument(objXml);\nElement message = doc.getRootElement();\nif(message.getTagName()==\"\" && message.getChildElements().size()==0)\nreturn NULL;\nfor (int var = 0; var < (int)message.getChildElements().size(); var++){ Element ele = message.getChildElements().at(var); if(ele.getTagName()==\""+this->classN+
"\") { t->insert(*("+this->classN+
"*)unSerialize"+this->classN+
"(ele.render())); }}return t;}";
2035 classes +=
"\nvoid* unSerialize"+this->classN+
"Set(string objXml);\nvoid* unSerialize"+this->classN+
"MulSet(string objXml);";
2037 typedefs +=
"\nvoid* unSerialize"+this->classN+
"Vec(string objXml){vector<"+this->classN+
"> *t = new vector<"+this->classN+
">;XmlParser parser(\"Parser\");\nDocument doc = parser.getDocument(objXml);\nElement message = doc.getRootElement();\nif(message.getTagName()==\"\" && message.getChildElements().size()==0)\nreturn NULL;\nfor (int var = 0; var < (int)message.getChildElements().size(); var++){ Element ele = message.getChildElements().at(var); if(ele.getTagName()==\""+this->classN+
"\") { t->push_back(*("+this->classN+
"*)unSerialize"+this->classN+
"(ele.render())); }}return t;}";
2042 string Reflection::generateSerDefinitionBinary(
string className,
string &includesDefs,
string &typedefs,
string &classes,
string &methods)
2046 if (!generateClassInfo(className))
2053 includesDefs +=
"#include \"" + classN +
".h\"\n";
2055 classes +=
"\nstring binarySerialize" + classN +
"(void* obje);\nvoid* binaryUnSerialize" + classN +
"(string objXml);";
2056 methods +=
"\nstring binarySerialize" + classN +
"(void* obje)\n{\n"+classN+
" *__obj=("+classN+
"*)obje;\n";
2057 methods +=
"AMEFEncoder enc;\nAMEFObject object;\nobject.setName(\""+classN+
"\");\n";
2058 typedefs +=
"\nvoid* binaryUnSerialize" + classN +
"(string objXml)\n{\n";
2059 typedefs += classN+
" *__obj=new "+classN+
";\nAMEFDecoder dec;\nAMEFObject* root = dec.decodeB(objXml, true, false);\n";
2060 typedefs +=
"if(root->getNameStr()!=\""+classN+
"\")throw \"Invalid Binary Object\";";
2061 typedefs +=
"for(unsigned int i=0;i<root->getPackets().size();i++)\n{\n";
2062 typedefs +=
"string nam=root->getPackets().at(i)->getNameStr();\n";
2064 string publf, privf, protf ,publm, privm, protm;
2067 vector<string> fldnames;
2070 for (
unsigned int i = 0; i < pri.size(); i++)
2072 if(((tes=pri.at(i).find(
"("))==string::npos && (tes=pri.at(i).find(
")"))==string::npos && pri.at(i).find(
"~")==string::npos))
2075 StringUtil::replaceFirst(fld,
";",
"");
2076 vector<string> fldp;
2077 StringUtil::split(fldp, fld, (
" "));
2080 string nam = fldp.at(1);
2081 fldnames.push_back(fldp.at(0));
2082 fldnames.push_back(nam);
2089 for (
unsigned int i = 0; i < pro.size(); i++)
2091 if(((tes=pro.at(i).find(
"("))==string::npos && (tes=pro.at(i).find(
")"))==string::npos && pro.at(i).find(
"~")==string::npos))
2094 StringUtil::replaceFirst(fld,
";",
"");
2095 vector<string> fldp;
2096 StringUtil::split(fldp, fld, (
" "));
2099 string nam = fldp.at(1);
2100 fldnames.push_back(fldp.at(0));
2101 fldnames.push_back(nam);
2108 for (
unsigned int i = 0; i < pub.size(); i++)
2110 if(((tes=pub.at(i).find(
"("))==string::npos && (tes=pub.at(i).find(
")"))==string::npos && pub.at(i).find(
"~")==string::npos))
2113 RegexUtil::replace(fld,
"[\t]+",
" ");
2114 RegexUtil::replace(fld,
"[ ]+",
" ");
2115 RegexUtil::replace(fld,
"[ ?, ?]+",
",");
2116 StringUtil::replaceFirst(fld,
";",
"");
2118 if(fld.find(
"*")!=string::npos)
2121 StringUtil::replaceFirst(fld,
"*",
"");
2123 vector<string> fldp;
2124 StringUtil::split(fldp, fld, (
" "));
2127 string nam = fldp.at(1);
2128 if(fldp.at(0)==
"int" || fldp.at(0)==
"short" || fldp.at(0)==
"long" || fldp.at(0)==
"float" || fldp.at(0)==
"string" ||
2129 fldp.at(0)==
"std::string" || fldp.at(0)==
"double" || fldp.at(0)==
"bool")
2131 string argtype = StringUtil::capitalizedCopy(fldp.at(0));
2132 string vallu =
"root->getPackets().at(i)->get"+argtype+
"Value()";
2133 if(fldp.at(0)==
"string" || fldp.at(0)==
"std::string")
2135 vallu =
"root->getPackets().at(i)->getValueStr()";
2139 methods += (
"object.addPacket(__obj->"+fldp.at(1)+
",\""+fldp.at(1)+
"\");\n");
2140 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2141 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+fldp.at(1)+
" = "+vallu+
";\n";
2145 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)object.addPacket(*__obj->"+fldp.at(1)+
",\""+fldp.at(1)+
"\");\n");
2146 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2147 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+fldp.at(1)+
" = new "+fldp.at(0)+
"("+vallu+
");\n";
2150 else if(fldp.at(0)==
"Date")
2154 methods += (
"DateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n");
2155 methods += (
"object.addPacket(formt"+fldp.at(1)+
".format(__obj->"+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2157 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2159 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n{\nDateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+fldp.at(1)+
" = *(formt"+fldp.at(1)+
".parse(root->getPackets().at(i)->getValue()));\n}\n";
2163 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL){DateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n");
2164 methods += (
"object.addPacket(formt"+fldp.at(1)+
".format(*__obj->"+fldp.at(1)+
"),\""+fldp.at(1)+
"\");}\n");
2166 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2168 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n{\nDateFormat formt"+fldp.at(1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+fldp.at(1)+
" = (formt"+fldp.at(1)+
".parse(root->getPackets().at(i)->getValue()));\n}\n";
2171 else if(fldp.at(0)==
"BinaryData")
2175 methods += (
"object.addPacket(BinaryData::serilaize(__obj->"+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2177 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2179 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+fldp.at(1)+
" = *(BinaryData::unSerilaize(root->getPackets().at(i)->getValue()));\n";
2183 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)object.addPacket(BinaryData::serilaize(*__obj->"+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2185 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2187 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+fldp.at(1)+
" = (BinaryData::unSerilaize(root->getPackets().at(i)->getValue()));\n";
2190 else if(fldp.at(0).find(
"vector")!=string::npos || fldp.at(0).find(
"queue")!=string::npos ||
2191 fldp.at(0).find(
"deque")!=string::npos || fldp.at(0).find(
"set")!=string::npos ||
2192 fldp.at(0).find(
"list")!=string::npos || fldp.at(0).find(
"multiset")!=string::npos)
2194 string stlcnt = fldp.at(0);
2195 string stltyp = fldp.at(0);
2197 StringUtil::replaceFirst(stltyp,
"std::",
"");
2198 StringUtil::replaceFirst(stltyp,
"<",
"::");
2199 StringUtil::replaceFirst(stltyp,
">",
"");
2200 StringUtil::replaceFirst(stltyp,
" ",
"");
2201 string stlcnttyp =
"";
2202 if(fldp.at(0).find(
"vector")!=string::npos)
2204 contType =
"std::vector<";
2207 else if(fldp.at(0).find(
"queue")!=string::npos)
2209 contType =
"std::queue<";
2212 else if(fldp.at(0).find(
"deque")!=string::npos)
2214 contType =
"std::deque<";
2217 else if(fldp.at(0).find(
"list")!=string::npos)
2219 contType =
"std::list<";
2222 else if(fldp.at(0).find(
"multiset")!=string::npos)
2224 contType =
"std::multiset<";
2225 stlcnttyp =
"MulSet";
2229 contType =
"std::set<";
2232 StringUtil::replaceFirst(stlcnt,
"std::",
"");
2233 StringUtil::replaceFirst(stlcnt,
"vector",
"");
2234 StringUtil::replaceFirst(stlcnt,
"queue",
"");
2235 StringUtil::replaceFirst(stlcnt,
"deque",
"");
2236 StringUtil::replaceFirst(stlcnt,
"multiset",
"");
2237 StringUtil::replaceFirst(stlcnt,
"set",
"");
2238 StringUtil::replaceFirst(stlcnt,
"list",
"");
2239 StringUtil::replaceFirst(stlcnt,
"<",
"");
2240 StringUtil::replaceFirst(stlcnt,
">",
"");
2241 StringUtil::replaceFirst(stlcnt,
" ",
"");
2243 contType += stlcnt +
",";
2247 methods += (fldp.at(0)+
" __temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
2248 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2249 methods += (
"object.addPacket(Serialize::serialize<"+fldp.at(0)+
" >(__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2251 methods += (
"object.addPacket(binarySerialize"+stlcnt+stlcnttyp+
"(&__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2252 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2254 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\"){";
2255 typedefs +=
"\nAMEFEncoder enc;\n";
2256 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" ||
2257 stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2258 typedefs +=
"\n__obj->"+fldp.at(1)+
" = Serialize::unserialize<"+fldp.at(0)+
" >(root->getPackets().at(i)->getValue());\n";
2260 typedefs +=
"\n__obj->"+fldp.at(1)+
" = *("+fldp.at(0)+
"*)binaryUnSerialize"+stlcnt+stlcnttyp+
"(root->getPackets().at(i)->getValue());\n";
2261 typedefs +=
"\n}\n";
2265 methods += (fldp.at(0)+
"* __temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
2266 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" ||
2267 stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2268 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)object.addPacket(Serialize::serialize<"+fldp.at(0)+
" >(*__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2270 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)object.addPacket(binarySerialize"+stlcnt+stlcnttyp+
"(__temp_obj_ser"+stlcnt+stlcnttyp+classN+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2271 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2273 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\"){";
2274 typedefs +=
"\nAMEFEncoder enc;\n";
2276 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2277 typedefs +=
"\n__obj->"+fldp.at(1)+
" = ("+fldp.at(0)+
"*)Serialize::unSerializeUnknown(root->getPackets().at(i)->getValue(),\""+contType+
"\");\n";
2279 typedefs +=
"\n__obj->"+fldp.at(1)+
" = ("+fldp.at(0)+
"*)binaryUnSerialize"+stlcnt+stlcnttyp+
"(root->getPackets().at(i)->getValue());\n";
2280 typedefs +=
"\n}\n";
2287 methods += (fldp.at(0)+
" __temp_obj_ser"+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
2288 methods += (
"object.addPacket(binarySerialize"+fldp.at(0)+
"(&__temp_obj_ser"+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2289 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2291 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+fldp.at(1)+
" = *("+fldp.at(0)+
"*)binaryUnSerialize"+fldp.at(0)+
"(root->getPackets().at(i)->getValue());\n";
2295 methods += (fldp.at(0)+
"* __temp_obj_ser"+fldp.at(1)+
" = __obj->"+fldp.at(1)+
";\n");
2296 methods += (
"if(__obj->"+fldp.at(1)+
"!=NULL)object.addPacket(binarySerialize"+fldp.at(0)+
"(__temp_obj_ser"+fldp.at(1)+
"),\""+fldp.at(1)+
"\");\n");
2297 string cam = StringUtil::capitalizedCopy(fldp.at(1));
2299 typedefs +=
"if(nam==\""+fldp.at(1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+fldp.at(1)+
" = ("+fldp.at(0)+
"*)binaryUnSerialize"+fldp.at(0)+
"(root->getPackets().at(i)->getValue());\n";
2305 if((tes=pub.at(i).find(
"("))!=string::npos && (tes=pub.at(i).find(
")"))!=string::npos && pub.at(i).find(
"~")==string::npos
2306 && fldnames.size()>0)
2309 StringUtil::replaceFirst(meth,
";",
"");
2310 RegexUtil::replace(meth,
"[\t]+",
" ");
2311 RegexUtil::replace(meth,
"[ ]+",
" ");
2312 RegexUtil::replace(meth,
"[ ?, ?]+",
",");
2314 if(meth.find(
"*")!=string::npos)
2317 StringUtil::replaceFirst(meth,
"*",
"");
2320 string argts = meth.substr(meth.find(
"("),meth.find(
")")-meth.find(
"("));
2321 StringUtil::replaceFirst(argts,
"(",
"");
2322 StringUtil::replaceAll(argts,
")",
"");
2323 meth = meth.substr(0,meth.find(
"("));
2324 if(meth.find(
"operator")!=string::npos)
2326 if(meth.find(
"<")!=string::npos)
2330 else if(meth.find(
">")!=string::npos)
2338 vector<string> methp,methpm,argp,argpm;
2339 StringUtil::split(argp, argts, (
","));
2340 StringUtil::split(methp, meth, (
" "));
2341 for(
unsigned int j = 0; j < methp.size(); j++)
2344 methpm.push_back(methp.at(j));
2346 for(
unsigned int j = 0; j < argp.size(); j++)
2348 if(argp.at(j)!=
"" && argp.at(j)!=
"(")
2350 string tty = argp.at(j);
2351 StringUtil::trim(tty);
2352 if(tty.find(
" ")!=string::npos)
2354 vector<string> temargt = StringUtil::split(tty,
" ");
2355 argpm.push_back(temargt.at(0));
2359 argpm.push_back(tty);
2364 if(methpm.at(0)!=classN)
2366 for(
unsigned int k = 0; k < fldnames.size(); k=k+2)
2368 string cam = StringUtil::capitalizedCopy(fldnames.at(k+1));
2369 string fldNamewoptr = StringUtil::replaceFirstCopy(fldnames.at(k),
"*",
"");
2373 StringUtil::replaceFirst(argpm.at(0),
"*",
"");
2376 if(
"set"+cam==methpm.at(1) && argpm.size()==1 && argpm.at(0)==fldNamewoptr && methpm.at(0)==
"void")
2379 if(argpm.at(0)==
"int" || argpm.at(0)==
"long" || argpm.at(0)==
"short" || argpm.at(0)==
"float"
2380 || argpm.at(0)==
"string" || argpm.at(0)==
"std::string" || argpm.at(0)==
"double" || argpm.at(0)==
"bool")
2382 string argtype = StringUtil::capitalizedCopy(argpm.at(0));
2383 string vallu =
"root->getPackets().at(i)->get"+argtype+
"Value()";
2384 if(argpm.at(0)==
"string" || argpm.at(0)==
"std::string")
2386 vallu =
"root->getPackets().at(i)->getValueStr()";
2390 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+methpm.at(1)+
"("+vallu+
");\n";
2394 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+methpm.at(1)+
"(new "+argpm.at(0)+
"("+vallu+
"));\n";
2397 else if(argpm.at(0)==
"Date")
2401 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n{\nDateFormat formt"+cam+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+methpm.at(1)+
"(*(formt"+cam+
".parse(root->getPackets().at(i)->getValue())));\n}\n";
2405 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n{\nDateFormat formt"+cam+
"(\"yyyy-mm-dd hh:mi:ss\");\n__obj->"+methpm.at(1)+
"((formt"+cam+
".parse(root->getPackets().at(i)->getValue())));\n}\n";
2408 else if(argpm.at(0)==
"BinaryData")
2412 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+methpm.at(1)+
"(*(BinaryData::unSerilaize(root->getPackets().at(i)->getValue())));\n";
2416 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+methpm.at(1)+
"((BinaryData::unSerilaize(root->getPackets().at(i)->getValue())));\n";
2419 else if(argpm.at(0).find(
"vector")!=string::npos || argpm.at(0).find(
"queue")!=string::npos ||
2420 argpm.at(0).find(
"deque")!=string::npos || argpm.at(0).find(
"set")!=string::npos ||
2421 argpm.at(0).find(
"list")!=string::npos || argpm.at(0).find(
"multiset")!=string::npos)
2423 string stlcnt = argpm.at(0);
2424 string stltyp = argpm.at(0);
2426 StringUtil::replaceFirst(stltyp,
"std::",
"");
2427 StringUtil::replaceFirst(stltyp,
"<",
"::");
2428 StringUtil::replaceFirst(stltyp,
">",
"");
2429 StringUtil::replaceFirst(stltyp,
" ",
"");
2430 string stlcnttyp =
"";
2431 if(argpm.at(0).find(
"vector")!=string::npos)
2433 contType =
"std::vector<";
2436 else if(argpm.at(0).find(
"queue")!=string::npos)
2438 contType =
"std::queue<";
2441 else if(argpm.at(0).find(
"deque")!=string::npos)
2443 contType =
"std::deque<";
2446 else if(argpm.at(0).find(
"list")!=string::npos)
2448 contType =
"std::list<";
2451 else if(argpm.at(0).find(
"multiset")!=string::npos)
2453 contType =
"std::multiset<";
2454 stlcnttyp =
"MulSet";
2458 contType =
"std::set<";
2461 StringUtil::replaceFirst(stlcnt,
"std::",
"");
2462 StringUtil::replaceFirst(stlcnt,
"vector",
"");
2463 StringUtil::replaceFirst(stlcnt,
"queue",
"");
2464 StringUtil::replaceFirst(stlcnt,
"deque",
"");
2465 StringUtil::replaceFirst(stlcnt,
"multiset",
"");
2466 StringUtil::replaceFirst(stlcnt,
"set",
"");
2467 StringUtil::replaceFirst(stlcnt,
"list",
"");
2468 StringUtil::replaceFirst(stlcnt,
"<",
"");
2469 StringUtil::replaceFirst(stlcnt,
">",
"");
2470 StringUtil::replaceFirst(stlcnt,
" ",
"");
2472 contType += stlcnt +
",";
2476 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\"){";
2477 typedefs +=
"\nAMEFEncoder enc;";
2478 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" ||
2479 stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2480 typedefs +=
"\n__obj->set"+cam+
"(Serialize::unserialize<"+argpm.at(0)+
" >(root->getPackets().at(i)->getValue()));\n";
2482 typedefs +=
"\n__obj->set"+cam+
"(*("+argpm.at(0)+
"*)binaryUnSerialize"+stlcnt+stlcnttyp+
"(root->getPackets().at(i)->getValue()));\n";
2483 typedefs +=
"\n}\n";
2487 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\"){";
2488 typedefs +=
"\nAMEFEncoder enc;";
2489 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" ||
2490 stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2491 typedefs +=
"\n__obj->set"+cam+
"(("+argpm.at(0)+
"*)Serialize::unSerializeUnknown(root->getPackets().at(i)->getValue(),\""+contType+
"\"));\n";
2493 typedefs +=
"\n__obj->set"+cam+
"(("+argpm.at(0)+
"*)binaryUnSerialize"+stlcnt+stlcnttyp+
"(root->getPackets().at(i)->getValue()));\n";
2494 typedefs +=
"\n}\n";
2502 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n{\nAMEFEncoder enc;\n__obj->"+methpm.at(1)+
"(*("+argpm.at(0)+
"*)binaryUnSerialize"+argpm.at(0)+
"(root->getPackets().at(i)->getValueStr()));}\n";
2506 typedefs +=
"if(nam==\""+fldnames.at(k+1)+
"\" && root->getPackets().at(i)->getValue()!=\"\")\n{\nAMEFEncoder enc;\n__obj->"+methpm.at(1)+
"(("+argpm.at(0)+
"*)binaryUnSerialize"+argpm.at(0)+
"(root->getPackets().at(i)->getValueStr()));}\n";
2510 else if(
"get"+cam==methpm.at(1) && argpm.size()==0 && methpm.at(0)==fldNamewoptr)
2512 if(methpm.at(0)==
"int" || methpm.at(0)==
"long" || methpm.at(0)==
"short" || methpm.at(0)==
"float" ||
2513 methpm.at(0)==
"string" || methpm.at(0)==
"std::string" || methpm.at(0)==
"double" || methpm.at(0)==
"bool")
2517 methods += (
"object.addPacket(__obj->"+methpm.at(1)+
"(),\""+fldnames.at(k+1)+
"\");\n");
2524 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)object.addPacket(*__obj->"+methpm.at(1)+
"(),\""+fldnames.at(k+1)+
"\");\n");
2530 else if(methpm.at(0)==
"Date")
2534 methods += (
"DateFormat formt"+fldnames.at(k+1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n");
2535 methods += (
"object.addPacket(formt"+fldnames.at(k+1)+
".format(__obj->"+methpm.at(1)+
"()),\""+fldnames.at(k+1)+
"\");\n");
2542 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL){DateFormat formt"+fldnames.at(k+1)+
"(\"yyyy-mm-dd hh:mi:ss\");\n");
2543 methods += (
"object.addPacket(formt"+fldnames.at(k+1)+
".format(*__obj->"+methpm.at(1)+
"()),\""+fldnames.at(k+1)+
"\");}\n");
2549 else if(methpm.at(0)==
"BinaryData")
2553 methods += (
"object.addPacket(BinaryData::serilaize(__obj->"+methpm.at(1)+
"()),\""+fldnames.at(k+1)+
"\");\n");
2560 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)object.addPacket(BinaryData::serilaize(*__obj->"+methpm.at(1)+
"()),\""+fldnames.at(k+1)+
"\");\n");
2566 else if(methpm.at(0).find(
"vector")!=string::npos || methpm.at(0).find(
"queue")!=string::npos ||
2567 methpm.at(0).find(
"deque")!=string::npos || methpm.at(0).find(
"set")!=string::npos ||
2568 methpm.at(0).find(
"list")!=string::npos || methpm.at(0).find(
"multiset")!=string::npos)
2570 string stlcnt = methpm.at(0);
2571 string stltyp = methpm.at(0);
2572 StringUtil::replaceFirst(stltyp,
"std::",
"");
2573 StringUtil::replaceFirst(stltyp,
"<",
"::");
2574 StringUtil::replaceFirst(stltyp,
">",
"");
2575 StringUtil::replaceFirst(stltyp,
" ",
"");
2576 string stlcnttyp =
"";
2577 if(methpm.at(0).find(
"vector")!=string::npos)
2579 else if(methpm.at(0).find(
"queue")!=string::npos)
2581 else if(methpm.at(0).find(
"deque")!=string::npos)
2583 else if(methpm.at(0).find(
"list")!=string::npos)
2585 else if(methpm.at(0).find(
"multiset")!=string::npos)
2586 stlcnttyp =
"MulSet";
2589 StringUtil::replaceFirst(stlcnt,
"std::",
"");
2590 StringUtil::replaceFirst(stlcnt,
"vector",
"");
2591 StringUtil::replaceFirst(stlcnt,
"queue",
"");
2592 StringUtil::replaceFirst(stlcnt,
"deque",
"");
2593 StringUtil::replaceFirst(stlcnt,
"multiset",
"");
2594 StringUtil::replaceFirst(stlcnt,
"set",
"");
2595 StringUtil::replaceFirst(stlcnt,
"list",
"");
2596 StringUtil::replaceFirst(stlcnt,
"<",
"");
2597 StringUtil::replaceFirst(stlcnt,
">",
"");
2598 StringUtil::replaceFirst(stlcnt,
" ",
"");
2602 methods += (methpm.at(0)+
" __temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
2603 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2604 methods += (
"object.addPacket(Serialize::serialize<"+methpm.at(0)+
" >(__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
"),\""+fldnames.at(k+1)+
"\");\n");
2606 methods += (
"object.addPacket(binarySerialize"+stlcnt+stlcnttyp+
"(&__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
"),\""+fldnames.at(k+1)+
"\");\n");
2619 methods += (methpm.at(0)+
"* __temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
2620 if(stlcnt==
"int" || stlcnt==
"short" || stlcnt==
"long" || stlcnt==
"float" || stlcnt==
"string" || stlcnt==
"std::string" || stlcnt==
"double" || stlcnt==
"bool")
2621 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)object.addPacket(Serialize::serialize<"+methpm.at(0)+
" >(*__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
"),\""+fldnames.at(k+1)+
"\");\n");
2623 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)object.addPacket(binarySerialize"+stlcnt+stlcnttyp+
"(__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+
"),\""+fldnames.at(k+1)+
"\");\n");
2642 methods += (methpm.at(0)+
" __temp_obj_ser"+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
2643 methods += (
"object.addPacket(binarySerialize"+methpm.at(0)+
"(&__temp_obj_ser"+methpm.at(1)+
"),\""+fldnames.at(k+1)+
"\");\n");
2648 methods += (methpm.at(0)+
"* __temp_obj_ser"+methpm.at(1)+
" = __obj->"+methpm.at(1)+
"();\n");
2649 methods += (
"if(__obj->"+methpm.at(1)+
"()!=NULL)object.addPacket(binarySerialize"+methpm.at(0)+
"(&__temp_obj_ser"+methpm.at(1)+
"),\""+fldnames.at(k+1)+
"\");\n");
2665 methods +=
"return enc.encodeB(&object, false);\n}\n";
2666 methods +=
"\nstring binarySerialize" + classN +
"Vec(void* obje)\n{\nvector<"+classN+
"> *__obj=(vector<"+classN+
">*)obje;\n"
2667 +
"string xml;\nAMEFObject object;AMEFEncoder enc;\nfor(unsigned int i=0;i<__obj->size();i++)\n{\nobject.addPacket(binarySerialize"+classN+
"(&(__obj->at(i))));\n}\nreturn enc.encodeB(&object, false);\n}\n";
2668 methods +=
"\nstring binarySerialize"+classN+
"Q(void *t){\nstd::queue<"+classN+
"> *_t=(std::queue<"+classN+
">*)t;std::queue<"+classN+
"> *tt = new std::queue<"+classN+
">; *tt = *_t;"
2669 +
"\nstring objXml;\nAMEFObject object;AMEFEncoder enc;\nfor(unsigned int var=0;var<tt->size();var++){\nobject.addPacket(binarySerialize"+classN+
"(&(tt->front())));tt->pop();}\nreturn enc.encodeB(&object, false);\n}";
2670 methods +=
"\nstring binarySerialize"+classN+
"Dq(void *t)\n{\ndeque<"+classN+
"> *_t=(deque<"+classN+
">*)t;"
2671 +
"\nstring objXml;\nAMEFObject object;AMEFEncoder enc;\nfor(unsigned int var=0;var<_t->size();var++){\nobject.addPacket(binarySerialize"+classN+
"(&(_t->at(var))));}\nreturn enc.encodeB(&object, false);\n}";
2672 methods +=
"\nstring binarySerialize"+classN+
"Lis(void *_t)\n{\nlist<"+classN+
"> *t=(list<"+classN+
">*)_t;list<"+classN+
">::iterator it;"
2673 +
"string objXml;\nAMEFObject object;AMEFEncoder enc;\nfor(it=t->begin();it!=t->end();++it) {"+classN+
" _temp=*it;object.addPacket(binarySerialize"+classN+
"(&(_temp))); }\nreturn enc.encodeB(&object, false);\n}";
2674 classes +=
"\nstring binarySerialize" + classN +
"Vec(void* obje);\nstring binarySerialize"+classN+
"Q(void *t);\nstring binarySerialize"+classN+
"Dq(void *_t);\nstring binarySerialize"+classN+
"Lis(void *_t);";
2677 methods +=
"\nstring binarySerialize"+classN+
"Set(void *_t)\n{\nset<"+classN+
"> *t=(set<"+classN+
">*)_t;set<"+classN+
">::iterator it;"
2678 +
"string objXml;\nAMEFObject object;AMEFEncoder enc;\nfor(it=t->begin();it!=t->end();++it) {"+classN+
" _temp=*it;object.addPacket(binarySerialize"+classN+
"(&(_temp)));\n}\nreturn enc.encodeB(&object, false);\n}";
2679 methods +=
"\nstring binarySerialize"+classN+
"MulSet(void *_t)\n{\nmultiset<"+classN+
"> *t=(multiset<"+classN+
">*)_t;multiset<"+classN+
">::iterator it;"
2680 +
"string objXml;\nAMEFObject object;AMEFEncoder enc;\nfor(it=t->begin();it!=t->end();++it) {"+classN+
" _temp=*it;object.addPacket(binarySerialize"+classN+
"(&(_temp)));\n}\nreturn enc.encodeB(&object, false);\n}";
2681 classes +=
"\nstring binarySerialize"+classN+
"Set(void *_t);\nstring binarySerialize"+classN+
"MulSet(void *_t);";
2684 typedefs +=
"\n}\nreturn __obj;\n}";
2685 typedefs +=
"\nvoid* binaryUnSerialize"+classN+
"Dq(string objXml){deque<"+classN+
"> *t = new deque<"+classN+
">;"
2686 +
"\nAMEFDecoder dec;\nAMEFObject* root = dec.decodeB(objXml, true, false);for (int var = 0; var < (int)root->getPackets().size(); var++){"
2687 +
"t->push_back(*("+classN+
"*)binaryUnSerialize"+classN+
"(root->getPackets().at(var)->getValue())); }return t;}";
2688 typedefs +=
"\nvoid* binaryUnSerialize"+classN+
"Q(string objXml){std::queue<"+classN+
"> *t = new std::queue<"+classN+
">;"
2689 +
"\nAMEFDecoder dec;\nAMEFObject* root = dec.decodeB(objXml, true, false);for (int var = 0; var < (int)root->getPackets().size(); var++){"
2690 +
"t->push(*("+classN+
"*)binaryUnSerialize"+classN+
"(root->getPackets().at(var)->getValue())); }return t;}";
2691 typedefs +=
"\nvoid* binaryUnSerialize"+classN+
"Lis(string objXml){list<"+classN+
"> *t = new list<"+classN+
">;"
2692 +
"\nAMEFDecoder dec;\nAMEFObject* root = dec.decodeB(objXml, true, false);for (int var = 0; var < (int)root->getPackets().size(); var++){"
2693 +
"t->push_back(*("+classN+
"*)binaryUnSerialize"+classN+
"(root->getPackets().at(var)->getValue())); }return t;}";
2694 typedefs +=
"\nvoid* binaryUnSerialize"+classN+
"Vec(string objXml){vector<"+classN+
"> *t = new vector<"+classN+
">;"
2695 +
"\nAMEFDecoder dec;\nAMEFObject* root = dec.decodeB(objXml, true, false);for (int var = 0; var < (int)root->getPackets().size(); var++){"
2696 +
"t->push_back(*("+classN+
"*)binaryUnSerialize"+classN+
"(root->getPackets().at(var)->getValue())); }return t;}";
2697 classes +=
"\nvoid* binaryUnSerialize"+classN+
"Vec(string objXml);\nvoid* binaryUnSerialize"+classN+
"Q(string objXml);\nvoid* binaryUnSerialize"+classN+
"Dq(string objXml);\nvoid* binaryUnSerialize"+classN+
"Lis(string objXml);";
2700 typedefs +=
"\nvoid* binaryUnSerialize"+classN+
"Set(string objXml){set<"+classN+
"> *t = new set<"+classN+
">;"
2701 +
"\nAMEFDecoder dec;\nAMEFObject* root = dec.decodeB(objXml, true, false);for (int var = 0; var < (int)root->getPackets().size(); var++){"
2702 +
"t->insert(*("+classN+
"*)binaryUnSerialize"+classN+
"(root->getPackets().at(var)->getValue())); }return t;}";
2703 typedefs +=
"\nvoid* binaryUnSerialize"+classN+
"MulSet(string objXml){multiset<"+classN+
"> *t = new multiset<"+classN+
">;"
2704 +
"\nAMEFDecoder dec;\nAMEFObject* root = dec.decodeB(objXml, true, false);for (int var = 0; var < (int)root->getPackets().size(); var++){"
2705 +
"t->insert(*("+classN+
"*)binaryUnSerialize"+classN+
"(root->getPackets().at(var)->getValue())); }return t;}";
2706 classes +=
"\nvoid* binaryUnSerialize"+classN+
"Set(string objXml);\nvoid* binaryUnSerialize"+classN+
"MulSet(string objXml);";