ffead.server.doc
ClassInfo.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  * ClassInfo.cpp
18  *
19  * Created on: Aug 21, 2009
20  * Author: sumeet
21  */
22 
23 #include "ClassInfo.h"
24 
25 ClassInfo::ClassInfo() {
26  // TODO Auto-generated constructor stub
27 
28 }
29 
30 ClassInfo::~ClassInfo() {
31  // TODO Auto-generated destructor stub
32 }
33 /*
34 void *ClassInfo::getInstance() const
35 {
36  return instance;
37 }
38 
39 void ClassInfo::setInstance(void *instance)
40 {
41  this->instance = instance;
42 }
43 */
44 string ClassInfo::getClassName() const
45 {
46  return className;
47 }
48 
49 void ClassInfo::setClassName(string className)
50 {
51  this->className = className;
52 }
53 
54 string ClassInfo::getBase() const
55 {
56  return base;
57 }
58 
59 void ClassInfo::setBase(string base)
60 {
61  this->base = base;
62 }
63 
64 Constructor ClassInfo::getConstructor(args argumentTypes)
65 {
66  string key = getClassName();
67  for (unsigned int var = 0; var < argumentTypes.size(); var++)
68  {
69  if(argumentTypes.at(var)!="")
70  key += argumentTypes.at(var);
71  }
72  return ctors[key];
73 }
74 
75 void ClassInfo::addConstructor(Constructor ctor)
76 {
77  string key = getClassName();
78  for (unsigned int var = 0; var < ctor.getArgumentTypes().size(); var++)
79  {
80  if(ctor.getArgumentTypes().at(var)!="")
81  key += ctor.getArgumentTypes().at(var);
82  }
83  ctors[key] = ctor;
84 }
85 
86 ctorMap ClassInfo::getConstructors()
87 {
88  return this->ctors;
89 }
90 
91 Method ClassInfo::getMethod(string methodName,args argumentTypes)
92 {
93  string key = getClassName()+methodName;
94  for (unsigned int var = 0; var < argumentTypes.size(); var++)
95  {
96  if(argumentTypes.at(var)!="")
97  {
98  string temp = argumentTypes.at(var);
99  StringUtil::replaceFirst(temp," ","");
100  StringUtil::replaceFirst(temp,"<","ts");
101  StringUtil::replaceFirst(temp,">","te");
102  StringUtil::replaceFirst(temp,"*","ptr");
103  StringUtil::replaceFirst(temp,"&","adr");
104  StringUtil::replaceFirst(temp,"std::","");
105  StringUtil::replaceFirst(temp,"::","ns");
106  key += temp;
107  }
108  }
109  return meths[key];
110 }
111 void ClassInfo::addMethod(Method meth)
112 {
113  string key = meth.getMethodName();
114  /*for (unsigned int var = 0; var < meth.getArgumentTypes().size(); var++)
115  {
116  if(meth.getArgumentTypes().at(var)!="")
117  key += meth.getArgumentTypes().at(var);
118  }*/
119  meths[key] = meth;
120 }
121 
122 Field ClassInfo::getField(string fldName)
123 {
124  string key = fldName;
125  return fields[key];
126 }
127 void ClassInfo::addField(Field fld)
128 {
129  string key = fld.getFieldName();
130  fields[key] = fld;
131  fldvec.push_back(fld);
132 }
133 
134 fldMap ClassInfo::getFields()
135 {
136  return fields;
137 }
138 
139 fldVec ClassInfo::getFieldVec()
140 {
141  return fldvec;
142 }
143 
144 methMap ClassInfo::getMethods()
145 {
146  return meths;
147 }
148 /*
149 string ClassInfo::getPublic_fields() const
150 {
151  return public_fields;
152 }
153 
154 void ClassInfo::setPublic_fields(string public_fields)
155 {
156  this->public_fields = public_fields;
157 }
158 
159 string ClassInfo::getPrivate_fields() const
160 {
161  return private_fields;
162 }
163 
164 void ClassInfo::setPrivate_fields(string private_fields)
165 {
166  this->private_fields = private_fields;
167 }
168 
169 string ClassInfo::getProtected_fields() const
170 {
171  return protected_fields;
172 }
173 
174 void ClassInfo::setProtected_fields(string protected_fields)
175 {
176  this->protected_fields = protected_fields;
177 }
178 
179 string ClassInfo::getPublic_meths() const
180 {
181  return public_meths;
182 }
183 
184 void ClassInfo::setPublic_meths(string public_meths)
185 {
186  this->public_meths = public_meths;
187 }
188 
189 string ClassInfo::getPrivate_meths() const
190 {
191  return private_meths;
192 }
193 
194 void ClassInfo::setPrivate_meths(string private_meths)
195 {
196  this->private_meths = private_meths;
197 }
198 
199 string ClassInfo::getProtected_meths() const
200 {
201  return protected_meths;
202 }
203 
204 void ClassInfo::setProtected_meths(string protected_meths)
205 {
206  this->protected_meths = protected_meths;
207 }
208 
209 vector<Method> ClassInfo::getMethods() const
210 {
211  return methods;
212 }
213 
214 void ClassInfo::setMethods(vector<Method> methods)
215 {
216  this->methods = methods;
217 }
218 
219 vector<Field> ClassInfo::getFields() const
220 {
221  return fields;
222 }
223 
224 void ClassInfo::setFields(vector<Field> fields)
225 {
226  this->fields = fields;
227 }
228 void ClassInfo::setMeths(methMap meths)
229 {
230  this->meths = meths;
231 }*/