MCPcopy Create free account
hub / github.com/avast/retdec / normalizeName

Function normalizeName

src/utils/string.cpp:1144–1213  ·  view source on GitHub ↗

* @brief Replaces all special symbols by their normalized equivalent. * * @param[in] name Input string. * * @return String with substituted special symbols. */

Source from the content-addressed store, hash-verified

1142* @return String with substituted special symbols.
1143*/
1144std::string normalizeName(const std::string &name) {
1145 std::string res;
1146 for (unsigned i = 0; i < name.length(); i++) {
1147 switch (name[i]) {
1148 case '<':
1149 res += "_lt_"; // less than
1150 break;
1151 case '>':
1152 res += "_gt_"; // great than
1153 break;
1154 case '[':
1155 res += "_lsb_"; // left square bracket
1156 break;
1157 case ']':
1158 res += "_rsb_"; // right square bracket
1159 break;
1160 case '(':
1161 res += "_lb_"; // left bracket
1162 break;
1163 case ')':
1164 res += "_rb_"; // right bracket
1165 break;
1166 case ',':
1167 res += "_comma_";
1168 break;
1169 case '~':
1170 res += "_destructor_";
1171 break;
1172 case '*':
1173 res += "_ptr_";
1174 break;
1175 case '&':
1176 res += "_ampersand_";
1177 break;
1178 case '=':
1179 res += "_eq_";
1180 break;
1181 case '!':
1182 res += "_not_";
1183 break;
1184 case '?':
1185 res += "_qm_"; // question mark
1186 break;
1187 case ' ':
1188 case '`':
1189 case '\'':
1190 case '@':
1191 case ':':
1192 case '\n':
1193 case '\r':
1194 res += '_';
1195 break;
1196 case '.':
1197 res += name[i];
1198 break;
1199 default:
1200 if (isalnum(static_cast<unsigned char>(name[i])))
1201 res += name[i];

Callers 2

getNormalizedNameMethod · 0.85
TEST_FFunction · 0.85

Calls 2

lengthMethod · 0.80
emptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.68