ffead.server.doc
Reflection.cpp
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * Reflection.cpp
18  *
19  * Created on: Aug 21, 2009
20  * Author: sumeet
21  */
22 
23 #include "Reflection.h"
24 
25 using namespace std;
26 
27 map<string,bool> Reflection::invalidcls;
28 
29 Reflection::Reflection() {
30  logger = Logger::getLogger("Reflection");
31 }
32 
33 Reflection::~Reflection() {
34  // TODO Auto-generated destructor stub
35 }
36 
37 strVec Reflection::list(string cwd)
38 {
39  FILE *pipe_fp;
40  string command;
41  strVec files;
42  if(chdir(cwd.c_str())!=0)
43  return files;
44  command = ("find . \\( ! -name . -prune \\) \\( -type f -o -type l \\) -name '*.h' 2>/dev/null");
45  //command = "ls -F1 "+cwd+"|grep '.h'";
46  logger << ("Searching directory " + cwd + " for pattern .h") << endl;
47  if ((pipe_fp = popen(command.c_str(), "r")) == NULL)
48  {
49  printf("pipe open error in cmd_list\n");
50  return files;
51  }
52  int t_char;
53  string fileName;
54  while ((t_char = fgetc(pipe_fp)) != EOF)
55  {
56  if(t_char!='\n')
57  {
58  stringstream ss;
59  ss << (char)t_char;
60  string temp;
61  ss >> temp;
62  fileName.append(temp);
63  }
64  else if(fileName!="")
65  {
66  StringUtil::replaceFirst(fileName,"*","");
67  StringUtil::replaceFirst(fileName,"./","");
68  if(fileName.find("~")==string::npos)
69  {
70  fileName = cwd+"/"+fileName;
71  StringUtil::replaceFirst(fileName,"//","/");
72  files.push_back(fileName);
73  }
74  fileName = "";
75  }
76  }
77  pclose(pipe_fp);
78  return files;
79 }
80 
81 void trimSpaces(string& str)
82 {
83  // Trim Both leading and trailing spaces
84  size_t startpos = str.find_first_not_of(" \t"); // Find the first character position after excluding leading blank spaces
85  size_t endpos = str.find_last_not_of(" \t"); // Find the first character position from reverse af
86 
87  // if all spaces or empty return an empty string
88  if(( string::npos == startpos ) || ( string::npos == endpos))
89  {
90  str = "";
91  }
92  else
93  str = str.substr( startpos, endpos-startpos+1 );
94 
95 }
96 
97 void Reflection::collectInfo(string data,string flag)
98 {
99  trimSpaces(data);
100  if(flag=="public")
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);
106 }
107 
108 bool Reflection::generateClassInfo(string className)
109 {
110  this->pub.clear();this->pri.clear();this->pro.clear();
111  this->classN="";this->baseClassN="";this->bcvisib="";
112  string data;
113  //className += ".h";
114  ifstream infile;
115  //logger << "Reading from the file" << endl;
116  //className = "/home/sumeet/workspace/weblib/" + className;
117  infile.open(className.c_str());
118  string flag = "";
119 
120  if(infile.is_open())
121  {
122  bool classdone = false;
123  bool start = false;
124  //bool classset = false;
125  bool commstrts = false;
126  size_t tes;
127  int cnt = 0;
128 
129  //e1.assign("\\t+");
130  //e2.assign("\\s+");
131  bool classcomplete = false;
132  while(getline(infile, data))
133  {
134  RegexUtil::replace(data, "[\t]+", " ");
135  RegexUtil::replace(data, "[ ]+", " ");
136  //classset = false;
137  if(classcomplete)
138  continue;
139  if((tes=data.find("/*"))!=string::npos)
140  {
141  commstrts = true;
142  if((tes=data.find("*/"))!=string::npos)
143  commstrts = false;
144  }
145  else if((tes=data.find("*/"))!=string::npos)
146  {
147  commstrts = false;
148  }
149  else if((tes=data.find("//"))!=string::npos)
150  {
151  commstrts = false;
152  }
153  else if(!commstrts)
154  {
155  //logger << data << cnt <<endl;
156  if((tes=data.find("template"))!=string::npos)
157  return false;
158  if(data.find("friend")!=string::npos)
159  continue;
160  if((tes=data.find("class"))!=string::npos && !classdone)
161  {
162  strVec results;
163  StringUtil::replaceFirst(data,":","");
164  StringUtil::replaceFirst(data,"class ","");
165  if((tes=data.find("{"))!=string::npos)
166  {
167  start = true;
168  cnt += 1;
169  }
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)
176  {
177  this->bcvisib = results.at(1);
178  StringUtil::replaceAll(this->bcvisib," ","");
179  this->baseClassN = results.at(2);
180  StringUtil::replaceAll(this->baseClassN," ","");
181  //logger << results.size() << flush;
182  }
183  classdone = true;
184  //classset = true;
185  //StringUtil::split(results, data, (": "));
186  }
187  else if((tes=data.find("{"))!=string::npos && !start)
188  {
189  start = true;
190  StringUtil::replaceFirst(data,"{","");
191  cnt += 1;
192  }
193  if(start && data!="")
194  {
195  if((tes=data.find("{"))!=string::npos)
196  {
197  cnt += 1;
198  }
199  if((tes=data.find("}"))!=string::npos)
200  {
201  cnt -= 1;
202  }
203  if(cnt==0)
204  break;
205  else if(cnt==1)
206  {
207  if((tes=data.find("public"))!=string::npos)
208  flag = "public";
209  else if((tes=data.find("protected"))!=string::npos)
210  flag = "protected";
211  else if((tes=data.find("private"))!=string::npos)
212  flag = "private";
213  else
214  {
215  if(flag=="")
216  flag = "private";
217  StringUtil::trim(data);
218  collectInfo(data,flag);
219  }
220  }
221  }
222  }
223  }
224  }
225  infile.close();
226  if(this->pub.size()>0 || this->pri.size()>0 || this->pro.size()>0)
227  return true;
228  else
229  return false;
230 }
231 
232 
233 bool Reflection::generateClassInfoFromDD(string alldata)
234 {
235  string data;
236  string flag = "";
237  stringstream ss;
238  ss << alldata;
239  while (getline(ss, data))
240  {
241  size_t tes;
242  if ((tes = data.find("class")) != string::npos)
243  {
244  strVec results;
245  StringUtil::replaceFirst(data,":","");
246  StringUtil::split(results, data, (" "));
247  this->classN = results.at(1);
248  if(results.size()>3)
249  {
250  this->bcvisib = results.at(2);
251  this->baseClassN = results.at(3);
252  //logger << results.size() << flush;
253  }
254  //StringUtil::split(results, data, (": "));
255  }
256  else if ((tes = data.find("}")) != string::npos)
257  break;
258  else if ((tes = data.find("public")) != string::npos)
259  flag = "public";
260  else if ((tes = data.find("protected")) != string::npos)
261  flag = "protected";
262  else if ((tes = data.find("private")) != string::npos)
263  flag = "private";
264  else
265  {
266  if (flag == "" && data != "{")
267  flag = "private";
268  collectInfo(data, flag);
269  }
270  }
271  //logger << pub.size() << pri.size() << pro.size() << flush;
272  if (this->pub.size() > 0 || this->pri.size() > 0 || this->pro.size() > 0)
273  return true;
274  else
275  return false;
276 }
277 
278 string Reflection::updateClassDefinition(string className, bool file)
279 {
280  string refDef,typedefs;
281  if (file && !generateClassInfo(className))
282  {
283  return refDef;
284  }
285  else if (!file && !generateClassInfoFromDD(className))
286  {
287  return refDef;
288  }
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;
299  string meth,fld;
300  size_t tes;
301  if (this->pub.size() > 0)
302  {
303  for (unsigned int i = 0; i < this->pub.size(); i++)
304  {
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)
306  {
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,")"," ");
314  strVec methp,methpm;
315  StringUtil::split(methp, meth, (" "));
316  for(unsigned int j = 0; j < methp.size(); j++)
317  {
318  if(methp.at(j)!="")
319  methpm.push_back(methp.at(j));
320  }
321  for(unsigned int j = 0; j < methpm.size(); j++)
322  {
323  if(j==0)
324  {
325  if(methpm.at(0)==this->classN)
326  {
327  refDef += ("me.setReturnType(\"Constructor\");\n");
328  refDef += ("me.setMethodName(\""+methpm.at(j)+"\");\n");
329  }
330  else
331  {
332  refDef += ("me.setReturnType(\""+methpm.at(j)+"\");\n");
333  //typedefs += ("typedef " + methpm.at(j) + " ");
334  }
335  }
336  else if(j==1 && methpm.at(0)!=this->classN)
337  {
338  refDef += ("me.setMethodName(\""+methpm.at(j)+"\");\n");
339  //refDef += (this->classN + methpm.at(j)+" = &"+this->classN+"::"+methpm.at(j)+";\n");
340  //typedefs += ("("+this->classN+"::*" + this->classN + methpm.at(j) + ") (");
341  }
342  else if(methpm.at(j)!="")
343  {
344  refDef += ("argu.push_back(\""+methpm.at(j)+"\");\n");
345  /*typedefs += methpm.at(j);
346  if(j!=methpm.size()-1)
347  typedefs += ",";*/
348  }
349  }
350  /*if(methpm.at(0)!=this->classN)
351  typedefs += ");\n";*/
352  refDef += ("me.setArgumentTypes(argu);\n");
353  refDef += ("if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
354  }
355  else if(this->pub.at(i).find("~")==string::npos)
356  {
357  refDef += ("f.clear();\n");
358  publf += this->pub.at(i);
359  fld = this->pub.at(i);
360  StringUtil::replaceFirst(fld,";","");
361  strVec fldp;
362  StringUtil::split(fldp, fld, (" "));
363  for(unsigned int j = 0; j < fldp.size(); j++)
364  {
365  if(j==0)
366  {
367  refDef += ("f.setType(\""+fldp.at(j)+"\");\n");
368  }
369  else if(j==1)
370  {
371  refDef += ("f.setFieldName(\""+fldp.at(j)+"\");\n");
372  }
373  }
374  if(fldp.size()==2)
375  structinf += (fldp.at(0)+" "+fldp.at(1)+";\n");
376  refDef += ("if(f.getFieldName()!=\"\")\n{\nfldVec.push_back(f);\n}\n");
377  }
378  }
379  }
380  if (this->pri.size() > 0)
381  {
382  for (unsigned int i = 0; i < this->pri.size(); i++)
383  {
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)
385  {
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,")"," ");
393  strVec methp;
394  StringUtil::split(methp, meth, (" "));
395  for(unsigned int j = 0; j < methp.size(); j++)
396  {
397  if(j==0)
398  {
399  if(methp.at(0)==this->classN)
400  {
401  refDef += ("me.setReturnType(\"Constructor\");\n");
402  refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
403  }
404  else
405  refDef += ("me.setReturnType(\""+methp.at(j)+"\");\n");
406  }
407  else if(j==1 && methp.at(0)!=this->classN)
408  {
409  refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
410  }
411  else if(methp.at(j)!="")
412  {
413  refDef += ("argu.push_back(\""+methp.at(j)+"\");\n");
414  }
415  }
416  refDef += ("me.setArgumentTypes(argu);\n");
417  refDef += ("if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
418  }
419  else if(this->pri.at(i).find("~")==string::npos)
420  {
421  refDef += ("f.clear();\n");
422  privf += this->pri.at(i);
423  fld = this->pri.at(i);
424  StringUtil::replaceFirst(fld,";","");
425  strVec fldp;
426  StringUtil::split(fldp, fld, (" "));
427  for(unsigned int j = 0; j < fldp.size(); j++)
428  {
429  if(j==0)
430  {
431  refDef += ("f.setType(\""+fldp.at(j)+"\");\n");
432  }
433  else if(j==1)
434  {
435  refDef += ("f.setFieldName(\""+fldp.at(j)+"\");\n");
436  }
437  }
438  if(fldp.size()==2)
439  structinf += (fldp.at(0)+" "+fldp.at(1)+";\n");
440  refDef += ("if(f.getFieldName()!=\"\")\n{\nfldVec.push_back(f);\n}\n");
441  }
442  }
443  }
444  if (this->pro.size() > 0)
445  {
446  for (unsigned int i = 0; i < this->pro.size(); i++)
447  {
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)
449  {
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,")"," ");
457  strVec methp;
458  StringUtil::split(methp, meth, (" "));
459  for(unsigned int j = 0; j < methp.size(); j++)
460  {
461  if(j==0)
462  {
463  if(methp.at(0)==this->classN)
464  {
465  refDef += ("me.setReturnType(\"Constructor\");\n");
466  refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
467  }
468  else
469  refDef += ("me.setReturnType(\""+methp.at(j)+"\");\n");
470  }
471  else if(j==1 && methp.at(0)!=this->classN)
472  {
473  refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
474  }
475  else if(methp.at(j)!="")
476  {
477  refDef += ("argu.push_back(\""+methp.at(j)+"\");\n");
478  }
479  }
480  refDef += ("me.setArgumentTypes(argu);\n");
481  refDef += ("if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
482  }
483  else if(this->pro.at(i).find("~")==string::npos)
484  {
485  refDef += ("f.clear();\n");
486  protf += this->pro.at(i);
487  fld = this->pro.at(i);
488  StringUtil::replaceFirst(fld,";","");
489  strVec fldp;
490  StringUtil::split(fldp, fld, (" "));
491  for(unsigned int j = 0; j < fldp.size(); j++)
492  {
493  if(j==0)
494  {
495  refDef += ("f.setType(\""+fldp.at(j)+"\");\n");
496  }
497  else if(j==1)
498  {
499  refDef += ("f.setFieldName(\""+fldp.at(j)+"\");\n");
500  }
501  }
502  if(fldp.size()==2)
503  structinf += (fldp.at(0)+" "+fldp.at(1)+";\n");
504  refDef += ("if(f.getFieldName()!=\"\")\n{\nfldVec.push_back(f);\n}\n");
505  }
506  }
507  }
508  //refDef += ("\nclassInfo.setMeths(meths);");
509  //refDef += ("\nclassInfo.setMethods(methVec);");
510  //refDef += ("\nclassInfo.setFields(fldVec);");
511  refDef += "\nreturn classInfo;\n}\n";
512  refDef += "}";
513  structinf += "};\n";
514  refDef = (typedefs + structinf + refDef);
515  return refDef;
516 }
517 
518 string Reflection::updateTemplateContextDefinition(string className, bool file)
519 {
520  string refDef;
521  if (file && !generateClassInfo(className))
522  {
523  return refDef;
524  }
525  else if (!file && !generateClassInfoFromDD(className))
526  {
527  return refDef;
528  }
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}";
534  return refDef;
535 }
536 
537 
538 propMap Reflection::getDbTableInfo(string file)
539 {
540  propMap tabInfo;
541  string temp;
542  strVec all;
543  ifstream infile;
544  infile.open(file.c_str());
545  if(infile)
546  {
547  while(getline(infile,temp))
548  {
549  if(temp!="")
550  all.push_back(temp);
551  }
552  for(unsigned int i=0;i<(all.size()/2);i++)
553  {
554  tabInfo[all.at(i)] = all.at(i+1);
555  }
556  }
557  return tabInfo;
558 }
559 
560 strVec Reflection::getAfcObjectData(string className,bool object,strVec& privf, bool &isOpForSet)
561 {
562  isOpForSet = false;
563  strVec refDef;
564  if (!generateClassInfo(className))
565  {
566  return refDef;
567  }
568  strVec publf, protf ,publm, privm, protm;
569 
570  size_t tes;
571  if (this->pub.size() > 0)
572  {
573  for (unsigned int i = 0; i < this->pub.size(); i++)
574  {
575  if((tes=this->pub.at(i).find("("))!=string::npos && (tes=this->pub.at(i).find(")"))!=string::npos)
576  {
577  publm.push_back(this->pub.at(i));
578 
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)
586  {
587  if(meth.find("<")!=string::npos)
588  {
589  isOpForSet = true;
590  }
591  else if(meth.find(">")!=string::npos)
592  {
593  isOpForSet = true;
594  }
595  }
596  }
597  else
598  {
599  publf.push_back(this->pub.at(i));
600  }
601  }
602  }
603  if (this->pri.size() > 0)
604  {
605  for (unsigned int i = 0; i < this->pri.size(); i++)
606  {
607  if((tes=this->pri.at(i).find("("))!=string::npos && (tes=this->pri.at(i).find(")"))!=string::npos)
608  {
609  privm.push_back(this->pri.at(i));
610  }
611  else
612  {
613  privf.push_back(this->pri.at(i));
614  }
615  }
616  }
617  if (this->pro.size() > 0)
618  {
619  for (unsigned int i = 0; i < this->pro.size(); i++)
620  {
621  if((tes=this->pro.at(i).find("("))!=string::npos && (tes=this->pro.at(i).find(")"))!=string::npos)
622  {
623  protm.push_back(this->pro.at(i));
624  }
625  }
626  }
627  if(!object)
628  {
629  return publm;
630  }
631  else
632  {
633  return publf;
634  }
635 }
636 
637 strVec Reflection::getAfcObjectData(string className,bool object)
638 {
639  strVec refDef;
640  if (!generateClassInfo(className))
641  {
642  return refDef;
643  }
644  strVec publf, privf, protf ,publm, privm, protm;
645 
646  size_t tes;
647  if (this->pub.size() > 0)
648  {
649  for (unsigned int i = 0; i < this->pub.size(); i++)
650  {
651  if((tes=this->pub.at(i).find("("))!=string::npos && (tes=this->pub.at(i).find(")"))!=string::npos)
652  {
653  publm.push_back(this->pub.at(i));
654  }
655  else
656  {
657  publf.push_back(this->pub.at(i));
658  }
659  }
660  }
661  if (this->pri.size() > 0)
662  {
663  for (unsigned int i = 0; i < this->pri.size(); i++)
664  {
665  if((tes=this->pri.at(i).find("("))!=string::npos && (tes=this->pri.at(i).find(")"))!=string::npos)
666  {
667  privm.push_back(this->pri.at(i));
668  }
669  }
670  }
671  if (this->pro.size() > 0)
672  {
673  for (unsigned int i = 0; i < this->pro.size(); i++)
674  {
675  if((tes=this->pro.at(i).find("("))!=string::npos && (tes=this->pro.at(i).find(")"))!=string::npos)
676  {
677  protm.push_back(this->pro.at(i));
678  }
679  }
680  }
681  if(!object)
682  {
683  return publm;
684  }
685  else
686  {
687  return publf;
688  }
689 }
690 
691 string Reflection::generateClassDefinitionsAll(strVec all,string &includeRef)
692 {
693  string ret = "";
694  //includeRef = "#ifndef REFLECTOR_H_\n#define REFLECTOR_H_\n#include \"ClassInfo.h\"\n#include \"string\"\n#include \"Method.h\"\n#include \"Field.h\"\n";
695  //includeRef += "#include \"XmlParser.h\"\n#include <stdio.h>\n#include <sys/wait.h>\n#include <stdexcept>\n#include <execinfo.h>\n#include <dlfcn.h>\n#include <cxxabi.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include \"string\"\n#include <sstream>\n#include <typeinfo>\n";
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)
700  {
701  //logger << "\nstarting for classes " << all.size() << "\n" << flush;
702  ret += this->generateClassDefinitions(all.at(var),inc,typedefs,classes,methods,opers);
703 
704  }
705  /*ret += "ClassInfo Reflector::getClassInfo(string className)\n{\n";
706  ret += classes;
707  ret += "\n\treturn info;\n}\n";
708  ret += "void* Reflector::invokeMethod(void* instance,Method method,vals values)\n{\n";
709  ret += methods;
710  ret += "\n\treturn returnValue;\n}\n";
711  ret += "bool Reflector::instanceOf(void* instance,string className)\n{\n";
712  ret += "Trace tr;\nstring cn = tr.getClassName(instance);\nif(cn==className)\nreturn true;\nelse\nreturn false;\n}\n";*/
713  ret += methods+opers+ "\n}\n";
714  ret = (inc+ret);
715  return ret;
716 }
717 
718 string Reflection::generateClassDefinitions(string includeDir,string &includesDefs,string &typedefs,string &classes,string &methods,string &opers)
719 {
720  strVec includes = list(includeDir);
721  string ret,in,ty,cl,me;
722  for (unsigned int var = 0; var < includes.size(); ++var)
723  {
724  //logger << "\ngenerating for file" << includes.at(var) << "\n" << flush;
725  string includesDefs1,typedefs1,classes1,methods1,opers1;
726  string ret1 = generateClassDefinition(includes.at(var),includesDefs1,typedefs1,classes1,methods1,opers1);
727  ret += ret1;
728  if(ret1!="")
729  {
730  includesDefs += includesDefs1;
731  typedefs += typedefs1;
732  classes += classes1;
733  methods += methods1;
734  opers += opers1;
735  }
736  else
737  {
738  invalidcls[includes.at(var)] = true;
739  }
740  //logger << "\ndone generating for file" << includes.at(var) << "\n" << flush;
741  }
742  return ret;
743 }
744 
745 string Reflection::generateClassDefinition(string className,string &includesDefs,string &typedefs,string &classes,string &methods,string &opers)
746 {
747  string refDef;
748  if (!generateClassInfo(className))
749  {
750  return refDef;
751  }
752  classes += "\tif(className==\""+this->classN+"\")\n\t\treturn get"+this->classN+"();\n";
753  includesDefs += "#include \"" + this->classN + ".h\"\n";
754  //string structinf = "\nstruct struct"+this->classN+"{\n";
755  refDef += "ClassInfo getReflectionCIFor" + this->classN + "()\n{\nClassInfo classInfo;";
756  refDef += ("\nclassInfo.setClassName(\"" + this->classN + "\");");
757  //refDef += ("\nclassInfo.setInstance(new " + 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;
762  string meth,fld;
763  size_t tes;
764  bool ctorisp = false,ddtorisp = false;;
765  if (this->pub.size() > 0)
766  {
767  for (unsigned int i = 0; i < this->pub.size(); i++)
768  {
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)
770  {
771  refDef += ("ctor.clear();\nme.clear();\n");
772  publm += this->pub.at(i);
773  meth = this->pub.at(i);
774  StringUtil::replaceFirst(meth,";","");
775 
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("("));
780  //StringUtil::replaceFirst(meth,")"," ");
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++)
785  {
786  if(methp.at(j)!="")
787  methpm.push_back(methp.at(j));
788  }
789  for(unsigned int j = 0; j < argp.size(); j++)
790  {
791  if(argp.at(j)!="" && argp.at(j)!="(")
792  {
793  string argpmtemp = argp.at(j);
794  argpmtemp = argpmtemp.substr(argpmtemp.find_first_not_of(" "));
795  argpm.push_back(argpmtemp);
796  }
797  }
798  string typdefName,methsd,valsd,valsa;
799  //bool ctor = false;
800  if(methpm.size()>0 && methpm.at(0).find("virtual")!=string::npos)
801  return "";
802  for(unsigned int j = 0; j < methpm.size(); j++)
803  {
804  if(j==0)
805  {
806  if(methpm.at(0)==this->classN)
807  {
808  refDef += ("ctor.setName(\""+this->classN+"\");\n");
809  //refDef += ("me.setMethodName(\""+this->classN+methpm.at(j)+"\");\n");
810  //ctor = true;
811  methsd += (this->classN);
812  }
813  else if(meth.find(" operator")==string::npos)
814  {
815  refDef += ("me.setReturnType(\""+methpm.at(j)+"\");\n");
816  typedefs += ("typedef " + methpm.at(j) + " ");
817  }
818  }
819  else if(j==1 && methpm.at(0)!=this->classN && meth.find(" operator")==string::npos)
820  {
821 
822  //refDef += (this->classN + methpm.at(j)+" = &"+this->classN+"::"+methpm.at(j)+";\n");
823  typedefs += ("("+this->classN+"::*"+this->classN +methpm.at(j));
824  methsd += (this->classN+methpm.at(j));
825  }
826  /*else if(methpm.at(j)!="")
827  {
828  refDef += ("argu.push_back(\""+methpm.at(j)+"\");\n");
829  valsd += "\t\t"+(methpm.at(j) + " *_" + CastUtil::lexical_cast<string>(j-1)+" = ("+methpm.at(j)+"*)values.at("+CastUtil::lexical_cast<string>(j-2)+");");
830  valsa += "*_" + CastUtil::lexical_cast<string>(j-1);
831  if(methpm.at(0)!=this->classN)
832  {
833  typedefs += methpm.at(j);
834  typdefName += methpm.at(j);
835  methsd += methpm.at(j);
836  if(j!=methpm.size()-1)
837  {
838  typdefName += ",";
839  valsa += ",";
840  }
841  }
842  }*/
843  }
844 
845  bool tmpltarg = false;
846  for(unsigned int j = 0; j < argpm.size(); j++)
847  {
848  if(tmpltarg && argpm.at(j).find(">")!=string::npos)
849  {
850  string ttt = argpmtemp.at(argpmtemp.size()-1)+","+argpm.at(j);
851  argpmtemp.at(argpmtemp.size()-1) = ttt;
852  }
853  else if(argpm.at(j).find("<")!=string::npos)
854  {
855  argpmtemp.push_back(argpm.at(j));
856  tmpltarg = true;
857  }
858  else
859  {
860  argpmtemp.push_back(argpm.at(j));
861  }
862  }
863  argpm = argpmtemp;
864  for(unsigned int j = 0; j < argpm.size(); j++)
865  {
866  strVec argtn;
867  string type12 = "";
868  if(argpm.at(j).find("*")!=string::npos)
869  type12 = "*";
870  else if(argpm.at(j).find("&")!=string::npos)
871  type12 = "&";
872  StringUtil::split(argtn, argpm.at(j), (" "));
873  //logger << "testing::::" << argpm.at(j) << argtn.size();
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=="*")
877  {
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)+");");
880  }
881  else if(argtn.at(0).find("&")!=string::npos || type12=="&")
882  {
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)+");");
885  }
886  else
887  valsd += "\t\t"+(argtn.at(0) + " *_" + CastUtil::lexical_cast<string>(j)+" = ("+argtn.at(0)+"*)values.at("+CastUtil::lexical_cast<string>(j)+");");
888  if(type12=="*")
889  valsa += "_" + CastUtil::lexical_cast<string>(j);
890  else
891  valsa += "*_" + CastUtil::lexical_cast<string>(j);
892  //if(methpm.at(0)!=this->classN)
893  //{
894  typedefs += argtn.at(0);
895  typdefName += argtn.at(0);
896  methsd += argtn.at(0) + (type12=="*"?"ptr":"");
897  if(j!=argpm.size()-1)
898  {
899  typdefName += ",";
900  valsa += ",";
901  }
902  //}
903  }
904  if(meth.find(" operator")!=string::npos)
905  {
906  if(meth.find("<")!=string::npos)
907  {
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")
910  {
911  opers += valsd;
912  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj<"+valsa+";";
913  opers += "\n\treturn returnValue;";
914  }
915  else
916  {
917  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
918  opers += valsd;
919  opers += "\n\t*_retVal = (*_obj<"+valsa+");";
920  opers += "\n\treturn _retVal;";
921  }
922  opers += "\n}";
923  }
924  else if(meth.find(">")!=string::npos)
925  {
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")
928  {
929  opers += valsd;
930  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj>"+valsa+";";
931  opers += "\n\treturn returnValue;";
932  }
933  else
934  {
935  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
936  opers += valsd;
937  opers += "\n\t*_retVal = (*_obj>"+valsa+");";
938  opers += "\n\treturn _retVal;";
939  }
940  opers += "\n}";
941  }
942  else if(meth.find("==")!=string::npos)
943  {
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")
946  {
947  opers += valsd;
948  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj=="+valsa+";";
949  opers += "\n\treturn returnValue;";
950  }
951  else
952  {
953  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
954  opers += valsd;
955  opers += "\n\t*_retVal = (*_obj=="+valsa+");";
956  opers += "\n\treturn _retVal;";
957  }
958  opers += "\n}";
959  }
960  else if(meth.find("!=")!=string::npos)
961  {
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")
964  {
965  opers += valsd;
966  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj!="+valsa+";";
967  opers += "\n\treturn returnValue;";
968  }
969  else
970  {
971  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
972  opers += valsd;
973  opers += "\n\t*_retVal = (*_obj!="+valsa+");";
974  opers += "\n\treturn _retVal;";
975  }
976  opers += "\n}";
977  }
978  else if(meth.find("<=")!=string::npos)
979  {
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")
982  {
983  opers += valsd;
984  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj<="+valsa+";";
985  opers += "\n\treturn returnValue;";
986  }
987  else
988  {
989  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
990  opers += valsd;
991  opers += "\n\t*_retVal = (*_obj<="+valsa+");";
992  opers += "\n\treturn _retVal;";
993  }
994  opers += "\n}";
995  }
996  else if(meth.find(">=")!=string::npos)
997  {
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")
1000  {
1001  opers += valsd;
1002  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj>="+valsa+";";
1003  opers += "\n\treturn returnValue;";
1004  }
1005  else
1006  {
1007  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
1008  opers += valsd;
1009  opers += "\n\t*_retVal = (*_obj>="+valsa+");";
1010  opers += "\n\treturn _retVal;";
1011  }
1012  opers += "\n}";
1013  }
1014  else if(meth.find("!")!=string::npos)
1015  {
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")
1018  {
1019  opers += valsd;
1020  opers += "\n\tvoid* returnValue=NULL;\n\t!*_obj;";
1021  opers += "\n\treturn returnValue;";
1022  }
1023  else
1024  {
1025  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
1026  opers += valsd;
1027  opers += "\n\t*_retVal = (!*_obj);";
1028  opers += "\n\treturn _retVal;";
1029  }
1030  opers += "\n}";
1031  }
1032  else if(meth.find("<<")!=string::npos)
1033  {
1034 
1035  }
1036  else if(meth.find(">>")!=string::npos)
1037  {
1038 
1039  }
1040  else if(meth.find("+")!=string::npos)
1041  {
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")
1044  {
1045  opers += valsd;
1046  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj+"+valsa+";";
1047  opers += "\n\treturn returnValue;";
1048  }
1049  else
1050  {
1051  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
1052  opers += valsd;
1053  opers += "\n\t*_retVal = (*_obj+"+valsa+");";
1054  opers += "\n\treturn _retVal;";
1055  }
1056  opers += "\n}";
1057  }
1058  else if(meth.find("-")!=string::npos)
1059  {
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")
1062  {
1063  opers += valsd;
1064  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj-"+valsa+";";
1065  opers += "\n\treturn returnValue;";
1066  }
1067  else
1068  {
1069  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
1070  opers += valsd;
1071  opers += "\n\t*_retVal = (*_obj-"+valsa+");";
1072  opers += "\n\treturn _retVal;";
1073  }
1074  opers += "\n}";
1075  }
1076  else if(meth.find("/")!=string::npos)
1077  {
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")
1080  {
1081  opers += valsd;
1082  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj/"+valsa+";";
1083  opers += "\n\treturn returnValue;";
1084  }
1085  else
1086  {
1087  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
1088  opers += valsd;
1089  opers += "\n\t*_retVal = (*_obj/"+valsa+");";
1090  opers += "\n\treturn _retVal;";
1091  }
1092  opers += "\n}";
1093  }
1094  else if(meth.find("*")!=string::npos)
1095  {
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")
1098  {
1099  opers += valsd;
1100  opers += "\n\tvoid* returnValue=NULL;\n\t*_obj*"+valsa+";";
1101  opers += "\n\treturn returnValue;";
1102  }
1103  else
1104  {
1105  opers += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
1106  opers += valsd;
1107  opers += "\n\t*_retVal = (*_obj*"+valsa+");";
1108  opers += "\n\treturn _retVal;";
1109  }
1110  opers += "\n}";
1111  }
1112  else if(meth.find("&&")!=string::npos)
1113  {
1114 
1115  }
1116  else if(meth.find("&")!=string::npos)
1117  {
1118 
1119  }
1120  else if(meth.find("||")!=string::npos)
1121  {
1122 
1123  }
1124  else if(meth.find("|")!=string::npos)
1125  {
1126 
1127  }
1128  else if(meth.find("[")!=string::npos && meth.find("]")!=string::npos)
1129  {
1130 
1131  }
1132  else if(meth.find("(")!=string::npos && meth.find(")")!=string::npos)
1133  {
1134 
1135  }
1136  }
1137  else
1138  {
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)
1144  {
1145  StringUtil::replaceFirst(methsd,"std::","");
1146  }
1147  else if(methsd.find("::")!=string::npos)
1148  {
1149  StringUtil::replaceFirst(methsd,"::","ns");
1150  }
1151  //StringUtil::replaceFirst(methsd,"*","ptr");
1152  //StringUtil::replaceFirst(methsd,"&","adr");
1153  if(methpm.at(0)!=this->classN)
1154  {
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")
1158  {
1159  methods += valsd;
1160  methods += "\n\tvoid* returnValue=NULL;\n\t_obj->"+methpm.at(1)+"("+valsa+");";
1161  methods += "\n\treturn returnValue;";
1162  }
1163  else
1164  {
1165  methods += "\n\t"+methpm.at(0)+" *_retVal=new "+methpm.at(0)+";\n";
1166  methods += valsd;
1167  methods += "\n\t*_retVal = (_obj->"+methpm.at(1)+"("+valsa+"));";
1168  methods += "\n\treturn _retVal;";
1169  }
1170  methods += "\n}";
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");
1176  }
1177  else
1178  {
1179  typedefs += (") ("+typdefName+");\n");
1180  methods += "\nvoid* invokeReflectionCICtorFor"+methsd+"(vals values)\n{";
1181  methods += "\n\t"+this->classN+" *_retVal = NULL;\n";
1182  methods += valsd;
1183  methods += "\n\t_retVal = (new "+this->classN+"("+valsa+"));";
1184  methods += "\n\treturn _retVal;";
1185  methods += "\n}";
1186  refDef += ("ctor.setName(\""+methsd+"\");\n");
1187  refDef += ("ctor.setArgumentTypes(argu);\n");
1188  refDef += ("argu.clear();\n");
1189  refDef += ("classInfo.addConstructor(ctor);\n");
1190  ctorisp = true;
1191  }
1192  }
1193  }
1194  else if(this->pub.at(i).find("~")==string::npos)
1195  {
1196  refDef += ("f.clear();\n");
1197  publf += this->pub.at(i);
1198  fld = this->pub.at(i);
1199  StringUtil::replaceFirst(fld,";","");
1200  strVec fldp;
1201  StringUtil::split(fldp, fld, (" "));
1202  if(fldp.size()>1)
1203  {
1204  for(unsigned int j = 0; j < fldp.size(); j++)
1205  {
1206  if(j==0)
1207  {
1208  refDef += ("f.setType(\""+fldp.at(j)+"\");\n");
1209  }
1210  else if(j==1)
1211  {
1212  refDef += ("f.setFieldName(\""+fldp.at(j)+"\");\n");
1213  }
1214  }
1215  //if(fldp.size()==2)
1216  // structinf += (fldp.at(0)+" "+fldp.at(1)+";\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");
1219  }
1220  else
1221  {
1222  //logger << fld << " error" << endl;
1223  }
1224  }
1225  else if(this->pub.at(i).find("~")!=string::npos)
1226  {
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+"();";
1230  methods += "\n}";
1231  ddtorisp = true;
1232  }
1233  }
1234  if(!ctorisp)
1235  {
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;";
1242  methods += "\n}";
1243  refDef += ("ctor.setArgumentTypes(argu);\n");
1244  refDef += ("argu.clear();\n");
1245  refDef += ("classInfo.addConstructor(ctor);\n");
1246  }
1247  if(!ddtorisp)
1248  {
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+"();";
1252  methods += "\n}";
1253  ddtorisp = true;
1254  }
1255  }
1256  if (this->pri.size() > 0)
1257  {
1258  for (unsigned int i = 0; i < this->pri.size(); i++)
1259  {
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)
1261  {
1262  //refDef += ("me.clear();\n");
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,")"," ");
1269  strVec methp;
1270  StringUtil::split(methp, meth, (" "));
1271  for(unsigned int j = 0; j < methp.size(); j++)
1272  {
1273  if(j==0)
1274  {
1275  if(methp.at(0)==this->classN)
1276  {
1277  //refDef += ("me.setReturnType(\"Constructor\");\n");
1278  //refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
1279  }
1280  else
1281  {
1282  //refDef += ("me.setReturnType(\""+methp.at(j)+"\");\n");
1283  }
1284  }
1285  else if(j==1 && methp.at(0)!=this->classN)
1286  {
1287  //refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
1288  }
1289  else if(methp.at(j)!="")
1290  {
1291  //refDef += ("argu.push_back(\""+methp.at(j)+"\");\n");
1292  }
1293  }
1294  //refDef += ("me.setArgumentTypes(argu);\n");
1295  //refDef += ("if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
1296  }
1297  else if(this->pri.at(i).find("~")==string::npos)
1298  {
1299  refDef += ("f.clear();\n");
1300  privf += this->pri.at(i);
1301  fld = this->pri.at(i);
1302  StringUtil::replaceFirst(fld,";","");
1303  strVec fldp;
1304  StringUtil::split(fldp, fld, (" "));
1305  if(fldp.size()>1)
1306  {
1307  for(unsigned int j = 0; j < fldp.size(); j++)
1308  {
1309  if(j==0)
1310  {
1311  refDef += ("f.setType(\""+fldp.at(j)+"\");\n");
1312  }
1313  else if(j==1)
1314  {
1315  refDef += ("f.setFieldName(\""+fldp.at(j)+"\");\n");
1316  }
1317  }
1318  //if(fldp.size()==2)
1319  // structinf += (fldp.at(0)+" "+fldp.at(1)+";\n");
1320  //methods += "\n"+fldp.at(0)+" invokeReflectionCIFieldFor"+this->classN+fldp.at(1)+"(void* instance)\n{\n\t"+this->classN+" *_obj = ("+this->classN+"*)instance;\nstruct"
1321  //+this->classN+" *__obj=(struct"+this->classN+"*)_obj;\n\treturn __obj->"+fldp.at(1)+";\n}\n";
1322  refDef += ("if(f.getFieldName()!=\"\")\n{\nclassInfo.addField(f);\n}\n");
1323  }
1324  else
1325  {
1326  //logger << fld << " error" << endl;
1327  }
1328  }
1329  }
1330  }
1331  if (this->pro.size() > 0)
1332  {
1333  for (unsigned int i = 0; i < this->pro.size(); i++)
1334  {
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)
1336  {
1337  //refDef += ("me.clear();\n");
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,")"," ");
1344  strVec methp;
1345  StringUtil::split(methp, meth, (" "));
1346  for(unsigned int j = 0; j < methp.size(); j++)
1347  {
1348  if(j==0)
1349  {
1350  if(methp.at(0)==this->classN)
1351  {
1352  //refDef += ("me.setReturnType(\"Constructor\");\n");
1353  //refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
1354  }
1355  else
1356  {
1357  //refDef += ("me.setReturnType(\""+methp.at(j)+"\");\n");
1358  }
1359  }
1360  else if(j==1 && methp.at(0)!=this->classN)
1361  {
1362  //refDef += ("me.setMethodName(\""+methp.at(j)+"\");\n");
1363  }
1364  else if(methp.at(j)!="")
1365  {
1366  //refDef += ("argu.push_back(\""+methp.at(j)+"\");\n");
1367  }
1368  }
1369  //refDef += ("me.setArgumentTypes(argu);\n");
1370  //refDef += ("if(me.getMethodName()!=\"\")\n{\nmethVec.push_back(me);\n}\n");
1371  }
1372  else if(this->pro.at(i).find("~")==string::npos)
1373  {
1374  refDef += ("f.clear();\n");
1375  protf += this->pro.at(i);
1376  fld = this->pro.at(i);
1377  StringUtil::replaceFirst(fld,";","");
1378  strVec fldp;
1379  StringUtil::split(fldp, fld, (" "));
1380  if(fldp.size()>1)
1381  {
1382  for(unsigned int j = 0; j < fldp.size(); j++)
1383  {
1384  if(j==0)
1385  {
1386  refDef += ("f.setType(\""+fldp.at(j)+"\");\n");
1387  }
1388  else if(j==1)
1389  {
1390  refDef += ("f.setFieldName(\""+fldp.at(j)+"\");\n");
1391  }
1392  }
1393  //if(fldp.size()==2)
1394  // structinf += (fldp.at(0)+" "+fldp.at(1)+";\n");
1395  //methods += "\n"+fldp.at(0)+" invokeReflectionCIFieldFor"+this->classN+fldp.at(1)+"(void* instance)\n{\n\t"+this->classN+" *_obj = ("+this->classN+"*)instance;\nstruct"
1396  //+this->classN+" *__obj=(struct"+this->classN+"*)_obj;\n\treturn __obj->"+fldp.at(1)+";\n}\n";
1397  refDef += ("if(f.getFieldName()!=\"\")\n{\nclassInfo.addField(f);\n}\n");
1398  }
1399  else
1400  {
1401  //logger << fld << " error" << endl;
1402  }
1403  }
1404  }
1405  }
1406  //refDef += ("\nclassInfo.setMeths(meths);");
1407  //refDef += ("\nclassInfo.setMethods(methVec);");
1408  //refDef += ("\nclassInfo.setFields(fldVec);");
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));}";
1414  //refDef = (structinf+"};\n"+refDef);
1415  return refDef;
1416 }
1417 
1418 string Reflection::generateSerDefinitionAll(strVec all,string &includeRef, bool isBinary,string& objs, string& ajaxret, string& headers, string& typerefs)
1419 {
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)
1425  {
1426  rert1 += this->generateSerDefinitions(all.at(var),includeRef,typedefs,classes,methods,isBinary,objs,ajaxret,headers,typerefs);
1427  }
1428  includeRef += ("extern \"C\"{\n" + classes + typedefs + methods);
1429  ret += includeRef;
1430  ret += "}\n";
1431  includeRef += typedefs;
1432  return ret;
1433 }
1434 
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)
1437 {
1438  strVec includes = list(includeDir);
1439  string ret;
1440  for (unsigned int var = 0; var < includes.size(); ++var)
1441  {
1442  //logger << "\ngenerating Ser for file" << includes.at(var) << "\n" << flush;
1443  if(invalidcls.find(includes.at(var))==invalidcls.end())
1444  {
1445  ret = generateSerDefinition(includes.at(var),includesDefs,typedefs,classes,methods);
1446  ret += generateSerDefinitionBinary(includes.at(var),includesDefs,typedefs,classes,methods);
1447  strVec pinfo;
1448  bool isOpForSet = false;
1449  strVec minfo = getAfcObjectData(includes.at(var),false,pinfo,isOpForSet);
1450  pinfo.clear();
1451  strVec info = getAfcObjectData(includes.at(var),true,pinfo,isOpForSet);
1452  ajaxret += AfcUtil::generateJsObjects(info,this->classN,headers,includeDir,objs,pinfo,isOpForSet,typerefs,minfo);
1453  }
1454  //logger << "\ndone generating Ser for file" << includes.at(var) << "\n" << flush;
1455  }
1456  return ret;
1457 }
1458 
1459 string Reflection::generateSerDefinition(string className,string &includesDefs,string &typedefs,string &classes,string &methods)
1460 {
1461  string refDef;
1462  string opers;
1463  if (!generateClassInfo(className))
1464  {
1465  return refDef;
1466  }
1467  prosetser = false;
1468  //classes += "\tif(className==\""+this->classN+"\")\n\t\tobjXml = get"+this->classN+"XML(t);\n";
1469  //refDef += "\tif(className==\""+this->classN+"\")\n\t\tt = getObject"+this->classN+"(objXml);\n";
1470  includesDefs += "#include \"" + this->classN + ".h\"\n";
1471  //string structinf = "\nstruct struct"+this->classN+"{\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";
1479 
1480  string publf, privf, protf ,publm, privm, protm;
1481  string meth,fld;
1482  size_t tes;
1483  strVec fldnames;
1484  if (this->pri.size() > 0)
1485  {
1486  for (unsigned int i = 0; i < this->pri.size(); i++)
1487  {
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))
1489  {
1490  fld = this->pri.at(i);
1491  StringUtil::replaceFirst(fld,";","");
1492  strVec fldp;
1493  StringUtil::split(fldp, fld, (" "));
1494  if(fldp.size()==2)
1495  {
1496  string nam = fldp.at(1);
1497  fldnames.push_back(fldp.at(0));
1498  fldnames.push_back(nam);
1499  }
1500  }
1501  }
1502  }
1503  if (this->pro.size() > 0)
1504  {
1505  for (unsigned int i = 0; i < this->pro.size(); i++)
1506  {
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))
1508  {
1509  fld = this->pro.at(i);
1510  StringUtil::replaceFirst(fld,";","");
1511  strVec fldp;
1512  StringUtil::split(fldp, fld, (" "));
1513  if(fldp.size()==2)
1514  {
1515  string nam = fldp.at(1);
1516  fldnames.push_back(fldp.at(0));
1517  fldnames.push_back(nam);
1518  }
1519  }
1520  }
1521  }
1522  if (this->pub.size() > 0)
1523  {
1524  for (unsigned int i = 0; i < this->pub.size(); i++)
1525  {
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))
1527  {
1528  fld = pub.at(i);
1529  RegexUtil::replace(fld, "[\t]+", " ");
1530  RegexUtil::replace(fld, "[ ]+", " ");
1531  RegexUtil::replace(fld, "[ ?, ?]+", ",");
1532  StringUtil::replaceFirst(fld,";","");
1533  bool ptr = false;
1534  if(fld.find("*")!=string::npos)
1535  {
1536  ptr = true;
1537  StringUtil::replaceFirst(fld,"*","");
1538  }
1539  vector<string> fldp;
1540  StringUtil::split(fldp, fld, (" "));
1541  if(fldp.size()==2)
1542  {
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")
1546  {
1547  if(!ptr)
1548  {
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";
1553  }
1554  else
1555  {
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";
1560  }
1561  }
1562  else if(fldp.at(0)=="Date")
1563  {
1564  if(!ptr)
1565  {
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";
1570  }
1571  else
1572  {
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";
1577  }
1578  }
1579  else if(fldp.at(0)=="BinaryData")
1580  {
1581  if(!ptr)
1582  {
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";
1587  }
1588  else
1589  {
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";
1594  }
1595  }
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)
1597  {
1598  string stlcnt = fldp.at(0);
1599  string stltyp = fldp.at(0);
1600  string contType;
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)
1607  {
1608  contType = "std::vector<";
1609  stlcnttyp = "Vec";
1610  }
1611  else if(fldp.at(0).find("queue")!=string::npos)
1612  {
1613  contType = "std::queue<";
1614  stlcnttyp = "Q";
1615  }
1616  else if(fldp.at(0).find("deque")!=string::npos)
1617  {
1618  contType = "std::deque<";
1619  stlcnttyp = "Dq";
1620  }
1621  else if(fldp.at(0).find("list")!=string::npos)
1622  {
1623  contType = "std::list<";
1624  stlcnttyp = "Lis";
1625  }
1626  else if(fldp.at(0).find("multiset")!=string::npos)
1627  {
1628  contType = "std::multiset<";
1629  stlcnttyp = "MulSet";
1630  }
1631  else
1632  {
1633  contType = "std::set<";
1634  stlcnttyp = "Set";
1635  }
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," ","");
1646 
1647  contType += stlcnt + ",";
1648 
1649  if(!ptr)
1650  {
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)+")");
1654  else
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";
1660  else
1661  typedefs += "if(nam==\""+fldp.at(1)+"\")\n__obj->"+fldp.at(1)+" = *("+fldp.at(0)+"*)unSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).renderChildren());\n";
1662  }
1663  else
1664  {
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)+")");
1668  else
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";
1674  else
1675  typedefs += "if(nam==\""+fldp.at(1)+"\")\n__obj->"+fldp.at(1)+" = ("+fldp.at(0)+"*)unSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).renderChildren());\n";
1676  }
1677  }
1678  else
1679  {
1680  if(!ptr)
1681  {
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";
1687  }
1688  else
1689  {
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";
1695  }
1696  }
1697  //structinf += (fldp.at(0)+" "+fldp.at(1)+";\n");
1698  }
1699  }
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)
1702  {
1703  meth = pub.at(i);
1704  StringUtil::replaceFirst(meth,";","");
1705  RegexUtil::replace(meth, "[\t]+", " ");
1706  RegexUtil::replace(meth, "[ ]+", " ");
1707  RegexUtil::replace(meth, "[ ?, ?]+", ",");
1708  bool ptr = false;
1709  if(meth.find("*")!=string::npos)
1710  {
1711  ptr = true;
1712  StringUtil::replaceFirst(meth,"*","");
1713  }
1714 
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("("));
1719 
1720  if(meth.find("operator")!=string::npos)
1721  {
1722  if(meth.find("<")!=string::npos)
1723  {
1724  prosetser = true;
1725  }
1726  else if(meth.find(">")!=string::npos)
1727  {
1728  prosetser = true;
1729  }
1730  }
1731  else
1732  {
1733  //StringUtil::replaceFirst(meth,")"," ");
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++)
1738  {
1739  if(methp.at(j)!="")
1740  methpm.push_back(methp.at(j));
1741  }
1742  for(unsigned int j = 0; j < argp.size(); j++)
1743  {
1744  if(argp.at(j)!="" && argp.at(j)!="(")
1745  {
1746  string tty = argp.at(j);
1747  StringUtil::trim(tty);
1748  if(tty.find(" ")!=string::npos)
1749  {
1750  vector<string> temargt = StringUtil::split(tty, " ");
1751  argpm.push_back(temargt.at(0));
1752  }
1753  else
1754  {
1755  argpm.push_back(tty);
1756  }
1757  }
1758  }
1759 
1760  if(methpm.at(0)!=this->classN)
1761  {
1762  for(unsigned int k = 0; k < fldnames.size(); k=k+2)
1763  {
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")
1766  {
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")
1769  {
1770  if(!ptr)
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";
1772  else
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";
1774  }
1775  else if(argpm.at(0)=="Date")
1776  {
1777  if(!ptr)
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";
1779  else
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";
1781  }
1782  else if(argpm.at(0)=="BinaryData")
1783  {
1784  if(!ptr)
1785  typedefs += "if(nam==\""+fldnames.at(k+1)+"\")\n__obj->"+methpm.at(1)+"(*(BinaryData::unSerilaize(root.getChildElements().at(i).getText())));\n";
1786  else
1787  typedefs += "if(nam==\""+fldnames.at(k+1)+"\")\n__obj->"+methpm.at(1)+"((BinaryData::unSerilaize(root.getChildElements().at(i).getText())));\n";
1788  }
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)
1792  {
1793  string stlcnt = argpm.at(0);
1794  string stltyp = argpm.at(0);
1795  string contType;
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)
1802  {
1803  contType = "std::vector<";
1804  stlcnttyp = "Vec";
1805  }
1806  else if(argpm.at(0).find("queue")!=string::npos)
1807  {
1808  contType = "std::queue<";
1809  stlcnttyp = "Q";
1810  }
1811  else if(argpm.at(0).find("deque")!=string::npos)
1812  {
1813  contType = "std::deque<";
1814  stlcnttyp = "Dq";
1815  }
1816  else if(argpm.at(0).find("list")!=string::npos)
1817  {
1818  contType = "std::list<";
1819  stlcnttyp = "Lis";
1820  }
1821  else if(argpm.at(0).find("multiset")!=string::npos)
1822  {
1823  contType = "std::multiset<";
1824  stlcnttyp = "MulSet";
1825  }
1826  else
1827  {
1828  contType = "std::set<";
1829  stlcnttyp = "Set";
1830  }
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," ","");
1841 
1842  contType += stlcnt + ",";
1843 
1844  if(!ptr)
1845  {
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";
1850  else
1851  typedefs += "\n__obj->set"+cam+"(*("+argpm.at(0)+"*)unSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).renderChildren()));\n";
1852  typedefs += "\n}\n";
1853  }
1854  else
1855  {
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";
1860  else
1861  typedefs += "\n__obj->set"+cam+"(("+argpm.at(0)+"*)unSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).renderChildren()));\n";
1862  typedefs += "\n}\n";
1863  }
1864  }
1865  else
1866  {
1867  if(!ptr)
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";
1869  else
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";
1871  }
1872  }
1873  else if("get"+cam==methpm.at(1) && argpm.size()==0 && methpm.at(0)==fldnames.at(k))
1874  {
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")
1877  {
1878  if(!ptr)
1879  {
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";
1883  }
1884  else
1885  {
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";
1889  }
1890  }
1891  else if(methpm.at(0)=="Date")
1892  {
1893  if(!ptr)
1894  {
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";
1898  }
1899  else
1900  {
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";
1904  }
1905  }
1906  else if(methpm.at(0)=="BinaryData")
1907  {
1908  if(!ptr)
1909  {
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";
1913  }
1914  else
1915  {
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";
1919  }
1920  }
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)
1924  {
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)
1933  stlcnttyp = "Vec";
1934  else if(methpm.at(0).find("queue")!=string::npos)
1935  stlcnttyp = "Q";
1936  else if(methpm.at(0).find("deque")!=string::npos)
1937  stlcnttyp = "Dq";
1938  else if(methpm.at(0).find("list")!=string::npos)
1939  stlcnttyp = "Lis";
1940  else if(methpm.at(0).find("multiset")!=string::npos)
1941  stlcnttyp = "MulSet";
1942  else
1943  stlcnttyp = "Set";
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," ","");
1954 
1955  if(!ptr)
1956  {
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)+")");
1961  else
1962  methods += ("objxml += \"<"+fldnames.at(k+1)+" type=\\\""+stltyp+"\\\">\"+serialize"+stlcnt+stlcnttyp+"(&__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+")");
1963  //string cam = AfcUtil::camelCased(methpm.at(1));
1964  methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
1965  //if(methsall[this->classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)unSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).render()));\n";
1966  }
1967  else
1968  {
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)+")");
1973  else
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)+")");
1975  //string cam = AfcUtil::camelCased(methpm.at(1));
1976  methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
1977  //if(methsall[this->classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)unSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).render()));\n";
1978  }
1979  }
1980  else
1981  {
1982  if(!ptr)
1983  {
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");
1987  //string cam = AfcUtil::camelCased(methpm.at(1));
1988  //if(methsall[this->classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)unSerialize"+methpm.at(0)+"(root.getChildElements().at(i).render()));\n";
1989  }
1990  else
1991  {
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");
1995  //string cam = AfcUtil::camelCased(methpm.at(1));
1996  //if(methsall[this->classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)unSerialize"+methpm.at(0)+"(root.getChildElements().at(i).render()));\n";
1997  }
1998  }
1999  }
2000  }
2001  }
2002  }
2003  }
2004  }
2005  }
2006 
2007  //refDef += ("\nclassInfo.setMeths(meths);");
2008  //refDef += ("\nclassInfo.setMethods(methVec);");
2009  //refDef += ("\nclassInfo.setFields(fldVec);");
2010  //refDef += "\nreturn classInfo;\n}\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);";
2019  if(this->prosetser)
2020  {
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);";
2024  }
2025 
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);";
2031  if(this->prosetser)
2032  {
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);";
2036  }
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;}";
2038  //typedefs = (structinf+"};\n"+typedefs);
2039  return refDef;
2040 }
2041 
2042 string Reflection::generateSerDefinitionBinary(string className,string &includesDefs,string &typedefs,string &classes,string &methods)
2043 {
2044  string refDef;
2045  string opers;
2046  if (!generateClassInfo(className))
2047  {
2048  return refDef;
2049  }
2050  prosetser = false;
2051  //classes += "\tif(className==\""+classN+"\")\n\t\tobjXml = get"+classN+"XML(t);\n";
2052  //refDef += "\tif(className==\""+classN+"\")\n\t\tt = getObject"+classN+"(objXml);\n";
2053  includesDefs += "#include \"" + classN + ".h\"\n";
2054  //string structinf = "\nstruct struct"+classN+"{\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";
2063 
2064  string publf, privf, protf ,publm, privm, protm;
2065  string meth,fld;
2066  size_t tes;
2067  vector<string> fldnames;
2068  if (pri.size() > 0)
2069  {
2070  for (unsigned int i = 0; i < pri.size(); i++)
2071  {
2072  if(((tes=pri.at(i).find("("))==string::npos && (tes=pri.at(i).find(")"))==string::npos && pri.at(i).find("~")==string::npos))
2073  {
2074  fld = pri.at(i);
2075  StringUtil::replaceFirst(fld,";","");
2076  vector<string> fldp;
2077  StringUtil::split(fldp, fld, (" "));
2078  if(fldp.size()==2)
2079  {
2080  string nam = fldp.at(1);
2081  fldnames.push_back(fldp.at(0));
2082  fldnames.push_back(nam);
2083  }
2084  }
2085  }
2086  }
2087  if (pro.size() > 0)
2088  {
2089  for (unsigned int i = 0; i < pro.size(); i++)
2090  {
2091  if(((tes=pro.at(i).find("("))==string::npos && (tes=pro.at(i).find(")"))==string::npos && pro.at(i).find("~")==string::npos))
2092  {
2093  fld = pro.at(i);
2094  StringUtil::replaceFirst(fld,";","");
2095  vector<string> fldp;
2096  StringUtil::split(fldp, fld, (" "));
2097  if(fldp.size()==2)
2098  {
2099  string nam = fldp.at(1);
2100  fldnames.push_back(fldp.at(0));
2101  fldnames.push_back(nam);
2102  }
2103  }
2104  }
2105  }
2106  if (pub.size() > 0)
2107  {
2108  for (unsigned int i = 0; i < pub.size(); i++)
2109  {
2110  if(((tes=pub.at(i).find("("))==string::npos && (tes=pub.at(i).find(")"))==string::npos && pub.at(i).find("~")==string::npos))
2111  {
2112  fld = pub.at(i);
2113  RegexUtil::replace(fld, "[\t]+", " ");
2114  RegexUtil::replace(fld, "[ ]+", " ");
2115  RegexUtil::replace(fld, "[ ?, ?]+", ",");
2116  StringUtil::replaceFirst(fld,";","");
2117  bool ptr = false;
2118  if(fld.find("*")!=string::npos)
2119  {
2120  ptr = true;
2121  StringUtil::replaceFirst(fld,"*","");
2122  }
2123  vector<string> fldp;
2124  StringUtil::split(fldp, fld, (" "));
2125  if(fldp.size()==2)
2126  {
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")
2130  {
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")
2134  {
2135  vallu = "root->getPackets().at(i)->getValueStr()";
2136  }
2137  if(!ptr)
2138  {
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";
2142  }
2143  else
2144  {
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";
2148  }
2149  }
2150  else if(fldp.at(0)=="Date")
2151  {
2152  if(!ptr)
2153  {
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");
2156  //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)+")");
2157  string cam = StringUtil::capitalizedCopy(fldp.at(1));
2158  //methods += ("+\"</"+nam+">\";\n");
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";
2160  }
2161  else
2162  {
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");
2165  //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)+")");
2166  string cam = StringUtil::capitalizedCopy(fldp.at(1));
2167  //methods += ("+\"</"+nam+">\";\n");
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";
2169  }
2170  }
2171  else if(fldp.at(0)=="BinaryData")
2172  {
2173  if(!ptr)
2174  {
2175  methods += ("object.addPacket(BinaryData::serilaize(__obj->"+fldp.at(1)+"),\""+fldp.at(1)+"\");\n");
2176  //methods += ("objxml += \"<"+fldp.at(1)+" type=\\\""+fldp.at(0)+"\\\">\"+BinaryData::serilaize(__obj->"+fldp.at(1)+")");
2177  string cam = StringUtil::capitalizedCopy(fldp.at(1));
2178  //methods += ("+\"</"+nam+">\";\n");
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";
2180  }
2181  else
2182  {
2183  methods += ("if(__obj->"+fldp.at(1)+"!=NULL)object.addPacket(BinaryData::serilaize(*__obj->"+fldp.at(1)+"),\""+fldp.at(1)+"\");\n");
2184  //methods += ("objxml += \"<"+fldp.at(1)+" type=\\\""+fldp.at(0)+"\\\">\"+BinaryData::serilaize(__obj->"+fldp.at(1)+")");
2185  string cam = StringUtil::capitalizedCopy(fldp.at(1));
2186  //methods += ("+\"</"+nam+">\";\n");
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";
2188  }
2189  }
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)
2193  {
2194  string stlcnt = fldp.at(0);
2195  string stltyp = fldp.at(0);
2196  string contType;
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)
2203  {
2204  contType = "std::vector<";
2205  stlcnttyp = "Vec";
2206  }
2207  else if(fldp.at(0).find("queue")!=string::npos)
2208  {
2209  contType = "std::queue<";
2210  stlcnttyp = "Q";
2211  }
2212  else if(fldp.at(0).find("deque")!=string::npos)
2213  {
2214  contType = "std::deque<";
2215  stlcnttyp = "Dq";
2216  }
2217  else if(fldp.at(0).find("list")!=string::npos)
2218  {
2219  contType = "std::list<";
2220  stlcnttyp = "Lis";
2221  }
2222  else if(fldp.at(0).find("multiset")!=string::npos)
2223  {
2224  contType = "std::multiset<";
2225  stlcnttyp = "MulSet";
2226  }
2227  else
2228  {
2229  contType = "std::set<";
2230  stlcnttyp = "Set";
2231  }
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," ","");
2242 
2243  contType += stlcnt + ",";
2244 
2245  if(!ptr)
2246  {
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");
2250  else
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));
2253  //methods += ("+\"</"+nam+">\";\n");
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";
2259  else
2260  typedefs += "\n__obj->"+fldp.at(1)+" = *("+fldp.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(root->getPackets().at(i)->getValue());\n";
2261  typedefs += "\n}\n";
2262  }
2263  else
2264  {
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");
2269  else
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));
2272  //methods += ("+\"</"+nam+">\";\n");
2273  typedefs += "if(nam==\""+fldp.at(1)+"\" && root->getPackets().at(i)->getValue()!=\"\"){";
2274  typedefs += "\nAMEFEncoder enc;\n";
2275  //@TODO Is a concern if pointer is used, the address reference might lead to data issues
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";
2278  else
2279  typedefs += "\n__obj->"+fldp.at(1)+" = ("+fldp.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(root->getPackets().at(i)->getValue());\n";
2280  typedefs += "\n}\n";
2281  }
2282  }
2283  else
2284  {
2285  if(!ptr)
2286  {
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));
2290  //methods += ("+\"</"+nam+">\";\n");
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";
2292  }
2293  else
2294  {
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));
2298  //methods += ("+\"</"+nam+">\";\n");
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";
2300  }
2301  }
2302  //structinf += (fldp.at(0)+" "+fldp.at(1)+";\n");
2303  }
2304  }
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)
2307  {
2308  meth = pub.at(i);
2309  StringUtil::replaceFirst(meth,";","");
2310  RegexUtil::replace(meth, "[\t]+", " ");
2311  RegexUtil::replace(meth, "[ ]+", " ");
2312  RegexUtil::replace(meth, "[ ?, ?]+", ",");
2313  bool ptr = false;
2314  if(meth.find("*")!=string::npos)
2315  {
2316  ptr = true;
2317  StringUtil::replaceFirst(meth,"*","");
2318  }
2319 
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)
2325  {
2326  if(meth.find("<")!=string::npos)
2327  {
2328  prosetser = true;
2329  }
2330  else if(meth.find(">")!=string::npos)
2331  {
2332  prosetser = true;
2333  }
2334  }
2335  else
2336  {
2337  //StringUtil::replaceFirst(meth,")"," ");
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++)
2342  {
2343  if(methp.at(j)!="")
2344  methpm.push_back(methp.at(j));
2345  }
2346  for(unsigned int j = 0; j < argp.size(); j++)
2347  {
2348  if(argp.at(j)!="" && argp.at(j)!="(")
2349  {
2350  string tty = argp.at(j);
2351  StringUtil::trim(tty);
2352  if(tty.find(" ")!=string::npos)
2353  {
2354  vector<string> temargt = StringUtil::split(tty, " ");
2355  argpm.push_back(temargt.at(0));
2356  }
2357  else
2358  {
2359  argpm.push_back(tty);
2360  }
2361  }
2362  }
2363 
2364  if(methpm.at(0)!=classN)
2365  {
2366  for(unsigned int k = 0; k < fldnames.size(); k=k+2)
2367  {
2368  string cam = StringUtil::capitalizedCopy(fldnames.at(k+1));
2369  string fldNamewoptr = StringUtil::replaceFirstCopy(fldnames.at(k), "*", "");
2370  //logger << "setter check " << fldNamewoptr << " "<<methpm.at(0) << " "<< methpm.at(1) << " "<< cam<< endl;
2371  if(argpm.size()==1)
2372  {
2373  StringUtil::replaceFirst(argpm.at(0), "*", "");
2374  //logger << argpm.at(0) << " " << argpm.size() << endl;
2375  }
2376  if("set"+cam==methpm.at(1) && argpm.size()==1 && argpm.at(0)==fldNamewoptr && methpm.at(0)=="void")
2377  {
2378  //logger << " inside setter " << endl;
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")
2381  {
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")
2385  {
2386  vallu = "root->getPackets().at(i)->getValueStr()";
2387  }
2388  if(!ptr)
2389  {
2390  typedefs += "if(nam==\""+fldnames.at(k+1)+"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+methpm.at(1)+"("+vallu+");\n";
2391  }
2392  else
2393  {
2394  typedefs += "if(nam==\""+fldnames.at(k+1)+"\" && root->getPackets().at(i)->getValue()!=\"\")\n__obj->"+methpm.at(1)+"(new "+argpm.at(0)+"("+vallu+"));\n";
2395  }
2396  }
2397  else if(argpm.at(0)=="Date")
2398  {
2399  if(!ptr)
2400  {
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";
2402  }
2403  else
2404  {
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";
2406  }
2407  }
2408  else if(argpm.at(0)=="BinaryData")
2409  {
2410  if(!ptr)
2411  {
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";
2413  }
2414  else
2415  {
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";
2417  }
2418  }
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)
2422  {
2423  string stlcnt = argpm.at(0);
2424  string stltyp = argpm.at(0);
2425  string contType;
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)
2432  {
2433  contType = "std::vector<";
2434  stlcnttyp = "Vec";
2435  }
2436  else if(argpm.at(0).find("queue")!=string::npos)
2437  {
2438  contType = "std::queue<";
2439  stlcnttyp = "Q";
2440  }
2441  else if(argpm.at(0).find("deque")!=string::npos)
2442  {
2443  contType = "std::deque<";
2444  stlcnttyp = "Dq";
2445  }
2446  else if(argpm.at(0).find("list")!=string::npos)
2447  {
2448  contType = "std::list<";
2449  stlcnttyp = "Lis";
2450  }
2451  else if(argpm.at(0).find("multiset")!=string::npos)
2452  {
2453  contType = "std::multiset<";
2454  stlcnttyp = "MulSet";
2455  }
2456  else
2457  {
2458  contType = "std::set<";
2459  stlcnttyp = "Set";
2460  }
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," ","");
2471 
2472  contType += stlcnt + ",";
2473 
2474  if(!ptr)
2475  {
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";
2481  else
2482  typedefs += "\n__obj->set"+cam+"(*("+argpm.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(root->getPackets().at(i)->getValue()));\n";
2483  typedefs += "\n}\n";
2484  }
2485  else
2486  {
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";
2492  else
2493  typedefs += "\n__obj->set"+cam+"(("+argpm.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(root->getPackets().at(i)->getValue()));\n";
2494  typedefs += "\n}\n";
2495  }
2496  //if(methsall[classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).render()));\n";
2497  }
2498  else
2499  {
2500  if(!ptr)
2501  {
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";
2503  }
2504  else
2505  {
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";
2507  }
2508  }
2509  }
2510  else if("get"+cam==methpm.at(1) && argpm.size()==0 && methpm.at(0)==fldNamewoptr)
2511  {
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")
2514  {
2515  if(!ptr)
2516  {
2517  methods += ("object.addPacket(__obj->"+methpm.at(1)+"(),\""+fldnames.at(k+1)+"\");\n");
2518  //methods += ("objxml += \"<"+fldnames.at(k+1)+" type=\\\""+methpm.at(0)+"\\\">\"+CastUtil::lexical_cast<string>(__obj->"+methpm.at(1)+"())");
2519  //methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
2520  //if(methsall[classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+fldnames.at(k+1)+"\")\n__obj->set"+cam+"(CastUtil::lexical_cast<"+methpm.at(0)+">(root->getPackets().at(i)->getValue()));\n";
2521  }
2522  else
2523  {
2524  methods += ("if(__obj->"+methpm.at(1)+"()!=NULL)object.addPacket(*__obj->"+methpm.at(1)+"(),\""+fldnames.at(k+1)+"\");\n");
2525  //methods += ("objxml += \"<"+fldnames.at(k+1)+" type=\\\""+methpm.at(0)+"\\\">\"+CastUtil::lexical_cast<string>(__obj->"+methpm.at(1)+"())");
2526  //methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
2527  //if(methsall[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->getPackets().at(i)->getValue())));\n";
2528  }
2529  }
2530  else if(methpm.at(0)=="Date")
2531  {
2532  if(!ptr)
2533  {
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");
2536  //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)+"())");
2537  //methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
2538  //if(methsall[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->getPackets().at(i)->getValue())));\n}\n";
2539  }
2540  else
2541  {
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");
2544  //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)+"())");
2545  //methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
2546  //if(methsall[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->getPackets().at(i)->getValue())));\n}\n";
2547  }
2548  }
2549  else if(methpm.at(0)=="BinaryData")
2550  {
2551  if(!ptr)
2552  {
2553  methods += ("object.addPacket(BinaryData::serilaize(__obj->"+methpm.at(1)+"()),\""+fldnames.at(k+1)+"\");\n");
2554  //methods += ("objxml += \"<"+fldnames.at(k+1)+" type=\\\""+methpm.at(0)+"\\\">\"+BinaryData::serilaize(__obj->"+methpm.at(1)+"())");
2555  //methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
2556  //if(methsall[classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+fldnames.at(k+1)+"\")\n__obj->set"+cam+"(*(BinaryData::unSerilaize(root->getPackets().at(i)->getValue())));\n";
2557  }
2558  else
2559  {
2560  methods += ("if(__obj->"+methpm.at(1)+"()!=NULL)object.addPacket(BinaryData::serilaize(*__obj->"+methpm.at(1)+"()),\""+fldnames.at(k+1)+"\");\n");
2561  //methods += ("objxml += \"<"+fldnames.at(k+1)+" type=\\\""+methpm.at(0)+"\\\">\"+BinaryData::serilaize(__obj->"+methpm.at(1)+"())");
2562  //methods += ("+\"</"+fldnames.at(k+1)+">\";\n");
2563  //if(methsall[classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+fldnames.at(k+1)+"\")\n__obj->set"+cam+"((BinaryData::unSerilaize(root->getPackets().at(i)->getValue())));\n";
2564  }
2565  }
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)
2569  {
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)
2578  stlcnttyp = "Vec";
2579  else if(methpm.at(0).find("queue")!=string::npos)
2580  stlcnttyp = "Q";
2581  else if(methpm.at(0).find("deque")!=string::npos)
2582  stlcnttyp = "Dq";
2583  else if(methpm.at(0).find("list")!=string::npos)
2584  stlcnttyp = "Lis";
2585  else if(methpm.at(0).find("multiset")!=string::npos)
2586  stlcnttyp = "MulSet";
2587  else
2588  stlcnttyp = "Set";
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," ","");
2599 
2600  if(!ptr)
2601  {
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");
2605  else
2606  methods += ("object.addPacket(binarySerialize"+stlcnt+stlcnttyp+"(&__temp_obj_ser"+stlcnt+stlcnttyp+classN+methpm.at(1)+"),\""+fldnames.at(k+1)+"\");\n");
2607  //string cam = StringUtil::capitalizedCopy(methpm.at(1));
2608  //methods += ("+\"</"+nam+">\";\n");
2609  /*if(methsall[classN+"get"+cam+methpm.at(0)])
2610  {
2611  typedefs += "if(nam==\""+fldnames.at(k+1)+"\"){";
2612  typedefs += "\nAMEFEncoder enc;";
2613  typedefs += "\n__obj->set"+cam+"(*("+methpm.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(enc.encodeB(root->getPackets().at(i), false)));\n";
2614  typedefs += "\n}\n";
2615  }*/
2616  }
2617  else
2618  {
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");
2622  else
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");
2624  //string cam = StringUtil::capitalizedCopy(methpm.at(1));
2625  //methods += ("+\"</"+nam+">\";\n");
2626  /*if(methsall[classN+"get"+cam+methpm.at(0)])
2627  {
2628  typedefs += "if(nam==\""+fldnames.at(k+1)+"\"){";
2629  typedefs += "\nAMEFEncoder enc;";
2630  typedefs += "\n__obj->set"+cam+"(("+methpm.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(enc.encodeB(root->getPackets().at(i), false)));\n";
2631  typedefs += "\n}\n";
2632  }*/
2633  }
2634  //if(methsall[classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)binaryUnSerialize"+stlcnt+stlcnttyp+"(root.getChildElements().at(i).render()));\n";
2635  }
2636  else
2637  {
2638  //string cam = StringUtil::capitalizedCopy(methpm.at(1));
2639  //if(methsall[classN+"get"+cam+methpm.at(0)])typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)binaryUnSerialize"+methpm.at(0)+"(root.getChildElements().at(i).render()));\n";
2640  if(!ptr)
2641  {
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");
2644  //typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(*("+methpm.at(0)+"*)binaryUnSerialize"+methpm.at(0)+"(root->getPackets().at(i)->getValue()));\n";
2645  }
2646  else
2647  {
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");
2650  //typedefs += "if(nam==\""+methpm.at(1)+"\")\n__obj->set"+cam+"(("+methpm.at(0)+"*)binaryUnSerialize"+methpm.at(0)+"(root->getPackets().at(i)->getValue()));\n";
2651  }
2652  }
2653  }
2654  }
2655  }
2656  }
2657  }
2658  }
2659  }
2660 
2661  //refDef += ("\nclassInfo.setMeths(meths);");
2662  //refDef += ("\nclassInfo.setMethods(methVec);");
2663  //refDef += ("\nclassInfo.setFields(fldVec);");
2664  //refDef += "\nreturn classInfo;\n}\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);";
2675  if(prosetser)
2676  {
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);";
2682  }
2683 
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);";
2698  if(prosetser)
2699  {
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);";
2707  }
2708 
2709  //typedefs = (structinf+"};\n"+typedefs);
2710  return refDef;
2711 }