MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / GetDemangledName

Function GetDemangledName

framework/src/util/Utils.cpp:194–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192 {
193
194 std::string
195 GetDemangledName(std::type_info const& typeInfo)
196 {
197 std::string result;
198#ifdef US_HAVE_CXXABI_H
199 int status = 0;
200 char* demangled = abi::__cxa_demangle(typeInfo.name(), nullptr, nullptr, &status);
201 if (demangled && status == 0)
202 {
203 result = demangled;
204 free(demangled);
205 }
206#elif defined(US_PLATFORM_WINDOWS)
207 char const* demangled = typeInfo.name();
208 if (demangled != nullptr)
209 {
210 result = demangled;
211 // remove "struct" qualifiers
212 std::size_t pos = 0;
213 while (pos != std::string::npos)
214 {
215 if ((pos = result.find("struct ", pos)) != std::string::npos)
216 {
217 result = result.substr(0, pos) + result.substr(pos + 7);
218 pos += 8;
219 }
220 }
221 // remove "class" qualifiers
222 pos = 0;
223 while (pos != std::string::npos)
224 {
225 if ((pos = result.find("class ", pos)) != std::string::npos)
226 {
227 result = result.substr(0, pos) + result.substr(pos + 6);
228 pos += 7;
229 }
230 }
231 }
232#else
233 (void)typeInfo;
234#endif
235 return result;
236 }
237
238 } // namespace detail
239} // namespace cppmicroservices

Callers 2

ThrowBadAnyCastExceptionFunction · 0.85
ServiceInterface.hFile · 0.85

Calls 1

findMethod · 0.45

Tested by

no test coverage detected