MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / short_demangle_once

Function short_demangle_once

extlibs/sol3/include/sol/sol.hpp:7702–7737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7700
7701 template <typename T>
7702 std::string short_demangle_once() {
7703 std::string realname = ctti_get_type_name<T>();
7704 // This isn't the most complete but it'll do for now...?
7705 static const std::array<std::string, 10> ops = {{"operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*"}};
7706 int level = 0;
7707 std::ptrdiff_t idx = 0;
7708 for (idx = static_cast<std::ptrdiff_t>(realname.empty() ? 0 : realname.size() - 1); idx > 0; --idx) {
7709 if (level == 0 && realname[idx] == ':') {
7710 break;
7711 }
7712 bool isleft = realname[idx] == '<';
7713 bool isright = realname[idx] == '>';
7714 if (!isleft && !isright)
7715 continue;
7716 bool earlybreak = false;
7717 for (const auto& op : ops) {
7718 std::size_t nisop = realname.rfind(op, idx);
7719 if (nisop == std::string::npos)
7720 continue;
7721 std::size_t nisopidx = idx - op.size() + 1;
7722 if (nisop == nisopidx) {
7723 idx = static_cast<std::ptrdiff_t>(nisopidx);
7724 earlybreak = true;
7725 }
7726 break;
7727 }
7728 if (earlybreak) {
7729 continue;
7730 }
7731 level += isleft ? -1 : 1;
7732 }
7733 if (idx > 0) {
7734 realname.erase(0, realname.length() < static_cast<std::size_t>(idx) ? realname.length() : idx + 1);
7735 }
7736 return realname;
7737 }
7738
7739 template <typename T>
7740 const std::string& demangle() {

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected