| 82 | } |
| 83 | |
| 84 | std::string LogDispatcher::Proxy::ExtractName(std::string pretty_function) |
| 85 | { |
| 86 | if ( pretty_function == "" ) |
| 87 | return ""; |
| 88 | size_t pos = pretty_function.find('('); |
| 89 | if ( pos == std::string::npos ) |
| 90 | return pretty_function; // return unchanged. |
| 91 | |
| 92 | pretty_function = pretty_function.substr(0, pos); |
| 93 | |
| 94 | // There are also template instantiations where the instantiating |
| 95 | // parameters are encrypted inside. Therefore, search for the first |
| 96 | // open < and if found, search for symmetric >. |
| 97 | |
| 98 | int depth = 1; |
| 99 | pos = pretty_function.find('<'); |
| 100 | if ( pos != std::string::npos ) |
| 101 | { |
| 102 | size_t end = pos+1; |
| 103 | for(;;) |
| 104 | { |
| 105 | ++pos; |
| 106 | if ( pos == pretty_function.size() ) |
| 107 | { |
| 108 | --pos; |
| 109 | break; |
| 110 | } |
| 111 | if ( pretty_function[pos] == '<' ) |
| 112 | { |
| 113 | ++depth; |
| 114 | continue; |
| 115 | } |
| 116 | |
| 117 | if ( pretty_function[pos] == '>' ) |
| 118 | { |
| 119 | --depth; |
| 120 | if ( depth <= 0 ) |
| 121 | break; |
| 122 | continue; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | std::string afterpart = pretty_function.substr(pos+1); |
| 127 | pretty_function = pretty_function.substr(0, end) + ">" + afterpart; |
| 128 | } |
| 129 | |
| 130 | // Now see how many :: can be found in the name. |
| 131 | // If this occurs more than once, take the last two. |
| 132 | pos = pretty_function.rfind("::"); |
| 133 | |
| 134 | if ( pos == std::string::npos || pos < 2 ) |
| 135 | return pretty_function; // return whatever this is. No scope name. |
| 136 | |
| 137 | // Find the next occurrence of :: - if found, copy up to it. If not, |
| 138 | // return whatever is found. |
| 139 | pos -= 2; |
| 140 | pos = pretty_function.rfind("::", pos); |
| 141 | if ( pos == std::string::npos ) |