| | 50 | void print_method(const MethodInfo &mi) |
|---|
| | 51 | { |
|---|
| | 52 | std::cout << "\t "; |
|---|
| | 53 | |
|---|
| | 54 | // display if the method is virtual |
|---|
| | 55 | if (mi.isVirtual()) |
|---|
| | 56 | std::cout << "virtual "; |
|---|
| | 57 | |
|---|
| | 58 | // display the method's return type if defined |
|---|
| | 59 | if (mi.getReturnType().isDefined()) |
|---|
| | 60 | std::cout << mi.getReturnType().getQualifiedName() << " "; |
|---|
| | 61 | else |
|---|
| | 62 | std::cout << "[UNDEFINED TYPE] "; |
|---|
| | 63 | |
|---|
| | 64 | // display the method's name |
|---|
| | 65 | std::cout << mi.getName() << "("; |
|---|
| | 66 | |
|---|
| | 67 | // display method's parameters |
|---|
| | 68 | const ParameterInfoList ¶ms = mi.getParameters(); |
|---|
| | 69 | for (ParameterInfoList::const_iterator k=params.begin(); k!=params.end(); ++k) |
|---|
| | 70 | { |
|---|
| | 71 | // get the ParameterInfo object that describes the |
|---|
| | 72 | // current parameter |
|---|
| | 73 | const ParameterInfo &pi = **k; |
|---|
| | 74 | |
|---|
| | 75 | // display the parameter's modifier |
|---|
| | 76 | if (pi.isIn()) |
|---|
| | 77 | std::cout << "IN"; |
|---|
| | 78 | if (pi.isOut()) |
|---|
| | 79 | std::cout << "OUT"; |
|---|
| | 80 | if (pi.isIn() || pi.isOut()) |
|---|
| | 81 | std::cout << " "; |
|---|
| | 82 | |
|---|
| | 83 | // display the parameter's type name |
|---|
| | 84 | if (pi.getParameterType().isDefined()) |
|---|
| | 85 | std::cout << pi.getParameterType().getQualifiedName(); |
|---|
| | 86 | |
|---|
| | 87 | // display the parameter's name if defined |
|---|
| | 88 | if (!pi.getName().empty()) |
|---|
| | 89 | std::cout << " " << pi.getName(); |
|---|
| | 90 | |
|---|
| | 91 | if ((k+1)!=params.end()) |
|---|
| | 92 | std::cout << ", "; |
|---|
| | 93 | } |
|---|
| | 94 | std::cout << ")"; |
|---|
| | 95 | if (mi.isConst()) |
|---|
| | 96 | std::cout << " const"; |
|---|
| | 97 | if (mi.isPureVirtual()) |
|---|
| | 98 | std::cout << " = 0"; |
|---|
| | 99 | std::cout << "\n"; |
|---|
| | 100 | } |
|---|
| | 101 | |
|---|
| | 102 | void print_type(const Type &type) |
|---|
| | 103 | { |
|---|
| | 104 | // ignore pointer types and undefined types |
|---|
| | 105 | if (!type.isDefined() || type.isPointer() || type.isReference()) |
|---|
| | 106 | return; |
|---|
| | 107 | |
|---|
| | 108 | // print the type name |
|---|
| | 109 | std::cout << type.getQualifiedName() << "\n"; |
|---|
| | 110 | |
|---|
| | 111 | // check whether the type is abstract |
|---|
| | 112 | if (type.isAbstract()) std::cout << "\t[abstract]\n"; |
|---|
| | 113 | |
|---|
| | 114 | // check whether the type is atomic |
|---|
| | 115 | if (type.isAtomic()) std::cout << "\t[atomic]\n"; |
|---|
| | 116 | |
|---|
| | 117 | // check whether the type is an enumeration. If yes, display |
|---|
| | 118 | // the list of enumeration labels |
|---|
| | 119 | if (type.isEnum()) |
|---|
| | 120 | { |
|---|
| | 121 | std::cout << "\t[enum]\n"; |
|---|
| | 122 | std::cout << "\tenumeration values:\n"; |
|---|
| | 123 | const EnumLabelMap &emap = type.getEnumLabels(); |
|---|
| | 124 | for (EnumLabelMap::const_iterator j=emap.begin(); j!=emap.end(); ++j) |
|---|
| | 125 | { |
|---|
| | 126 | std::cout << "\t\t" << j->second << " = " << j->first << "\n"; |
|---|
| | 127 | } |
|---|
| | 128 | } |
|---|
| | 129 | |
|---|
| | 130 | // if the type has one or more base types, then display their |
|---|
| | 131 | // names |
|---|
| | 132 | if (type.getNumBaseTypes() > 0) |
|---|
| | 133 | { |
|---|
| | 134 | std::cout << "\tderived from: "; |
|---|
| | 135 | for (int j=0; j<type.getNumBaseTypes(); ++j) |
|---|
| | 136 | { |
|---|
| | 137 | const Type &base = type.getBaseType(j); |
|---|
| | 138 | if (base.isDefined()) |
|---|
| | 139 | std::cout << base.getQualifiedName() << " "; |
|---|
| | 140 | else |
|---|
| | 141 | std::cout << "[undefined type] "; |
|---|
| | 142 | } |
|---|
| | 143 | std::cout << "\n"; |
|---|
| | 144 | } |
|---|
| | 145 | |
|---|
| | 146 | // display a list of public methods defined for the current type |
|---|
| | 147 | const MethodInfoList &mil = type.getMethods(); |
|---|
| | 148 | if (!mil.empty()) |
|---|
| | 149 | { |
|---|
| | 150 | std::cout << "\t* public methods:\n"; |
|---|
| | 151 | for (MethodInfoList::const_iterator j=mil.begin(); j!=mil.end(); ++j) |
|---|
| | 152 | { |
|---|
| | 153 | // get the MethodInfo object that describes the current |
|---|
| | 154 | // method |
|---|
| | 155 | const MethodInfo &mi = **j; |
|---|
| | 156 | |
|---|
| | 157 | print_method(mi); |
|---|
| | 158 | } |
|---|
| | 159 | } |
|---|
| | 160 | |
|---|
| | 161 | // display a list of protected methods defined for the current type |
|---|
| | 162 | const MethodInfoList &bmil = type.getMethods(Type::PROTECTED_FUNCTIONS); |
|---|
| | 163 | if (!bmil.empty()) |
|---|
| | 164 | { |
|---|
| | 165 | std::cout << "\t* protected methods:\n"; |
|---|
| | 166 | for (MethodInfoList::const_iterator j=bmil.begin(); j!=bmil.end(); ++j) |
|---|
| | 167 | { |
|---|
| | 168 | // get the MethodInfo object that describes the current |
|---|
| | 169 | // method |
|---|
| | 170 | const MethodInfo &mi = **j; |
|---|
| | 171 | |
|---|
| | 172 | print_method(mi); |
|---|
| | 173 | } |
|---|
| | 174 | } |
|---|
| | 175 | |
|---|
| | 176 | // display a list of properties defined for the current type |
|---|
| | 177 | const PropertyInfoList &pil = type.getProperties(); |
|---|
| | 178 | if (!pil.empty()) |
|---|
| | 179 | { |
|---|
| | 180 | std::cout << "\t* properties:\n"; |
|---|
| | 181 | for (PropertyInfoList::const_iterator j=pil.begin(); j!=pil.end(); ++j) |
|---|
| | 182 | { |
|---|
| | 183 | // get the PropertyInfo object that describes the current |
|---|
| | 184 | // property |
|---|
| | 185 | const PropertyInfo &pi = **j; |
|---|
| | 186 | |
|---|
| | 187 | std::cout << "\t "; |
|---|
| | 188 | |
|---|
| | 189 | std::cout << "{"; |
|---|
| | 190 | std::cout << (pi.canGet()? "G": " "); |
|---|
| | 191 | std::cout << (pi.canSet()? "S": " "); |
|---|
| | 192 | std::cout << (pi.canCount()? "C": " "); |
|---|
| | 193 | std::cout << (pi.canAdd()? "A": " "); |
|---|
| | 194 | std::cout << "} "; |
|---|
| | 195 | |
|---|
| | 196 | // display the property's name |
|---|
| | 197 | std::cout << pi.getName(); |
|---|
| | 198 | |
|---|
| | 199 | // display the property's value type if defined |
|---|
| | 200 | std::cout << " ("; |
|---|
| | 201 | if (pi.getPropertyType().isDefined()) |
|---|
| | 202 | std::cout << pi.getPropertyType().getQualifiedName(); |
|---|
| | 203 | else |
|---|
| | 204 | std::cout << "UNDEFINED TYPE"; |
|---|
| | 205 | std::cout << ") "; |
|---|
| | 206 | |
|---|
| | 207 | // check whether the property is an array property |
|---|
| | 208 | if (pi.isArray()) |
|---|
| | 209 | { |
|---|
| | 210 | std::cout << " [ARRAY]"; |
|---|
| | 211 | } |
|---|
| | 212 | |
|---|
| | 213 | // check whether the property is an indexed property |
|---|
| | 214 | if (pi.isIndexed()) |
|---|
| | 215 | { |
|---|
| | 216 | std::cout << " [INDEXED]\n\t\t indices:\n"; |
|---|
| | 217 | |
|---|
| | 218 | const ParameterInfoList &ind = pi.getIndexParameters(); |
|---|
| | 219 | |
|---|
| | 220 | // print the list of indices |
|---|
| | 221 | int num = 1; |
|---|
| | 222 | for (ParameterInfoList::const_iterator k=ind.begin(); k!=ind.end(); ++k, ++num) |
|---|
| | 223 | { |
|---|
| | 224 | std::cout << "\t\t " << num << ") "; |
|---|
| | 225 | const ParameterInfo &par = **k; |
|---|
| | 226 | std::cout << par.getParameterType().getQualifiedName() << " " << par.getName(); |
|---|
| | 227 | std::cout << "\n"; |
|---|
| | 228 | } |
|---|
| | 229 | } |
|---|
| | 230 | |
|---|
| | 231 | std::cout << "\n"; |
|---|
| | 232 | } |
|---|
| | 233 | } |
|---|
| | 234 | std::cout << "\n" << std::string(75, '-') << "\n"; |
|---|
| | 235 | } |
|---|
| | 236 | |
|---|
| 68 | | // ignore pointer types and undefined types |
|---|
| 69 | | if (!(*i)->isDefined() || (*i)->isPointer() || (*i)->isReference()) |
|---|
| 70 | | continue; |
|---|
| 71 | | |
|---|
| 72 | | // print the type name |
|---|
| 73 | | std::cout << (*i)->getQualifiedName() << "\n"; |
|---|
| 74 | | |
|---|
| 75 | | // check whether the type is abstract |
|---|
| 76 | | if ((*i)->isAbstract()) std::cout << "\t[abstract]\n"; |
|---|
| 77 | | |
|---|
| 78 | | // check whether the type is atomic |
|---|
| 79 | | if ((*i)->isAtomic()) std::cout << "\t[atomic]\n"; |
|---|
| 80 | | |
|---|
| 81 | | // check whether the type is an enumeration. If yes, display |
|---|
| 82 | | // the list of enumeration labels |
|---|
| 83 | | if ((*i)->isEnum()) |
|---|
| 84 | | { |
|---|
| 85 | | std::cout << "\t[enum]\n"; |
|---|
| 86 | | std::cout << "\tenumeration values:\n"; |
|---|
| 87 | | const EnumLabelMap &emap = (*i)->getEnumLabels(); |
|---|
| 88 | | for (EnumLabelMap::const_iterator j=emap.begin(); j!=emap.end(); ++j) |
|---|
| 89 | | { |
|---|
| 90 | | std::cout << "\t\t" << j->second << " = " << j->first << "\n"; |
|---|
| 91 | | } |
|---|
| 92 | | } |
|---|
| 93 | | |
|---|
| 94 | | // if the type has one or more base types, then display their |
|---|
| 95 | | // names |
|---|
| 96 | | if ((*i)->getNumBaseTypes() > 0) |
|---|
| 97 | | { |
|---|
| 98 | | std::cout << "\tderived from: "; |
|---|
| 99 | | for (int j=0; j<(*i)->getNumBaseTypes(); ++j) |
|---|
| 100 | | { |
|---|
| 101 | | const Type &base = (*i)->getBaseType(j); |
|---|
| 102 | | if (base.isDefined()) |
|---|
| 103 | | std::cout << base.getQualifiedName() << " "; |
|---|
| 104 | | else |
|---|
| 105 | | std::cout << "[undefined type] "; |
|---|
| 106 | | } |
|---|
| 107 | | std::cout << "\n"; |
|---|
| 108 | | } |
|---|
| 109 | | |
|---|
| 110 | | // display a list of methods defined for the current type |
|---|
| 111 | | const MethodInfoList &mil = (*i)->getMethods(); |
|---|
| 112 | | if (!mil.empty()) |
|---|
| 113 | | { |
|---|
| 114 | | std::cout << "\t* methods:\n"; |
|---|
| 115 | | for (MethodInfoList::const_iterator j=mil.begin(); j!=mil.end(); ++j) |
|---|
| 116 | | { |
|---|
| 117 | | // get the MethodInfo object that describes the current |
|---|
| 118 | | // method |
|---|
| 119 | | const MethodInfo &mi = **j; |
|---|
| 120 | | |
|---|
| 121 | | std::cout << "\t "; |
|---|
| 122 | | |
|---|
| 123 | | // display if the method is virtual |
|---|
| 124 | | if (mi.isVirtual()) |
|---|
| 125 | | std::cout << "virtual "; |
|---|
| 126 | | |
|---|
| 127 | | // display the method's return type if defined |
|---|
| 128 | | if (mi.getReturnType().isDefined()) |
|---|
| 129 | | std::cout << mi.getReturnType().getQualifiedName() << " "; |
|---|
| 130 | | else |
|---|
| 131 | | std::cout << "[UNDEFINED TYPE] "; |
|---|
| 132 | | |
|---|
| 133 | | // display the method's name |
|---|
| 134 | | std::cout << mi.getName() << "("; |
|---|
| 135 | | |
|---|
| 136 | | // display method's parameters |
|---|
| 137 | | const ParameterInfoList ¶ms = mi.getParameters(); |
|---|
| 138 | | for (ParameterInfoList::const_iterator k=params.begin(); k!=params.end(); ++k) |
|---|
| 139 | | { |
|---|
| 140 | | // get the ParameterInfo object that describes the |
|---|
| 141 | | // current parameter |
|---|
| 142 | | const ParameterInfo &pi = **k; |
|---|
| 143 | | |
|---|
| 144 | | // display the parameter's modifier |
|---|
| 145 | | if (pi.isIn()) |
|---|
| 146 | | std::cout << "IN"; |
|---|
| 147 | | if (pi.isOut()) |
|---|
| 148 | | std::cout << "OUT"; |
|---|
| 149 | | if (pi.isIn() || pi.isOut()) |
|---|
| 150 | | std::cout << " "; |
|---|
| 151 | | |
|---|
| 152 | | // display the parameter's type name |
|---|
| 153 | | if (pi.getParameterType().isDefined()) |
|---|
| 154 | | std::cout << pi.getParameterType().getQualifiedName(); |
|---|
| 155 | | |
|---|
| 156 | | // display the parameter's name if defined |
|---|
| 157 | | if (!pi.getName().empty()) |
|---|
| 158 | | std::cout << " " << pi.getName(); |
|---|
| 159 | | |
|---|
| 160 | | if ((k+1)!=params.end()) |
|---|
| 161 | | std::cout << ", "; |
|---|
| 162 | | } |
|---|
| 163 | | std::cout << ")"; |
|---|
| 164 | | if (mi.isConst()) |
|---|
| 165 | | std::cout << " const"; |
|---|
| 166 | | if (mi.isPureVirtual()) |
|---|
| 167 | | std::cout << " = 0"; |
|---|
| 168 | | std::cout << "\n"; |
|---|
| 169 | | } |
|---|
| 170 | | } |
|---|
| 171 | | |
|---|
| 172 | | // display a list of properties defined for the current type |
|---|
| 173 | | const PropertyInfoList &pil = (*i)->getProperties(); |
|---|
| 174 | | if (!pil.empty()) |
|---|
| 175 | | { |
|---|
| 176 | | std::cout << "\t* properties:\n"; |
|---|
| 177 | | for (PropertyInfoList::const_iterator j=pil.begin(); j!=pil.end(); ++j) |
|---|
| 178 | | { |
|---|
| 179 | | // get the PropertyInfo object that describes the current |
|---|
| 180 | | // property |
|---|
| 181 | | const PropertyInfo &pi = **j; |
|---|
| 182 | | |
|---|
| 183 | | std::cout << "\t "; |
|---|
| 184 | | |
|---|
| 185 | | std::cout << "{"; |
|---|
| 186 | | std::cout << (pi.canGet()? "G": " "); |
|---|
| 187 | | std::cout << (pi.canSet()? "S": " "); |
|---|
| 188 | | std::cout << (pi.canCount()? "C": " "); |
|---|
| 189 | | std::cout << (pi.canAdd()? "A": " "); |
|---|
| 190 | | std::cout << "} "; |
|---|
| 191 | | |
|---|
| 192 | | // display the property's name |
|---|
| 193 | | std::cout << pi.getName(); |
|---|
| 194 | | |
|---|
| 195 | | // display the property's value type if defined |
|---|
| 196 | | std::cout << " ("; |
|---|
| 197 | | if (pi.getPropertyType().isDefined()) |
|---|
| 198 | | std::cout << pi.getPropertyType().getQualifiedName(); |
|---|
| 199 | | else |
|---|
| 200 | | std::cout << "UNDEFINED TYPE"; |
|---|
| 201 | | std::cout << ") "; |
|---|
| 202 | | |
|---|
| 203 | | // check whether the property is an array property |
|---|
| 204 | | if (pi.isArray()) |
|---|
| 205 | | { |
|---|
| 206 | | std::cout << " [ARRAY]"; |
|---|
| 207 | | } |
|---|
| 208 | | |
|---|
| 209 | | // check whether the property is an indexed property |
|---|
| 210 | | if (pi.isIndexed()) |
|---|
| 211 | | { |
|---|
| 212 | | std::cout << " [INDEXED]\n\t\t indices:\n"; |
|---|
| 213 | | |
|---|
| 214 | | const ParameterInfoList &ind = pi.getIndexParameters(); |
|---|
| 215 | | |
|---|
| 216 | | // print the list of indices |
|---|
| 217 | | int num = 1; |
|---|
| 218 | | for (ParameterInfoList::const_iterator k=ind.begin(); k!=ind.end(); ++k, ++num) |
|---|
| 219 | | { |
|---|
| 220 | | std::cout << "\t\t " << num << ") "; |
|---|
| 221 | | const ParameterInfo &par = **k; |
|---|
| 222 | | std::cout << par.getParameterType().getQualifiedName() << " " << par.getName(); |
|---|
| 223 | | std::cout << "\n"; |
|---|
| 224 | | } |
|---|
| 225 | | } |
|---|
| 226 | | |
|---|
| 227 | | std::cout << "\n"; |
|---|
| 228 | | } |
|---|
| 229 | | } |
|---|
| 230 | | std::cout << "\n" << std::string(75, '-') << "\n"; |
|---|
| | 255 | print_type(**i); |
|---|